Class Registry

java.lang.Object
host.anzo.simon.Registry

public final class Registry extends Object
The SIMON server acts as a registry for remote objects. So, Registry is SIMON's internal server implementation
  • Constructor Details

    • Registry

      protected Registry(InetAddress address, int port, ExecutorService threadPool, String protocolFactoryClassName) throws IOException
      Creates a registry
      Parameters:
      address - the interface address on which the socketserver listens on
      port - the port on which the socketserver listens on
      threadPool - the thread pool implementation which is forwarded to the dispatcher
      protocolFactoryClassName - the full classname of the class that describes to network protocol
      Throws:
      IOException - if there are problems with creating the mina socketserver
    • Registry

      protected Registry(InetAddress address, int port, ExecutorService threadPool, String protocolFactoryClassName, SslContextFactory sslContextFactory) throws IOException
      Creates a SSL powered registry
      Parameters:
      address - the interface address on which the socketserver listens on
      port - the port on which the socketserver listens on
      threadPool - the thread pool implementation which is forwarded to the dispatcher
      protocolFactoryClassName - the full classname of the class that describes to network protocol
      sslContextFactory - the factory which is used to get the server ssl context
      Throws:
      IOException - if there are problems with creating the mina socketserver
  • Method Details

    • start

      public void start() throws IOException
      Starts the registry thread. After stopping, a registry cannot start again. One need to create a new registry.
      Throws:
      IOException - if there's a problem getting a selector for the non-blocking network communication, or if the
      IllegalArgumentException - if specified protocol codec cannot be used
      IllegalStateException - if registry is already started or has been stopped.
    • setKeepAliveTimeout

      public void setKeepAliveTimeout(int seconds)
      Sets the keep alive timeout time in seconds for this registry.
      Parameters:
      seconds - time in seconds
    • setKeepAliveInterval

      public void setKeepAliveInterval(int seconds)
      Sets the keep alive interval time in seconds for this registry
      Parameters:
      seconds - time in seconds
    • getKeepAliveTimeout

      public int getKeepAliveTimeout()
      Gets the keep alive timeout time in seconds of this registry.
      Returns:
      current set keep alive timeout
    • getKeepAliveInterval

      public int getKeepAliveInterval()
      Gets the keep alive interval time in seconds of this registry.
      Returns:
      current set keep alive interval
    • stop

      public void stop()
      Stops the registry. This clears the LookupTable in the dispatcher, stops the acceptor and the Dispatcher. After stopping this registry, no further connection/communication is possible with this registry.
    • bind

      public void bind(String name, Object remoteObject) throws NameBindingException
      Binds a remote object to the registry's own LookupTable
      Parameters:
      name - a name for object to bind
      remoteObject - the object to bind
      Throws:
      NameBindingException - if there are problems binding the remoteobject to the registry
      IllegalStateException - if registry is not yet started or already stopped
    • bindAndPublish

      public void bindAndPublish(String name, Object remoteObject) throws NameBindingException
      Binds the object to the Registry and publishes it to the network, so that they can be found with Simon.searchRemoteObjects(int) or Simon.searchRemoteObjects(SearchProgressListener, int)
      Parameters:
      name - a name for the object to bind and publish
      remoteObject - the object to bind and publish
      Throws:
      NameBindingException - if binding fails
    • bindAndPublishRemote

      public void bindAndPublishRemote(String name, Object remoteObject, InetSocketAddress remoteRegistry) throws NameBindingException
      Throws:
      NameBindingException
    • unbind

      public boolean unbind(String name)
      Unbinds a remote object from the registry's own LookupTable. If it's published, it's removed from the list of published objects
      Parameters:
      name - the object to unbind (and unpublish, if published)
      Returns:
      true, if unpublish succeeded, false, if object wasn't published and though can't be unpublished
    • unpublish

      public boolean unpublish(String name)
      Unpublish a already published remote object.
      Parameters:
      name - the object to unpublish, if published
      Returns:
      true, if unpublish succeeded, false, if object wasn't published and though can't be unpublished
    • rebind

      public void rebind(String name, Object remoteObject)
      As the name says, it re-binds a remote object. This method shows the same behavior as the following two commands in sequence:

      unbind(name);
      bind(name, remoteObject);
      Parameters:
      name - the name of the object to rebind
      remoteObject - the object to rebind
    • isRunning

      public boolean isRunning()
      Returns whether the registry is running and active or not
      Returns:
      boolean
    • getStatistics

      public SimonRegistryStatistics getStatistics()
      Returns a object that lets you get some network related information on the session of the given remote object (an instance of SimonProxy
      Returns:
      an implementation of SimonRegistryStatistics that gives access to the statistics data of this Registry
    • getDispatcher

      protected Dispatcher getDispatcher()
      Returns the Dispatcher associated with this registry.
      Returns:
      the related dispatcher
    • getClassLoader

      public ClassLoader getClassLoader()
      The classloader which is used to load remote interface classes (used in remote callbacks f.i.).
      Returns:
      ClassLoader
      Since:
      1.2.0
    • setClassLoader

      public void setClassLoader(ClassLoader classLoader)
      Set the classloader which is used to load remote interface classes (used in remote callbacks f.i.)
      Parameters:
      classLoader -
      Since:
      1.2.0