Package host.anzo.simon
Class Registry
java.lang.Object
host.anzo.simon.Registry
The SIMON server acts as a registry for remote objects. So, Registry is
SIMON's internal server implementation
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedRegistry(InetAddress address, int port, ExecutorService threadPool, String protocolFactoryClassName) Creates a registryprotectedRegistry(InetAddress address, int port, ExecutorService threadPool, String protocolFactoryClassName, SslContextFactory sslContextFactory) Creates a SSL powered registry -
Method Summary
Modifier and TypeMethodDescriptionvoidBinds a remote object to the registry's ownLookupTablevoidbindAndPublish(String name, Object remoteObject) Binds the object to theRegistryand publishes it to the network, so that they can be found withSimon.searchRemoteObjects(int)orSimon.searchRemoteObjects(SearchProgressListener, int)voidbindAndPublishRemote(String name, Object remoteObject, InetSocketAddress remoteRegistry) The classloader which is used to load remote interface classes (used in remote callbacks f.i.).protected DispatcherReturns theDispatcherassociated with this registry.intGets the keep alive interval time in seconds of this registry.intGets the keep alive timeout time in seconds of this registry.Returns a object that lets you get some network related information on the session of the given remote object (an instance ofSimonProxybooleanReturns whether the registry is running and active or notvoidAs the name says, it re-binds a remote object.voidsetClassLoader(ClassLoader classLoader) Set the classloader which is used to load remote interface classes (used in remote callbacks f.i.)voidsetKeepAliveInterval(int seconds) Sets the keep alive interval time in seconds for this registryvoidsetKeepAliveTimeout(int seconds) Sets the keep alive timeout time in seconds for this registry.voidstart()Starts the registry thread.voidstop()Stops the registry.booleanUnbinds a remote object from the registry's ownLookupTable.booleanUnpublish a already published remote object.
-
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 onport- the port on which the socketserver listens onthreadPool- the thread pool implementation which is forwarded to the dispatcherprotocolFactoryClassName- 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 onport- the port on which the socketserver listens onthreadPool- the thread pool implementation which is forwarded to the dispatcherprotocolFactoryClassName- the full classname of the class that describes to network protocolsslContextFactory- 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
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 theIllegalArgumentException- if specified protocol codec cannot be usedIllegalStateException- 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 theLookupTablein the dispatcher, stops the acceptor and theDispatcher. After stopping this registry, no further connection/communication is possible with this registry. -
bind
Binds a remote object to the registry's ownLookupTable- Parameters:
name- a name for object to bindremoteObject- the object to bind- Throws:
NameBindingException- if there are problems binding the remoteobject to the registryIllegalStateException- if registry is not yet started or already stopped
-
bindAndPublish
Binds the object to theRegistryand publishes it to the network, so that they can be found withSimon.searchRemoteObjects(int)orSimon.searchRemoteObjects(SearchProgressListener, int)- Parameters:
name- a name for the object to bind and publishremoteObject- 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
Unbinds a remote object from the registry's ownLookupTable. 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
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
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 rebindremoteObject- the object to rebind
-
isRunning
public boolean isRunning()Returns whether the registry is running and active or not- Returns:
- boolean
-
getStatistics
Returns a object that lets you get some network related information on the session of the given remote object (an instance ofSimonProxy- Returns:
- an implementation of
SimonRegistryStatisticsthat gives access to the statistics data of thisRegistry
-
getDispatcher
Returns theDispatcherassociated with this registry.- Returns:
- the related dispatcher
-
getClassLoader
The classloader which is used to load remote interface classes (used in remote callbacks f.i.).- Returns:
- ClassLoader
- Since:
- 1.2.0
-
setClassLoader
Set the classloader which is used to load remote interface classes (used in remote callbacks f.i.)- Parameters:
classLoader-- Since:
- 1.2.0
-