|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.sun.jdmk.comm.CommunicatorServer
The CommunicatorServer
class defines generic behaviour for the server
part of a connector or an adaptor. Most connectors or adaptors extend CommunicatorServer
and inherit this behaviour. Connectors or adaptors that do not fit into this model do not extend
CommunicatorServer
.
An CommunicatorServer
is an active object, it listens for client requests
and processes them in its own thread. When necessary, a CommunicatorServer
creates other threads to process multiple requests concurrently.
A CommunicatorServer
object can be stopped by calling the stop
method. When it is stopped, the CommunicatorServer
no longer listens to client
requests and no longer holds any thread or communication resources.
It can be started again by calling the start
method.
A CommunicatorServer
has a state
property which reflects its
activity.
CommunicatorServer | 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 CommunicatorServer
is
finishing or interrupting active requests.
A CommunicatorServer
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 a CommunicatorServer
is unregistered from the MBeanServer,
it is stopped automatically.
Field Summary | |
protected java.lang.String |
dbgTag
|
protected java.lang.String |
host
The host name used by this CommunicatorServer. |
static int |
HTML_TYPE
Indicates that it is a HTML connector type. |
static int |
HTTP_TYPE
Indicates that it is a HTTP connector type. |
static int |
HTTPS_TYPE
Indicates that it is a HTTPS connector type. |
protected int |
infoType
|
protected int |
maxActiveClientCount
The maximum number of clients that the CommunicatorServer can process concurrently. |
protected MBeanServer |
mbs
The MBeanServer where this CommunicatorServer is to be registered with. |
protected ObjectName |
objectName
The object name of the connector server. |
static int |
OFFLINE
Represents an OFFLINE state. |
static int |
ONLINE
Represents an ONLINE state. |
protected int |
port
The port number used by this CommunicatorServer. |
static int |
RMI_TYPE
Indicates that it is a RMI connector type. |
protected int |
servedClientCount
|
static int |
SNMP_TYPE
Indicates that it is a SNMP connector type. |
static int |
STARTING
Represents a STARTING state. |
protected int |
state
The state of the connector server. |
static int |
STOPPING
Represents a STOPPING state. |
Constructor Summary | |
CommunicatorServer(int connectorType)
Instantiates a CommunicatorServer . |
Method Summary | |
protected void |
changeState(int s)
For JDMK internal use only |
protected void |
debug(java.lang.String func,
java.lang.String info)
|
protected void |
debug(java.lang.String clz,
java.lang.String func,
java.lang.String info)
|
protected void |
debug(java.lang.String clz,
java.lang.String func,
java.lang.Throwable exception)
|
protected void |
debug(java.lang.String func,
java.lang.Throwable exception)
|
protected abstract void |
doBind()
|
protected abstract void |
doProcess()
doProcess() is called after doReceive() : it should process the requests
of the incoming client. |
protected abstract void |
doReceive()
doReceive() should block until a client is available. |
protected abstract void |
doUnbind()
doUnbind() is called whenever the connector goes OFFLINE except if
doBind() has thrown an exception. |
int |
getActiveClientCount()
Gets the number of clients currently being processed by this CommunicatorServer . |
java.lang.String |
getHost()
Gets the host name used by this CommunicatorServer . |
int |
getMaxActiveClientCount()
Gets the maximum number of clients that this CommunicatorServer can
process concurrently. |
protected MBeanServer |
getMBeanServer()
For JDMK internal use only |
protected ObjectName |
getObjectName()
For JDMK internal use only |
int |
getPort()
Gets the port number used by this CommunicatorServer . |
abstract java.lang.String |
getProtocol()
Gets the protocol being used by this CommunicatorServer . |
int |
getServedClientCount()
Gets the number of clients that have been processed by this CommunicatorServer
since its creation. |
int |
getState()
Gets the state of this CommunicatorServer as an integer. |
java.lang.String |
getStateString()
Gets the state of this CommunicatorServer as a string. |
boolean |
isActive()
Tests if the CommunicatorServer is active. |
protected boolean |
isDebugOn()
|
protected boolean |
isTraceOn()
|
protected java.lang.String |
makeDebugTag()
Returns the string used in debug traces. |
protected java.lang.String |
makeThreadName()
Returns the string used to name the connector thread. |
void |
postDeregister()
Do nothing. |
void |
postRegister(java.lang.Boolean registrationDone)
Do nothing |
void |
preDeregister()
Stop the connector |
ObjectName |
preRegister(MBeanServer server,
ObjectName name)
Preregister method of connector. |
void |
run()
For Java DMK internal use only. |
void |
setMaxActiveClientCount(int c)
Sets the maximum number of clients this CommunicatorServer can
process concurrently. |
void |
setPort(int p)
Sets the port number used by this CommunicatorServer . |
void |
start()
Starts this CommunicatorServer . |
void |
stop()
Stops this CommunicatorServer . |
protected void |
trace(java.lang.String func,
java.lang.String info)
|
protected void |
trace(java.lang.String clz,
java.lang.String func,
java.lang.String info)
|
boolean |
waitState(int s,
long timeOut)
Waits to be notified of a change in this object. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
public static final int ONLINE
ONLINE
state.public static final int OFFLINE
OFFLINE
state.public static final int STOPPING
STOPPING
state.public static final int STARTING
STARTING
state.public static final int RMI_TYPE
public static final int HTTP_TYPE
public static final int HTML_TYPE
public static final int SNMP_TYPE
public static final int HTTPS_TYPE
protected transient int state
protected ObjectName objectName
protected MBeanServer mbs
protected transient java.lang.String dbgTag
protected int maxActiveClientCount
protected transient int servedClientCount
protected java.lang.String host
protected int port
protected int infoType
Constructor Detail |
public CommunicatorServer(int connectorType) throws java.lang.IllegalArgumentException
CommunicatorServer
.connectorType
- Indicates the connector type. Possible values are:
RMI_TYPE, HTTP_TYPE, HTML_TYPE, SNMP_TYPE and HTTPS_TYPE.Method Detail |
public void start()
CommunicatorServer
.
Has no effect if this CommunicatorServer
is ONLINE
or
STOPPING
.
public void stop()
CommunicatorServer
.
Has no effect if this CommunicatorServer
is OFFLINE
or
STOPPING
.
public boolean isActive()
CommunicatorServer
is active.public boolean waitState(int s, long timeOut)
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.
s
- The state to wait.timeOut
- The maximum time to wait in milliseconds.public int getState()
CommunicatorServer
as an integer.ONLINE
, OFFLINE
, STARTING
or STOPPING
.public java.lang.String getStateString()
CommunicatorServer
as a string.public java.lang.String getHost()
CommunicatorServer
.CommunicatorServer
.public int getPort()
CommunicatorServer
.CommunicatorServer
.public void setPort(int p) throws java.lang.IllegalStateException
CommunicatorServer
.p
- The port number used by this CommunicatorServer
.public abstract java.lang.String getProtocol()
CommunicatorServer
.public int getServedClientCount()
CommunicatorServer
since its creation.CommunicatorServer
since its creation. This counter is not reset by the stop
method.public int getActiveClientCount()
CommunicatorServer
.CommunicatorServer
.public int getMaxActiveClientCount()
CommunicatorServer
can
process concurrently.CommunicatorServer
can
process concurrently.public void setMaxActiveClientCount(int c) throws java.lang.IllegalStateException
CommunicatorServer
can
process concurrently.c
- The number of clients.public void run()
protected abstract void doBind() throws CommunicationException, java.lang.InterruptedException
protected abstract void doReceive() throws CommunicationException, java.lang.InterruptedException
doReceive()
should block until a client is available.
If this method throws an exception, doProcess()
is not called but
doUnbind()
is called then run()
ends up.protected abstract void doProcess() throws CommunicationException, java.lang.InterruptedException
doProcess()
is called after doReceive()
: it should process the requests
of the incoming client.
If it throws an exception, doUnbind()
is called and run()
ends up.protected abstract void doUnbind() throws CommunicationException, java.lang.InterruptedException
doUnbind()
is called whenever the connector goes OFFLINE
except if
doBind()
has thrown an exception.protected ObjectName getObjectName()
protected MBeanServer getMBeanServer()
protected void changeState(int s)
protected java.lang.String makeDebugTag()
protected java.lang.String makeThreadName()
public ObjectName preRegister(MBeanServer server, ObjectName name) throws java.lang.Exception
server
- The MBeanServer in which the MBean will be registered.name
- The object name of the MBean.public void postRegister(java.lang.Boolean registrationDone)
registrationDone
- Indicates whether or not the MBean has been successfully registered in
the MBeanServer. The value false means that either the registration phase
has failed.public void preDeregister() throws java.lang.Exception
public void postDeregister()
protected boolean isTraceOn()
protected void trace(java.lang.String clz, java.lang.String func, java.lang.String info)
protected boolean isDebugOn()
protected void debug(java.lang.String clz, java.lang.String func, java.lang.String info)
protected void debug(java.lang.String clz, java.lang.String func, java.lang.Throwable exception)
protected void trace(java.lang.String func, java.lang.String info)
protected void debug(java.lang.String func, java.lang.String info)
protected void debug(java.lang.String func, java.lang.Throwable exception)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |