Class RmiRegistry

java.lang.Object
com.jme3.network.service.rmi.RmiRegistry

public class RmiRegistry extends Object
Maintains locally shared objects and remote proxies for the RMI service.
Author:
Paul Speed
  • Constructor Summary

    Constructors
    Constructor
    Description
    RmiRegistry(HostedConnection context, RpcConnection rpc, short rmiId, byte defaultChannel)
    Creates an RMI registry.
    RmiRegistry(RpcConnection rpc, short rmiId, byte defaultChannel)
    Creates an RMI registry without a server-side connection context.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    Registers remote class metadata announced by the far end.
    protected void
    addRemoteObject(byte channel, short objectId, String name, ClassInfo typeInfo)
    Registers a remote object proxy from metadata received over the wire.
    <T> T
    Returns a local object that was previously registered with share() using just type registration.
    <T> T
    getLocalObject(String name, Class<T> type)
    Returns a local object that was previously registered with share() using name registration.
    <T> T
    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.
    <T> T
    getRemoteObject(String name, Class<T> type)
    Looks up a remote object by name and returns a local proxy to the remote object that was shared on the other end of the network connection.
    protected Object
    invokeLocal(short objectId, short procId, Object[] args)
    Handle the actual remote object method calls.
    protected Object
    invokeRemote(byte channel, short objectId, short procId, CallType callType, Object[] args)
    Invokes a remote procedure through the configured RPC layer.
    protected void
    removeRemoteObject(short objectId)
    Removes a previously registered remote object.
    protected void
    rmiUpdate(short procId, Object[] args)
    Handle remote object registry updates from the other end.
    <T> void
    share(byte channel, String name, T object, Class<? super T> type)
    Exposes, through a specific connection channel, the specified object to the other end of the connection as the specified interface type and associates it with the specified name.
    <T> void
    share(byte channel, T object, Class<? super T> type)
    Exposes, through a specific connection channel, the specified object to the other end of the connection as the specified interface type.
    <T> void
    share(String name, T object, Class<? super T> type)
    Exposes the specified object to the other end of the connection as the specified interface type and associates it with the specified name.
    <T> void
    share(T object, Class<? super T> type)
    Exposes the specified object to the other end of the connection as the specified interface type.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • RmiRegistry

      public RmiRegistry(RpcConnection rpc, short rmiId, byte defaultChannel)
      Creates an RMI registry without a server-side connection context.
      Parameters:
      rpc - the backing RPC connection
      rmiId - the registry RPC object id
      defaultChannel - the default network channel for RMI traffic
    • RmiRegistry

      public RmiRegistry(HostedConnection context, RpcConnection rpc, short rmiId, byte defaultChannel)
      Creates an RMI registry.
      Parameters:
      context - the hosted connection currently associated with local RMI calls, or null
      rpc - the backing RPC connection
      rmiId - the registry RPC object id
      defaultChannel - the default network channel for RMI traffic
  • Method Details

    • share

      public <T> void share(T object, Class<? super T> 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.
      Type Parameters:
      T - the shared object type
      Parameters:
      object - the object to share
      type - the shared interface type
    • share

      public <T> void share(byte channel, T object, Class<? super T> type)
      Exposes, through a specific connection channel, 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. The specified channel will be used for all network communication specific to this object.
      Type Parameters:
      T - the shared object type
      Parameters:
      channel - the network channel to use
      object - the object to share
      type - the shared interface type
    • share

      public <T> void share(String name, T object, Class<? super T> type)
      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.
      Type Parameters:
      T - the shared object type
      Parameters:
      name - the exported object name
      object - the object to share
      type - the shared interface type
    • share

      public <T> void share(byte channel, String name, T object, Class<? super T> type)
      Exposes, through a specific connection channel, 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. The specified channel will be used for all network communication specific to this object.
      Type Parameters:
      T - the shared object type
      Parameters:
      channel - the network channel to use
      name - the exported object name
      object - the object to share
      type - the shared interface type
    • getLocalObject

      public <T> T getLocalObject(Class<T> type)
      Returns a local object that was previously registered with share() using just type registration.
      Type Parameters:
      T - the requested object type
      Parameters:
      type - the shared interface type
      Returns:
      the shared local object
    • getLocalObject

      public <T> T getLocalObject(String name, Class<T> type)
      Returns a local object that was previously registered with share() using name registration.
      Type Parameters:
      T - the requested object type
      Parameters:
      name - the exported object name
      type - the shared interface type
      Returns:
      the shared local object
    • getRemoteObject

      public <T> T getRemoteObject(Class<T> 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.
      Type Parameters:
      T - the requested proxy type
      Parameters:
      type - the shared interface type
      Returns:
      the remote object proxy
    • getRemoteObject

      public <T> T getRemoteObject(String name, Class<T> type)
      Looks up a remote object by name 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.
      Type Parameters:
      T - the requested proxy type
      Parameters:
      name - the exported object name
      type - the shared interface type
      Returns:
      the remote object proxy
    • addRemoteClass

      protected void addRemoteClass(ClassInfo info)
      Registers remote class metadata announced by the far end.
      Parameters:
      info - the remote class metadata
    • removeRemoteObject

      protected void removeRemoteObject(short objectId)
      Removes a previously registered remote object.
      Parameters:
      objectId - the remote object id
    • addRemoteObject

      protected void addRemoteObject(byte channel, short objectId, String name, ClassInfo typeInfo)
      Registers a remote object proxy from metadata received over the wire.
      Parameters:
      channel - the message channel used for method calls
      objectId - the remote object id
      name - the exported object name
      typeInfo - the remote object type metadata
    • invokeRemote

      protected Object invokeRemote(byte channel, short objectId, short procId, CallType callType, Object[] args)
      Invokes a remote procedure through the configured RPC layer.
      Parameters:
      channel - the message channel to use
      objectId - the remote object id
      procId - the remote procedure id
      callType - the invocation mode
      args - the invocation arguments
      Returns:
      the remote return value for synchronous calls, or null otherwise
    • rmiUpdate

      protected void rmiUpdate(short procId, Object[] args)
      Handle remote object registry updates from the other end.
      Parameters:
      procId - the registry update procedure id
      args - the registry update arguments
    • invokeLocal

      protected Object invokeLocal(short objectId, short procId, Object[] args)
      Handle the actual remote object method calls.
      Parameters:
      objectId - the shared object id
      procId - the procedure id
      args - the invocation arguments
      Returns:
      the invocation result