而使用了業務代理後
public static void main(String[] argv) throws Exception {
BusinessDelegate bd=new BusinessDelegate()
Order o=bd
o
bd
}
在業務代理對象BusinessDelegate中
public class BusinessDelegate {
IOrderManager usermanager =null; //封裝遠程方法調用的流程
public BusinessDelegate(){
try {
usermanager = (IOrderManager) Naming
} catch (MalformedURLException e) {
e
} catch (RemoteException e) {
e
} catch (NotBoundException e) {
e
}
}
public boolean checkUserFromCache(int uid){
return true;
}
public boolean checkUser(int uid) throws RemoteException{
//當前對象被多個客戶端共享
//可以在本地緩存中校驗用戶
[
From:http://tw.wingwit.com/Article/program/Java/gj/201311/27808.html