@SuppressWarnings( "restriction" ) private static String serialize( DispatcherTrapImpl obj ) { ByteArrayOutputStream os = new ByteArrayOutputStream(); try { ObjectOutputStream oos = new ObjectOutputStream( os ); oos.writeObject( RemoteObject.toStub( obj ) ); oos.close(); } catch ( IOException e ) { throw new RuntimeException( "Broken implementation!", e ); } return Base64.getEncoder().encodeToString( os.toByteArray() ); }
RemoteRef ref = ((RemoteObject)stub).getRef(); if (ref.getClass() != UnicastRef2.class) { throw new SecurityException(
RmiDebuggerService() { try { debugger = new RmiDebuggerImpl(this); server = new DebuggerServer((Serializable) RemoteObject.toStub(debugger)); server.start(); } catch (RemoteException e) { e.printStackTrace(); throw new UndeclaredThrowableException(e); } }
public boolean equals (Object obj) { if (obj instanceof RemoteObject) { if (ref == null) { return obj == this; } else { RemoteRef otherRef = ((RemoteObject)obj).getRef(); return ref.remoteEquals (otherRef); } } else if (obj != null) { return obj.equals (this); } else { return false; } } }
/** * Returns a stub for the given server object. * @param obj the server object for which a stub is required. Must either be * a subclass of PortableRemoteObject or have been previously the * target of a call to {@link #exportObject}. * @return the most derived stub for the object. * @exception NoSuchObjectException if a stub cannot be located for the * given server object. */ public Remote toStub(Remote obj) throws NoSuchObjectException { return RemoteObject.toStub(obj); } }
private static RemoteJMeterEngine getEngine(String hostAndPort) throws RemoteException, NotBoundException { final String name = RemoteJMeterEngineImpl.JMETER_ENGINE_RMI_NAME; // $NON-NLS-1$ $NON-NLS-2$ String host = hostAndPort; int port = RmiUtils.DEFAULT_RMI_PORT; int indexOfSeparator = hostAndPort.indexOf(':'); if (indexOfSeparator >= 0) { host = hostAndPort.substring(0, indexOfSeparator); String portAsString = hostAndPort.substring(indexOfSeparator+1); port = Integer.parseInt(portAsString); } Registry registry = LocateRegistry.getRegistry( host, port, RmiUtils.createClientSocketFactory()); Remote remobj = registry.lookup(name); if (remobj instanceof RemoteJMeterEngine){ final RemoteJMeterEngine rje = (RemoteJMeterEngine) remobj; if (remobj instanceof RemoteObject){ RemoteObject robj = (RemoteObject) remobj; System.out.println("Using remote object: "+robj.getRef().remoteToString()); // NOSONAR } return rje; } throw new RemoteException("Could not find "+name); }
public Remote toStub() throws IOException { return RemoteObject.toStub(this); }
//nopackage -- move if you like import java.rmi.Remote; import java.rmi.registry.*; import java.rmi.server.*; import sun.rmi.server.UnicastRef; import sun.rmi.transport.LiveRef; public class JMXTarget { /* * run: java JMXTarget host port * where host (name or address) contains the JVM process offering JMX * and port (number) is the registry specified by -Dcom.sun.management.jmxremote.port */ public static void main(String[] args) throws Exception { Registry reg = LocateRegistry.getRegistry (args[0], Integer.parseInt(args[1])); Remote r = reg.lookup ("jmxrmi"); RemoteObject ro = (RemoteObject)r; RemoteRef rr = ro.getRef(); UnicastRef ur = (UnicastRef)rr; LiveRef lr = ur.getLiveRef(); System.out.println (lr); } }
/** Override replaceObject to check for Remote objects that are not RemoteStubs. */ protected Object replaceObject(Object obj) throws IOException { if( (obj instanceof Remote) && !(obj instanceof RemoteStub) ) { Remote remote = (Remote) obj; try { obj = RemoteObject.toStub(remote); } catch(IOException ignore) { // Let the Serialization layer try with the orignal obj } } return obj; }
actualRegistryPort = ((UnicastRef) registry.getRef()).getLiveRef().getPort();
/** Override replaceObject to check for Remote objects that are not RemoteStubs. */ protected Object replaceObject(Object obj) throws IOException { if( (obj instanceof Remote) && !(obj instanceof RemoteStub) ) { Remote remote = (Remote) obj; try { obj = RemoteObject.toStub(remote); } catch(IOException ignore) { // Let the Serialization layer try with the orignal obj } } return obj; } }
actualRegistryPort = ((UnicastRef) registry.getRef()).getLiveRef().getPort();
/** * Override replaceObject to check for Remote objects that are * not RemoteStubs. */ protected Object replaceObject(Object obj) throws IOException { if((obj instanceof Remote) && !(obj instanceof RemoteStub)) { Remote remote = (Remote) obj; try { obj = RemoteObject.toStub(remote); } catch(IOException ignore) { // Let the Serialization layer try with the orignal obj } } return obj; }
actualRegistryPort = ((UnicastRef) registry.getRef()).getLiveRef().getPort();
/** Override replaceObject to check for Remote objects that are not RemoteStubs. */ protected Object replaceObject(Object obj) throws IOException { if( (obj instanceof Remote) && !(obj instanceof RemoteStub) ) { Remote remote = (Remote) obj; try { obj = RemoteObject.toStub(remote); } catch(IOException ignore) { // Let the Serialization layer try with the orignal obj } } return obj; } }
RemoteRef remoteRef = remoteObject.getRef(); Assert.assertTrue(remoteRef instanceof ProxyRef); ProxyRef proxyRef = (ProxyRef) remoteRef;
public synchronized Remote export(Remote impl) throws ExportException { this.impl = impl; try { return RemoteObject.toStub(impl); } catch (NoSuchObjectException e) { throw new ExportException("no stub found", e); } }
/** * Outputs the remote repository reference as a serialized stream. * * @param request HTTP request * @param response HTTP response * @throws ServletException if the remote reference is not available * @throws IOException on IO errors */ protected void doGet( HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("application/octet-stream"); ObjectOutputStream output = new ObjectOutputStream(response.getOutputStream()); output.writeObject(RemoteObject.toStub(getRemoteRepository())); output.flush(); }
/** * Outputs the remote repository reference as a serialized stream. * * @param request HTTP request * @param response HTTP response * @throws ServletException if the remote reference is not available * @throws IOException on IO errors */ protected void doGet( HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("application/octet-stream"); ObjectOutputStream output = new ObjectOutputStream(response.getOutputStream()); output.writeObject(RemoteObject.toStub(getRemoteRepository())); output.flush(); }
/** * Converts a ServiceItem to an Item. Any exception that results is bundled up into a * MarshalException. */ public Item(ServiceItem item) throws RemoteException { Object svc = item.service; if (enableImplToStubReplacement && svc instanceof Remote) { try { svc = RemoteObject.toStub((Remote) svc); if (logger.isLoggable(Level.FINER)) { logger.log(Level.FINER, "replacing {0} with {1}", new Object[]{item.service, svc}); } } catch (NoSuchObjectException e) { } } serviceID = item.serviceID; ServiceTypeBase stb = ClassMapper.toServiceTypeBase(svc.getClass()); serviceType = stb.type; codebase = stb.codebase; try { service = new MarshalledWrapper(svc); } catch (IOException e) { throw new MarshalException("error marshalling arguments", e); } attributeSets = EntryRep.toEntryRep(item.attributeSets, true); }