public class RmiClientService extends AbstractClientService
Objects are shared by adding them to the RmiRegistry with one of the share() methods. Shared objects must have a separate interface and implementation. The interface is what the other end of the connection will use to interact with the object and that interface class must be available on both ends of the connection. The implementing class need only be on the sharing end.
Shared objects can be accessed on the other end of the connection by using one of the RmiRegistry's getRemoteObject() methods. These can be used to lookup an object by class if it is a shared singleton or by name if it was registered with a name.
Note: This RMI implementation is not as advanced as Java's regular RMI as it won't marshall shared references, ie: you can't pass a shared objects as an argument to another shared object's method.
Constructor and Description |
---|
RmiClientService() |
RmiClientService(short rmiObjectId,
byte defaultChannel) |
Modifier and Type | Method and Description |
---|---|
<T> T |
getRemoteObject(java.lang.Class<T> type)
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.
|
<T> T |
getRemoteObject(java.lang.String name,
java.lang.Class<T> type)
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.
|
protected void |
onInitialize(ClientServiceManager s)
Called during initialize() for the subclass to perform
implementation specific initialization.
|
<T> void |
share(byte channel,
java.lang.String name,
T object,
java.lang.Class<? super T> type)
Shares the specified object with the server and associates it with the
specified name.
|
<T> void |
share(byte channel,
T object,
java.lang.Class<? super T> type)
Shares the specified object with the server and associates it with the
specified type.
|
<T> void |
share(java.lang.String name,
T object,
java.lang.Class<? super T> type)
Shares the specified object with the server and associates it with the
specified name.
|
<T> void |
share(T object,
java.lang.Class<? super T> type)
Shares the specified object with the server and associates it with the
specified type.
|
void |
start()
Default implementation does nothing.
|
getClient
getService, getServiceManager, initialize, stop, terminate, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
initialize, stop, terminate
public RmiClientService()
public RmiClientService(short rmiObjectId, byte defaultChannel)
public <T> void share(T object, java.lang.Class<? super T> type)
public <T> void share(byte channel, T object, java.lang.Class<? super T> type)
public <T> void share(java.lang.String name, T object, java.lang.Class<? super T> type)
public <T> void share(byte channel, java.lang.String name, T object, java.lang.Class<? super T> type)
public <T> T getRemoteObject(java.lang.Class<T> type)
public <T> T getRemoteObject(java.lang.String name, java.lang.Class<T> type)
protected void onInitialize(ClientServiceManager s)
AbstractService
onInitialize
in class AbstractService<ClientServiceManager>
public void start()
AbstractService
start
in interface ClientService
start
in interface Service<ClientServiceManager>
start
in class AbstractService<ClientServiceManager>