本文整理匯總了Java中javax.rmi.PortableRemoteObject.toStub方法的典型用法代碼示例。如果您正苦於以下問題:Java PortableRemoteObject.toStub方法的具體用法?Java PortableRemoteObject.toStub怎麽用?Java PortableRemoteObject.toStub使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.rmi.PortableRemoteObject
的用法示例。
在下文中一共展示了PortableRemoteObject.toStub方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: toStub
import javax.rmi.PortableRemoteObject; //導入方法依賴的package包/類
@Override
public Remote toStub(final Remote obj) throws NoSuchObjectException {
if (System.getSecurityManager() == null) {
return PortableRemoteObject.toStub(obj);
} else {
try {
return AccessController.doPrivileged(new PrivilegedExceptionAction<Remote>() {
@Override
public Remote run() throws Exception {
return PortableRemoteObject.toStub(obj);
}
}, STUB_ACC);
} catch (PrivilegedActionException e) {
if (e.getException() instanceof NoSuchObjectException) {
throw (NoSuchObjectException)e.getException();
}
throw new RuntimeException("Unexpected exception type", e.getException());
}
}
}
示例2: getEchoStub
import javax.rmi.PortableRemoteObject; //導入方法依賴的package包/類
/**
* Initialize the ORB and the singleton Echo server stub.
* @return the stub for the Echo server.
* @throws RemoteException if an error occurs
*/
synchronized Echo getEchoStub() throws RemoteException {
if (echoStub == null) {
ORB orb = (ORB) ORB.init(new String[0], null);
Echo server = new Server();
echoStub = (javax.rmi.CORBA.Stub) PortableRemoteObject.toStub(server);
echoStub.connect(orb);
}
return (Echo)echoStub;
}
示例3: toStub
import javax.rmi.PortableRemoteObject; //導入方法依賴的package包/類
public static Object toStub(final Object obj) throws IOException {
final Tie tie = javax.rmi.CORBA.Util.getTie((Remote) obj);
if (tie == null) {
throw new IOException("Unable to serialize PortableRemoteObject; object has not been exported: " + obj);
}
final ORB orb = getORB();
tie.orb(orb);
return PortableRemoteObject.toStub((Remote) obj);
}
示例4: toStub
import javax.rmi.PortableRemoteObject; //導入方法依賴的package包/類
@Override
public Remote toStub(Remote obj) throws NoSuchObjectException {
return PortableRemoteObject.toStub(obj);
}