Class RmiClientService

All Implemented Interfaces:
ClientService, Service<ClientServiceManager>

public class RmiClientService extends AbstractClientService
A service that can be added to the client to support a simple shared objects protocol.

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 Summary

    Constructors
    Constructor
    Description
     
    RmiClientService(short rmiObjectId, byte defaultChannel)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    <T> T
    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(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 void
    Called during initialize() for the subclass to perform implementation specific initialization.
    <T> void
    share(byte channel, String name, T object, 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, Class<? super T> type)
    Shares the specified object with the server and associates it with the specified type.
    <T> void
    share(String name, T object, Class<? super T> type)
    Shares the specified object with the server and associates it with the specified name.
    <T> void
    share(T object, Class<? super T> type)
    Shares the specified object with the server and associates it with the specified type.
    void
    Default implementation does nothing.

    Methods inherited from class com.jme3.network.service.AbstractClientService

    getClient

    Methods inherited from class com.jme3.network.service.AbstractService

    getService, getServiceManager, initialize, stop, terminate, toString

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface com.jme3.network.service.ClientService

    initialize, stop, terminate
  • Constructor Details

    • RmiClientService

      public RmiClientService()
    • RmiClientService

      public RmiClientService(short rmiObjectId, byte defaultChannel)
  • Method Details

    • share

      public <T> void share(T object, Class<? super T> type)
      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.
    • share

      public <T> void share(byte channel, T object, Class<? super T> type)
      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. All object related communication will be done over the specified connection channel.
    • share

      public <T> void share(String name, T object, Class<? super T> 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.
    • share

      public <T> void share(byte channel, String name, T object, Class<? super T> 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. All object related communication will be done over the specified connection channel.
    • getRemoteObject

      public <T> T getRemoteObject(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.
    • getRemoteObject

      public <T> T getRemoteObject(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.
    • onInitialize

      protected void onInitialize(ClientServiceManager s)
      Description copied from class: AbstractService
      Called during initialize() for the subclass to perform implementation specific initialization.
      Specified by:
      onInitialize in class AbstractService<ClientServiceManager>
    • start

      public void start()
      Description copied from class: AbstractService
      Default implementation does nothing. Implementations can override this to perform custom startup behavior.
      Specified by:
      start in interface ClientService
      Specified by:
      start in interface Service<ClientServiceManager>
      Overrides:
      start in class AbstractService<ClientServiceManager>