com.sun.jaw.impl.adaptor.generic
Class AdaptorServer

java.lang.Object
  |
  +--com.sun.jaw.impl.adaptor.generic.AdaptorServer
Direct Known Subclasses:
AdaptorServerImpl, AdaptorServerImpl, AdaptorServerImpl, AdaptorServerImpl, AdaptorServerImpl

public abstract class AdaptorServer
extends java.lang.Object
implements java.lang.Runnable, java.io.Serializable, ActivatableIf

The AdaptorServer class defines generic behaviour for the server part of an adaptor. Most adaptors extend AdaptorServer and inherit this behaviour. Adaptors that do not fit this model do not extend AdaptorServer.

An AdaptorServer is an active object, it listens for client requests and processes them in its own thread. When necessary, an AdaptorServer creates other threads to process multiple requests concurrently.

An AdaptorServer object can be stopped by calling the performStop method. When it is stopped, the AdaptorServer no longer listens to client requests and no longer holds any thread or communication resources. It can be started again by calling the performStart method.

An AdaptorServer has a state property which reflects its activity.

AdaptorServer State
stopped OFFLINE
starting STARTING
running ONLINE
stopping STOPPING

The STARTING state marks the transition from OFFLINE to ONLINE.

The STOPPING state marks the transition from ONLINE to OFFLINE. This occurs when the AdaptorServer is finishing or interrupting active requests.

An AdaptorServer may serve several clients concurrently. The number of concurrent clients can be limited using the property maxActiveClientCount. The default value of this property is defined by the subclasses.

When an AdaptorServer is registered in the framework, it is started automatically. When it is unregistered from the framework it is stopped automatically.

See Also:
Serialized Form

Field Summary
protected  Framework cmf
          The core management framework to register the adaptor server with.
protected  int maxActiveClientCount
          The maximum number of clients that the adaptor server can process concurrently.
protected  ObjectName objectName
          The object name of the adaptor server.
static int OFFLINE
          Represents an OFFLINE state.
static int ONLINE
          Represents an ONLINE state.
protected  int port
          The Port number used by the adaptor server.
static int STARTING
          Represents a STARTING state.
protected  int state
          The state of the adaptor server.
static int STOPPING
          Represents a STOPPING state.
 
Constructor Summary
AdaptorServer()
          Instantiates an AdaptorServer.
 
Method Summary
 void addAdaptorListener(AdaptorListener listener)
          Registers a state change listener.
 void deleteCmf()
          Stops the adaptor server after deregistration if this adaptor is ONLINE.
 java.lang.Integer getActiveClientCount()
          Gets the number of clients currently being processed by this AdaptorServer.
 java.lang.Integer getMaxActiveClientCount()
          Gets the maximum number of clients that this AdaptorServer can process concurrently.
 java.lang.Integer getPort()
          Gets the port number used by this AdaptorServer.
abstract  java.lang.String getProtocol()
          Gets the protocol being used by this AdaptorServer.
 java.lang.Integer getServedClientCount()
          Gets the number of clients that have been processed by this AdaptorServer since its creation.
 java.lang.Integer getState()
          Gets the state of this AdaptorServer as an integer.
 java.lang.String getStateString()
          Gets the state of this AdaptorServer as a string.
 void initCmf(Framework f, ObjectName name, boolean db, ModificationList list)
          Starts the adaptor server after registration if this adaptor is OFFLINE.
 boolean isActive()
          Tests if the AdaptorServer is active.
 void performStart()
          Starts this AdaptorServer.
 void performStop()
          Stops this AdaptorServer.
 boolean performWaitState(int s, long timeOut)
          Waits to be notified of a change in this object.
 void removeAdaptorListener(AdaptorListener listener)
          Unregisters a state change listener.
 void setMaxActiveClientCount(java.lang.Integer c)
          Sets the maximum number of clients this AdaptorServer can process concurrently.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ONLINE

public static final int ONLINE
Represents an ONLINE state.

OFFLINE

public static final int OFFLINE
Represents an OFFLINE state.

STOPPING

public static final int STOPPING
Represents a STOPPING state.

STARTING

public static final int STARTING
Represents a STARTING state.

state

protected transient int state
The state of the adaptor server.

objectName

protected ObjectName objectName
The object name of the adaptor server.

cmf

protected Framework cmf
The core management framework to register the adaptor server with.

maxActiveClientCount

protected int maxActiveClientCount
The maximum number of clients that the adaptor server can process concurrently.

port

protected int port
The Port number used by the adaptor server.
Constructor Detail

AdaptorServer

public AdaptorServer()
Instantiates an AdaptorServer.
Method Detail

performStart

public void performStart()
Starts this AdaptorServer.

Has no effect if this AdaptorServer is ONLINE or STOPPING.

Specified by:
performStart in interface ActivatableIf

performStop

public void performStop()
Stops this AdaptorServer.

Has no effect if this AdaptorServer is OFFLINE or STOPPING.

Specified by:
performStop in interface ActivatableIf

isActive

public boolean isActive()
Tests if the AdaptorServer is active.
Specified by:
isActive in interface ActivatableIf
Returns:
True if adaptor is active; false otherwise.

performWaitState

public boolean performWaitState(int s,
                                long timeOut)
Waits to be notified of a change in this object. It waits until either of the following two conditions has occurred:

The method returns immediately is the timeOut argument is negative. And if timeOut argument equals 0 (zero), it waits only until another thread notifies a new state that is the same as s argument.

Parameters:
s - The state to wait.
timeOut - The maximum time to wait in milliseconds.
Returns:
True if the state is the same as the s argument; false otherwise.

getState

public java.lang.Integer getState()
Gets the state of this AdaptorServer as an integer.
Returns:
ONLINE, OFFLINE or STOPPING.

getStateString

public java.lang.String getStateString()
Gets the state of this AdaptorServer as a string.
Returns:
One of the strings "ONLINE", "OFFLINE" or "STOPPING".

getPort

public java.lang.Integer getPort()
Gets the port number used by this AdaptorServer.
Returns:
The port number used by this AdaptorServer.

getServedClientCount

public java.lang.Integer getServedClientCount()
Gets the number of clients that have been processed by this AdaptorServer since its creation.
Returns:
The number of clients handled by this AdaptorServer since its creation. This counter is not reset by the performStop method.

getActiveClientCount

public java.lang.Integer getActiveClientCount()
Gets the number of clients currently being processed by this AdaptorServer.
Returns:
The number of clients currently being processed by this AdaptorServer.

getMaxActiveClientCount

public java.lang.Integer getMaxActiveClientCount()
Gets the maximum number of clients that this AdaptorServer can process concurrently.
Returns:
The maximum number of clients that this AdaptorServer can process concurrently.

setMaxActiveClientCount

public void setMaxActiveClientCount(java.lang.Integer c)
Sets the maximum number of clients this AdaptorServer can process concurrently.
Parameters:
c - The number of clients.

initCmf

public void initCmf(Framework f,
                    ObjectName name,
                    boolean db,
                    ModificationList list)
             throws InstanceAlreadyExistException
Starts the adaptor server after registration if this adaptor is OFFLINE. This method is not intent to be called directly by the user.

Parameters:
f - The core management framework to register the service with.
name - The object name.
db - Indicates if persistent storage is required.
list - The modification list to use for setting up parameters.
Throws:
InstanceAlreadyExistException - The m-bean is already registered in the repository.

deleteCmf

public void deleteCmf()
               throws InstanceNotFoundException,
                      java.lang.reflect.InvocationTargetException
Stops the adaptor server after deregistration if this adaptor is ONLINE. This method is not intent to be called directly by the user.

Throws:
InstanceNotFoundException - The m-bean does not exist in the repository.
java.lang.reflect.InvocationTargetException - It is a checked exception that wraps an exception thrown by an invoked method or constructor.

getProtocol

public abstract java.lang.String getProtocol()
Gets the protocol being used by this AdaptorServer.
Returns:
The protocol as a string.

addAdaptorListener

public void addAdaptorListener(AdaptorListener listener)
Registers a state change listener.
Parameters:
listener - The adaptor listener to add.

removeAdaptorListener

public void removeAdaptorListener(AdaptorListener listener)
Unregisters a state change listener.
Parameters:
listener - The adaptor listener to remove.