Class RmiClientService
- All Implemented Interfaces:
ClientService, Service<ClientServiceManager>
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.
- Author:
- Paul Speed
-
Constructor Summary
ConstructorsConstructorDescriptionCreates an RMI client service using the default object id and reliable channel.RmiClientService(short rmiObjectId, byte defaultChannel) Creates an RMI client service. -
Method Summary
Modifier and TypeMethodDescription<T> TgetRemoteObject(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> TgetRemoteObject(String name, 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 voidCalled during initialize() for the subclass to perform implementation specific initialization.<T> voidShares the specified object with the server and associates it with the specified name.<T> voidShares the specified object with the server and associates it with the specified type.<T> voidShares the specified object with the server and associates it with the specified name.<T> voidShares the specified object with the server and associates it with the specified type.voidstart()Default implementation does nothing.Methods inherited from class AbstractClientService
getClientMethods inherited from class AbstractService
getService, getServiceManager, initialize, stop, terminate, toStringMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface ClientService
initialize, stop, terminate
-
Constructor Details
-
RmiClientService
public RmiClientService()Creates an RMI client service using the default object id and reliable channel. -
RmiClientService
public RmiClientService(short rmiObjectId, byte defaultChannel) Creates an RMI client service.- Parameters:
rmiObjectId- the shared RMI object iddefaultChannel- the default network channel for RMI traffic
-
-
Method Details
-
getRemoteObject
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.- Type Parameters:
T- the requested proxy type- Parameters:
type- the shared interface type- Returns:
- the remote object proxy
-
getRemoteObject
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.- Type Parameters:
T- the requested proxy type- Parameters:
name- the exported object nametype- the shared interface type- Returns:
- the remote object proxy
-
onInitialize
Description copied from class:AbstractServiceCalled during initialize() for the subclass to perform implementation specific initialization.- Specified by:
onInitializein classAbstractService<ClientServiceManager>- Parameters:
s- the service manager initializing this service
-
start
public void start()Description copied from class:AbstractServiceDefault implementation does nothing. Implementations can override this to perform custom startup behavior.- Specified by:
startin interfaceClientService- Specified by:
startin interfaceService<ClientServiceManager>- Overrides:
startin classAbstractService<ClientServiceManager>