stella.net
Class ParameterRelay
java.lang.Object
util.PropertyContainer
util.PropertyResources
util.PropertyBundles
util.rmi.RmiPropertyContainer
util.rmi.AbstractRmiCaster
stella.CastingContainer
stella.net.ReceiverServer
stella.net.ParameterRelay
- All Implemented Interfaces:
- Cloneable, Runnable, Remote, ErrorProcessing, CancelRunnable, ExitCleaning, Initializable, LocalizedSupplying, PropertySupplying, ResourceSupplying, RmiCaster, RmiPropertyBearing
public class ParameterRelay
- extends ReceiverServer
A parameter server class. This class allows clients to connect to its
listening port to query instances of RemoteParameters. The
functionality is as follows.
- After starting the server with the
startServer() method it
aquires a listening state on the port defined by #KEY_PORT.
- Incomming request spawn a new
ParameterRelay.ParameterHandler thread.
This thread reads in the name of the parameter to be querried from
the client.
- The parameter name is than looked-up in a known-parameter list. If
not present, the registry is asked for a binding with the given name.
If such a binding exists and is linke to a
RemoteParameter
instance, it is stored in the look-up list for further reference.
The remote paramter is then queried with its
RemoteParameter.remoteGet() method to deliver the object requested.
- The object is converted to a string that
is written to the socket-stream. The stream is terminated
with a newline and flushed.
- This ends the protocol. The streams and the sockets are closed.
The parameter relay runs as stand-alone.
|
Method Summary |
void |
cancel()
Cancels the parameter server. |
protected void |
protocol(Socket client)
The method called as soon as a connection is established. |
void |
startServer()
Starts the server. |
| Methods inherited from class stella.net.ReceiverServer |
exit, getAsociatedThread, getBufferSize, getHandlerPriority, getReceiverName, getServerPort, getServerPriority, init, initReceiverServer, maxTimeToCancel, processError, run |
| Methods inherited from class stella.CastingContainer |
addErrorListener, addRmiErrorListener, isValid, notifyErrorListener, removeErrorListener, removeRmiErrorListener, sendError, sendError, sendError, sendStatus, sendStatus, sendStatus |
| Methods inherited from class util.PropertyResources |
createFrom, createFrom, createFrom, getApplet, getAsResources, getLocalClassLoader, getPropertiesToKey, getPropertiesToKey, getResource, getResourceAsStream, getResourceFromKey, getResources, keyCreate, keyCreate, reload, setApplet |
| Methods inherited from class util.PropertyContainer |
augment, augment, augment, defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsEnums, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsMap, getAsObject, getAsObject, getProperties, getProperty, has, isNew, parseObject, reload, removeProperty, rescanned, setObject, setProperties, setProperty, stringProperties, toString |
| Methods inherited from interface util.PropertySupplying |
defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsObject, getAsObject, getProperties, getProperty, has, parseObject, removeProperty, setObject, setProperty, stringProperties |
KEY_HOST
public static final String KEY_HOST
- The key to the host where the registry runs.
- See Also:
- Constant Field Values
KEY_TIMEOUT
public static final String KEY_TIMEOUT
- The key for join-time on cancel.
- See Also:
- Constant Field Values
DEFTIMEOUT
private static final long DEFTIMEOUT
- The default sleep interval between available queries.
- See Also:
- Constant Field Values
parameterGroup
private static final transient ThreadGroup parameterGroup
- The thread group commands run in.
request
private ParameterRelay.ParameterHandler request
- The handler for dealing with parameter queries.
lookup
private Map lookup
- The look-up table matching names to remote parameters.
registry
private Registry registry
- The registry, where parameters are look-up.
ParameterRelay
public ParameterRelay(Map prop)
throws RemoteException
- Constructs a new parameter server. The server thread must be started
explicetly with a call to
startServer().
- Throws:
RemoteException
startServer
public void startServer()
- Starts the server. The linked thread is already constructed in
ReceiverServer.ReceiverServer(Map), which also sets
the server priority.
cancel
public void cancel()
- Cancels the parameter server. If a connection is currently active, it
is first closed.
- Specified by:
cancel in interface CancelRunnable- Overrides:
cancel in class ReceiverServer
protocol
protected void protocol(Socket client)
- The method called as soon as a connection is established. It spwans
a
ParameterRelay.ParameterHandler thread witch performs the actual
communication.
- Specified by:
protocol in class ReceiverServer
- Parameters:
client - The client socket.- See Also:
CommandReceiver,
ErrorReceiver