com.ibm.websphere.samples.asynchbeans.wstrader.tickstream
Class StreamClientState

java.lang.Object
  extended by com.ibm.websphere.samples.asynchbeans.wstrader.tickstream.StreamClientState
All Implemented Interfaces:
com.ibm.websphere.asynchbeans.AsynchScopeEvents, com.ibm.websphere.asynchbeans.EventSourceEvents, com.ibm.websphere.asynchbeans.SubsystemMonitorEvents

public class StreamClientState
extends java.lang.Object
implements com.ibm.websphere.asynchbeans.AsynchScopeEvents, com.ibm.websphere.asynchbeans.SubsystemMonitorEvents

Contains all logic for maintaining the state of a client (login id). Each ClientState has an associated Asynch Scope which is a child of the main Application Asynch Scope or StreamApplicationState.


Field Summary
static java.lang.String SSM_CLIENT
           
 
Method Summary
 void destroy()
          Destroy this instance.
 void destroyed(com.ibm.websphere.asynchbeans.AsynchScope scope)
           
 void destroyed(com.ibm.websphere.asynchbeans.SubsystemMonitor ssm)
           
 StreamListener findStreamer(java.lang.String name)
          Find a streamer by it's name
 StreamApplicationState getApplicationState()
          Gets the appState.
 com.ibm.websphere.asynchbeans.AsynchScope getClientAsynchScope()
          Get the client Asynch Scope that is associated with this Client State
 java.lang.String getClientID()
          Get the ID of the client that is associated with this Client State
static StreamClientState getClientState(StreamApplicationState appState, java.lang.String clientID, boolean createFlag)
          Create a StreamClientState instance for a specific client id and application state.
 void handleClientPing()
          Handles pings from the Ping servlet for a given client
 void listenerCountChanged(com.ibm.websphere.asynchbeans.EventSource es, int oldCount, int newCount)
           
 void listenerExceptionThrown(com.ibm.websphere.asynchbeans.EventSource es, java.lang.Object listener, java.lang.String methodName, java.lang.Throwable exception)
           
 void registerStreamer(StreamListener streamer)
          A client can have multiple streaming connections concurrently.
 void setApplicationState(StreamApplicationState appState)
          Sets the appState.
 void subsystemIsDead(com.ibm.websphere.asynchbeans.SubsystemMonitor ssm)
           
 void subsystemIsFresh(com.ibm.websphere.asynchbeans.SubsystemMonitor ssm)
           
 void subsystemIsStale(com.ibm.websphere.asynchbeans.SubsystemMonitor ssm)
           
 java.lang.String toString()
           
 void unexpectedException(com.ibm.websphere.asynchbeans.EventSource es, java.lang.Object runnable, java.lang.Throwable exception)
           
 void unregisterStreamer(StreamListener streamer)
          Unregister a streamer from the client state.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SSM_CLIENT

public static final java.lang.String SSM_CLIENT
See Also:
Constant Field Values
Method Detail

getClientState

public static StreamClientState getClientState(StreamApplicationState appState,
                                               java.lang.String clientID,
                                               boolean createFlag)
Create a StreamClientState instance for a specific client id and application state.

Parameters:
appState - the associated StreamApplicationState
clientID - the client id to associate with the StreamClientState.
createFlag - when true, create a new StreamClientState when one doesn't already exist.

destroy

public void destroy()
Destroy this instance.


destroyed

public void destroyed(com.ibm.websphere.asynchbeans.AsynchScope scope)
Specified by:
destroyed in interface com.ibm.websphere.asynchbeans.AsynchScopeEvents
See Also:
AsynchScopeEvents.destroyed(AsynchScope)

destroyed

public void destroyed(com.ibm.websphere.asynchbeans.SubsystemMonitor ssm)
Specified by:
destroyed in interface com.ibm.websphere.asynchbeans.SubsystemMonitorEvents
See Also:
SubsystemMonitorEvents.destroyed(SubsystemMonitor)

subsystemIsDead

public void subsystemIsDead(com.ibm.websphere.asynchbeans.SubsystemMonitor ssm)
Specified by:
subsystemIsDead in interface com.ibm.websphere.asynchbeans.SubsystemMonitorEvents
See Also:
SubsystemMonitorEvents.subsystemIsDead(SubsystemMonitor)

subsystemIsFresh

public void subsystemIsFresh(com.ibm.websphere.asynchbeans.SubsystemMonitor ssm)
Specified by:
subsystemIsFresh in interface com.ibm.websphere.asynchbeans.SubsystemMonitorEvents
See Also:
SubsystemMonitorEvents.subsystemIsFresh(SubsystemMonitor)

subsystemIsStale

public void subsystemIsStale(com.ibm.websphere.asynchbeans.SubsystemMonitor ssm)
Specified by:
subsystemIsStale in interface com.ibm.websphere.asynchbeans.SubsystemMonitorEvents
See Also:
SubsystemMonitorEvents.subsystemIsStale(SubsystemMonitor)

listenerCountChanged

public void listenerCountChanged(com.ibm.websphere.asynchbeans.EventSource es,
                                 int oldCount,
                                 int newCount)
Specified by:
listenerCountChanged in interface com.ibm.websphere.asynchbeans.EventSourceEvents
See Also:
EventSourceEvents.listenerCountChanged(EventSource, int, int)

listenerExceptionThrown

public void listenerExceptionThrown(com.ibm.websphere.asynchbeans.EventSource es,
                                    java.lang.Object listener,
                                    java.lang.String methodName,
                                    java.lang.Throwable exception)
Specified by:
listenerExceptionThrown in interface com.ibm.websphere.asynchbeans.EventSourceEvents
See Also:
EventSourceEvents.listenerExceptionThrown(EventSource, Object, String, Throwable)

unexpectedException

public void unexpectedException(com.ibm.websphere.asynchbeans.EventSource es,
                                java.lang.Object runnable,
                                java.lang.Throwable exception)
Specified by:
unexpectedException in interface com.ibm.websphere.asynchbeans.EventSourceEvents
See Also:
EventSourceEvents.unexpectedException(EventSource, Object, Throwable)

handleClientPing

public void handleClientPing()
Handles pings from the Ping servlet for a given client


getClientID

public java.lang.String getClientID()
Get the ID of the client that is associated with this Client State


getClientAsynchScope

public com.ibm.websphere.asynchbeans.AsynchScope getClientAsynchScope()
Get the client Asynch Scope that is associated with this Client State


getApplicationState

public StreamApplicationState getApplicationState()
Gets the appState.

Returns:
Returns a StreamApplicationState

setApplicationState

public void setApplicationState(StreamApplicationState appState)
Sets the appState.

Parameters:
appState - The appState to set

registerStreamer

public void registerStreamer(StreamListener streamer)
A client can have multiple streaming connections concurrently. Each one is named uniquely and registered here so that it can be found easily using it's name.

Parameters:
streamer - The streamer to register.

unregisterStreamer

public void unregisterStreamer(StreamListener streamer)
Unregister a streamer from the client state.

Parameters:
streamer - The streamer to unregister.

findStreamer

public StreamListener findStreamer(java.lang.String name)
Find a streamer by it's name

Parameters:
name - The streamer name.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object