|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.sun.jdmk.comm.CommunicatorServer
Defines generic behavior for the server part of a connector or an adaptor.
Most connectors or adaptors extend CommunicatorServer
and inherit this behavior. Connectors or adaptors that do not fit into this model do not extend
CommunicatorServer
.
A 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.
When a CommunicatorServer
is unregistered from the MBeanServer,
it is stopped automatically.
Field Summary | |
static int |
OFFLINE
Represents an OFFLINE state. |
static int |
ONLINE
Represents an ONLINE state. |
static int |
STARTING
Represents a STARTING state. |
static int |
STOPPING
Represents a STOPPING state. |
Constructor Summary | |
CommunicatorServer()
Instantiates a CommunicatorServer . |
Method Summary | |
protected abstract void |
doBind()
|
protected abstract void |
doError(java.lang.Exception e)
|
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. |
java.lang.String |
getHost()
Gets the host name used by this CommunicatorServer . |
int |
getPort()
Gets the port number used by this CommunicatorServer . |
abstract java.lang.String |
getProtocol()
Gets the protocol being used by this CommunicatorServer . |
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 whether the CommunicatorServer is active. |
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 |
setPort(int port)
Sets the port number used by this CommunicatorServer . |
void |
start()
Starts this CommunicatorServer . |
void |
stop()
Stops this CommunicatorServer . |
boolean |
waitState(int state,
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.Constructor Detail |
public CommunicatorServer()
CommunicatorServer
.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 state, long timeOut)
state
argument.
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 state
argument.
state
- The state to wait.timeOut
- The maximum time to wait in milliseconds.state
argument; false otherwise.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 port) throws java.lang.IllegalStateException
CommunicatorServer
.port
- The port number used by this CommunicatorServer
.public abstract java.lang.String getProtocol()
CommunicatorServer
.public void run()
protected abstract void doError(java.lang.Exception e) throws CommunicationException
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()
stops.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()
stops.protected abstract void doUnbind() throws CommunicationException, java.lang.InterruptedException
doUnbind()
is called whenever the connector goes OFFLINE
, except if
doBind()
has thrown an exception.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.MBeanServer
and re-thrown
as an MBeanRegistrationException
.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 the registration phase has failed.public void preDeregister() throws java.lang.Exception
MBeanServer
and re-thrown
as an MBeanRegistrationException
.public void postDeregister()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |