com.sun.slamd.server
Class ClientManagerListener

java.lang.Object
  extended by java.lang.Thread
      extended by com.sun.slamd.server.ClientManagerListener
All Implemented Interfaces:
ConfigSubscriber, java.lang.Runnable

public class ClientManagerListener
extends java.lang.Thread
implements ConfigSubscriber

This class defines a thread that will listen for connections from client managers.

Author:
Neil A. Wilson

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
ClientManagerListener(SLAMDServer slamdServer)
          Creates a new listener that will listen for connections from client managers.
 
Method Summary
 void clientConnectionLost(ClientConnection clientConnection)
          Indicates that the specified client has disconnected from the SLAMD server and that the client managers should be polled to determine if that client might have been associated with a client manager.
 void connectionLost(ClientManagerConnection clientManagerConnection)
          Indicates that the connection to the provided client manager has been lost and that it should be removed from the list of available client managers.
 ClientManagerConnection getClientManager(java.lang.String clientID)
          Retrieves a connection to the requested client manager.
 ClientManagerConnection[] getClientManagers()
          Retrieves the list of client manager connections associated with the client managers that have connected to the SLAMD server.
 int getMaxResponseWaitTime()
          Retrieves the maximum length of time in seconds that the SLAMD server will wait for a response to a request issued to a client manager.
 java.lang.String getSubscriberName()
          Retrieves the name that the client manager listener uses to subscribe to the configuration handler in order to be notified of configuration changes.
 ParameterList getSubscriberParameters()
          Retrieves the set of configuration parameters associated with this configuration subscriber.
 void refreshSubscriberConfiguration()
          Re-reads all configuration information used by the client listener manager.
 void refreshSubscriberConfiguration(java.lang.String parameterName)
          Re-reads the configuration for the specified parameter if the parameter is applicable to the client manager listener.
 void run()
          Creates the server socket that will be used to accept new connections, then listens for new connections until the SLAMD server is shut down.
 void startListening()
          Indicates that the listener should start listening for client manager connections.
 void stopListening()
          Indicates that the listener should stop listening for client connections.
 void waitForStop()
          This method will not return until the listener has actually stopped.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ClientManagerListener

public ClientManagerListener(SLAMDServer slamdServer)
Creates a new listener that will listen for connections from client managers.

Parameters:
slamdServer - The SLAMD server with which this client manager listener is associated.
Method Detail

run

public void run()
Creates the server socket that will be used to accept new connections, then listens for new connections until the SLAMD server is shut down.

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

startListening

public void startListening()
Indicates that the listener should start listening for client manager connections.


stopListening

public void stopListening()
Indicates that the listener should stop listening for client connections. It will also notify all connected clients that the listener is shutting down.


waitForStop

public void waitForStop()
This method will not return until the listener has actually stopped. Note that it does not stop the listener -- you should first call the stopListening method to signal the listener that it needs to stop.


getClientManagers

public ClientManagerConnection[] getClientManagers()
Retrieves the list of client manager connections associated with the client managers that have connected to the SLAMD server.

Returns:
The list of client manager connections associated with the client managers that have connected to the SLAMD server.

getClientManager

public ClientManagerConnection getClientManager(java.lang.String clientID)
Retrieves a connection to the requested client manager.

Parameters:
clientID - The client ID associated with the client manager for which to retrieve the connection.
Returns:
The requested client manager connection, or null if no client manager is connected with the specified client ID.

connectionLost

public void connectionLost(ClientManagerConnection clientManagerConnection)
Indicates that the connection to the provided client manager has been lost and that it should be removed from the list of available client managers.

Parameters:
clientManagerConnection - The client manager to which the connection was lost.

clientConnectionLost

public void clientConnectionLost(ClientConnection clientConnection)
Indicates that the specified client has disconnected from the SLAMD server and that the client managers should be polled to determine if that client might have been associated with a client manager. If so, then the associated client manager will be updated to reflect the lost connection.

Parameters:
clientConnection - The client connection that has disconnected from the SLAMD server.

getMaxResponseWaitTime

public int getMaxResponseWaitTime()
Retrieves the maximum length of time in seconds that the SLAMD server will wait for a response to a request issued to a client manager.

Returns:
The maximum length of time in seconds that the SLAMD server will wait for a response to a request issued to a client manager.

getSubscriberName

public java.lang.String getSubscriberName()
Retrieves the name that the client manager listener uses to subscribe to the configuration handler in order to be notified of configuration changes.

Specified by:
getSubscriberName in interface ConfigSubscriber
Returns:
The name that the client manager listener uses to subscribe to the configuration handler in order to be notified of configuration changes.

getSubscriberParameters

public ParameterList getSubscriberParameters()
Retrieves the set of configuration parameters associated with this configuration subscriber.

Specified by:
getSubscriberParameters in interface ConfigSubscriber
Returns:
The set of configuration parameters associated with this configuration subscriber.

refreshSubscriberConfiguration

public void refreshSubscriberConfiguration()
                                    throws SLAMDServerException
Re-reads all configuration information used by the client listener manager. In this case, only the maximum wait time will be read because the port number is not dynamically reconfigurable.

Specified by:
refreshSubscriberConfiguration in interface ConfigSubscriber
Throws:
SLAMDServerException - If there is a problem reading or applying the changes.

refreshSubscriberConfiguration

public void refreshSubscriberConfiguration(java.lang.String parameterName)
                                    throws SLAMDServerException
Re-reads the configuration for the specified parameter if the parameter is applicable to the client manager listener. In this case, only the maximum wait time will be read because the port number is not dynamically reconfigurable.

Specified by:
refreshSubscriberConfiguration in interface ConfigSubscriber
Parameters:
parameterName - The name of the parameter for which to reread the configuration.
Throws:
SLAMDServerException - If there is a problem reading or applying the specified change.