[英]How do I register a server in the default RMI registry for JBoss and access it from a client running in another JVM?
[英]RMI bind object to Registry and access from Client
我正在努力從我的注冊表訪問遠程對象。 我不太明白如何在客戶端訪問綁定對象。 我所做的是:
// export for RMI
IRemote remoteObject = new RemoteObject();
IRemote stub = (IRemote) UnicastRemoteObject.exportObject(remoteObject, 0);
// bind to registry so clients can find it
Registry registry = LocateRegistry.createRegistry(port); registry.bind(bindingName, stub);
風險管理信息
// 服務器
// export for RMI
IRemote remoteObject = new RemoteObject();
IRemote stub = (IRemote) UnicastRemoteObject.exportObject(remoteObject, 0);
// bind to registry so clients can find it
Registry registry = LocateRegistry.createRegistry(port);
registry.bind(bindingName, stub);
// unexport
UnicastRemoteObject.unexportObject(remoteObject, true);
// 客戶
// lookup remote object on server
Registry registry = LocateRegistry.getRegistry(host, port);
IRemote remoteObject = (IRemote) registry.lookup(name);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.