de.root1.simon
Class Registry

java.lang.Object
  extended by de.root1.simon.Registry

public final class Registry
extends java.lang.Object

The SIMON server acts as a registry for remote objects. So, Registry is SIMON's internal server implementation

Author:
achristian

Constructor Summary
protected Registry(java.net.InetAddress address, int port, java.util.concurrent.ExecutorService threadPool, java.lang.String protocolFactoryClassName)
          Creates a registry
protected Registry(java.net.InetAddress address, int port, java.util.concurrent.ExecutorService threadPool, java.lang.String protocolFactoryClassName, SslContextFactory sslContextFactory)
          Creates a SSL powered registry
 
Method Summary
 void bind(java.lang.String name, java.lang.Object remoteObject)
          Binds a remote object to the registry's own LookupTable
 void bindAndPublish(java.lang.String name, java.lang.Object remoteObject)
          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)
protected  Dispatcher getDispatcher()
          Returns the Dispatcher associated with this registry.
 int getKeepAliveInterval()
          Gets the keep alive interval time in seconds of this registry.
 int getKeepAliveTimeout()
          Gets the keep alive timeout time in seconds of this registry.
 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
 boolean isRunning()
          Returns whether the registry is running and active or not
 void rebind(java.lang.String name, java.lang.Object remoteObject)
          As the name says, it re-binds a remote object.
 void setKeepAliveInterval(int seconds)
          Sets the keep alive interval time in seconds for this registry
 void setKeepAliveTimeout(int seconds)
          Sets the keep alive timeout time in seconds for this registry.
 void stop()
          Stops the registry.
 boolean unbind(java.lang.String name)
          Unbinds a remote object from the registry's own LookupTable.
 boolean unpublish(java.lang.String name)
          Unpublish a already published remote object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Registry

protected Registry(java.net.InetAddress address,
                   int port,
                   java.util.concurrent.ExecutorService threadPool,
                   java.lang.String protocolFactoryClassName)
            throws java.io.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:
java.io.IOException - if there are problems with creating the mina socketserver

Registry

protected Registry(java.net.InetAddress address,
                   int port,
                   java.util.concurrent.ExecutorService threadPool,
                   java.lang.String protocolFactoryClassName,
                   SslContextFactory sslContextFactory)
            throws java.io.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:
java.io.IOException - if there are problems with creating the mina socketserver
Method Detail

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 running this method, no further connection/communication is possible with this registry.


bind

public void bind(java.lang.String name,
                 java.lang.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

bindAndPublish

public void bindAndPublish(java.lang.String name,
                           java.lang.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

unbind

public boolean unbind(java.lang.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(java.lang.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(java.lang.String name,
                   java.lang.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


Copyright © 2011. All Rights Reserved.