public MethodInfo getMethod( Method m ) { for( MethodInfo mi : methods ) { if( mi.matches(m) ) { return mi; } } return null; }
/** * Exposes the specified object to the other end of the connection as * the specified interface type and associates it with the specified name. * The object can be looked up by the associated name on the other end of * the connection. */ public <T> void share( String name, T object, Class<? super T> type ) { share(defaultChannel, name, object, type); }
/** * Shares a server-wide object associated with the specified name. All connections * with RMI hosting started will have access to this shared object as soon as they * connect and they will all share the same instance. It is up to the shared object * to handle any multithreading that might be required. */ public <T> void shareGlobal( String name, T object, Class<? super T> type ) { shareGlobal(defaultChannel, name, object, type); }
@Override public Object invoke(Object o, Method method, Object[] os) throws Throwable { MethodInfo mi = getMethodInfo(method); if( mi == null ) { // Try to invoke locally return method.invoke(this, os); } return rmi.invokeRemote(channel, objectId, mi.getId(), mi.getCallType(), os); }
@Override public Object call( RpcConnection conn, short objectId, short procId, Object... args ) { if( objectId == rmiId ) { rmiUpdate(procId, args); return null; } else { return invokeLocal(objectId, procId, args); } } }
public MethodInfo( short id, Method m ) { this.id = id; this.method = m; this.representation = methodToString(m); this.callType = getCallType(m); }
/** * Looks up a remote object on the server by type and returns a local proxy to the * remote object that was shared on the other end of the network connection. */ public <T> T getRemoteObject( Class<T> type ) { return rmi.getRemoteObject(type); }
@Override protected void onInitialize( ClientServiceManager s ) { rpc = getService(RpcClientService.class); if( rpc == null ) { throw new RuntimeException("RmiClientService requires RpcClientService"); } // Register it now so that it is available when the // server starts to send us stuff. Waiting until start() // is too late in this case. rmi = new RmiRegistry(rpc.getRpcConnection(), rmiObjectId, defaultChannel); }
/** * Shares the specified object with the server and associates it with the * specified type. Objects shared in this way are available in the connection-specific * RMI registry on the server and are not available to other connections. */ public <T> void share( T object, Class<? super T> type ) { share(defaultChannel, object, type); }
@Override public String toString() { return "MethodInfo[#" + getId() + ", callType=" + callType + ", " + representation + "]"; } }
@Override public String toString() { return "RemoteObject[#" + objectId + ", " + typeInfo.getName() + "]"; } }
@Override protected void onInitialize( HostedServiceManager s ) { this.rpcService = getService(RpcHostedService.class); if( rpcService == null ) { throw new RuntimeException("RmiHostedService requires RpcHostedService"); } }
/** * Returns a local object that was previously registered with share() using * just type registration. */ public <T> T getLocalObject( Class<T> type ) { return getLocalObject(type.getName(), type); }
public ClassInfo( short typeId, Class type ) { this.typeId = typeId; this.name = type.getName(); this.methods = toMethodInfo(type, type.getMethods()); }
/** * Looks up a remote object on the server by name and returns a local proxy to the * remote object that was shared on the other end of the network connection. */ public <T> T getRemoteObject( String name, Class<T> type ) { return rmi.getRemoteObject(name, type); }
/** * Exposes the specified object to the other end of the connection as * the specified interface type. The object can be looked up by type * on the other end. */ public <T> void share( T object, Class<? super T> type ) { share(defaultChannel, object, type); }
/** * Shares the specified object with the server and associates it with the * specified name. Objects shared in this way are available in the connection-specific * RMI registry on the server and are not available to other connections. */ public <T> void share( String name, T object, Class<? super T> type ) { share(defaultChannel, name, object, type); }
/** * Shares a server-wide object associated with the specified type. All connections * with RMI hosting started will have access to this shared object as soon as they * connect and they will all share the same instance. It is up to the shared object * to handle any multithreading that might be required. */ public <T> void shareGlobal( T object, Class<? super T> type ) { shareGlobal(defaultChannel, type.getName(), object, type); }
/** * Looks up a remote object by type and returns a local proxy to the remote object * that was shared on the other end of the network connection. If this is called * from a client then it is accessing a shared object registered on the server. * If this is called from the server then it is accessing a shared object registered * on the client. */ public <T> T getRemoteObject( Class<T> type ) { return getRemoteObject(type.getName(), type); }