本文整理汇总了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);
}