|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sun.jdmk.comm.CommunicatorServer
public abstract class 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
attribute
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.
When the value of the State
attribute changes the
CommunicatorServer
sends a
AttributeChangeNotification
to the
registered listeners, if any.
Field Summary | |
---|---|
static int |
HTML_TYPE
Indicates that it is an HTML connector type. |
static int |
HTTP_TYPE
Indicates that it is an HTTP connector type. |
static int |
HTTPS_TYPE
Indicates that it is an HTTPS connector type. |
static int |
OFFLINE
Represents an OFFLINE state. |
static int |
ONLINE
Represents an ONLINE state. |
static int |
RMI_TYPE
Indicates that it is an RMI connector type. |
static int |
SNMP_TYPE
Indicates that it is an SNMP connector type. |
static int |
STARTING
Represents a STARTING state. |
static int |
STOPPING
Represents a STOPPING state. |
Constructor Summary | |
---|---|
CommunicatorServer(int connectorType)
Instantiates a CommunicatorServer . |
Method Summary | |
---|---|
void |
addNotificationListener(NotificationListener listener,
NotificationFilter filter,
Object handback)
Adds a listener for the notifications emitted by this CommunicatorServer. |
protected abstract void |
doBind()
|
protected abstract void |
doError(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. |
String |
getHost()
Gets the host name used by this CommunicatorServer . |
MBeanServer |
getMBeanServer()
Get the MBeanServer object to which incoming requests are
sent. |
MBeanNotificationInfo[] |
getNotificationInfo()
Returns an array of MBeanNotificationInfo objects describing the notification types sent by this CommunicatorServer. |
int |
getPort()
Gets the port number used by this CommunicatorServer . |
abstract String |
getProtocol()
Gets the protocol being used by this CommunicatorServer . |
int |
getState()
Gets the state of this CommunicatorServer as an integer. |
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(Boolean registrationDone)
|
void |
preDeregister()
Stop the connector. |
ObjectName |
preRegister(MBeanServer server,
ObjectName name)
Preregister method of connector. |
void |
removeNotificationListener(NotificationListener listener)
Removes the specified listener from this CommunicatorServer. |
void |
run()
For Java DMK internal use only. |
void |
setMBeanServer(MBeanServer newMBS)
Set the MBeanServer object to which incoming
requests are sent. |
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 wantedState,
long timeout)
Waits until either the State attribute of this MBean equals the specified wantedState parameter, or the specified timeout has elapsed. |
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
Constructor Detail |
---|
public CommunicatorServer(int connectorType) throws IllegalArgumentException
CommunicatorServer
.
connectorType
- Indicates the connector type. Possible values are:
RMI_TYPE, HTTP_TYPE, HTML_TYPE, SNMP_TYPE, HTTPS_TYPE.
java.lang.IllegalArgumentException
- This connector type is not correct.
IllegalArgumentException
Method Detail |
---|
public void start()
CommunicatorServer
.
Has no effect if this CommunicatorServer
is
ONLINE
or STOPPING
.
start
in interface CommunicatorServerMBean
public void stop()
CommunicatorServer
.
Has no effect if this CommunicatorServer
is
OFFLINE
or STOPPING
.
stop
in interface CommunicatorServerMBean
public boolean isActive()
CommunicatorServer
is active.
isActive
in interface CommunicatorServerMBean
ONLINE
; false otherwise.public boolean waitState(int wantedState, long timeout)
Waits until either the State attribute of this MBean equals the
specified wantedState parameter, or the specified
timeout has elapsed. The method waitState
returns with a boolean value indicating whether the specified
wantedState parameter equals the value of this MBean's
State attribute at the time the method terminates.
Two special cases for the timeout parameter value are:
waitState
returns immediately (i.e. does not wait at all),waitState
waits until the value of this MBean's State attribute
is the same as the wantedState parameter (i.e. will
wait indefinitely if this condition is never met).
waitState
in interface CommunicatorServerMBean
wantedState
- The value of this MBean's State attribute to wait
for. wantedState can be one of:
CommunicatorServer.OFFLINE
,
CommunicatorServer.ONLINE
,
CommunicatorServer.STARTING
,
CommunicatorServer.STOPPING
.timeout
- The maximum time to wait for, in milliseconds, if
positive. Infinite time out if 0, or no waiting at all if
negative.
true
if the value of this MBean's State attribute
is the same as the wantedState parameter;
false
otherwise.public int getState()
CommunicatorServer
as an integer.
getState
in interface CommunicatorServerMBean
ONLINE
, OFFLINE
,
STARTING
or STOPPING
.public String getStateString()
CommunicatorServer
as a string.
getStateString
in interface CommunicatorServerMBean
public String getHost()
CommunicatorServer
.
getHost
in interface CommunicatorServerMBean
CommunicatorServer
.public int getPort()
CommunicatorServer
.
getPort
in interface CommunicatorServerMBean
CommunicatorServer
.public void setPort(int port) throws IllegalStateException
CommunicatorServer
.
setPort
in interface CommunicatorServerMBean
port
- The port number used by this CommunicatorServer
.
IllegalStateException
- This method has been invoked
while the communicator was ONLINE or STARTING.public abstract String getProtocol()
CommunicatorServer
.
getProtocol
in interface CommunicatorServerMBean
public void run()
The run
method executed by this connector's main thread.
run
in interface Runnable
protected abstract void doError(Exception e) throws CommunicationException
CommunicationException
protected abstract void doBind() throws CommunicationException, InterruptedException
CommunicationException
InterruptedException
protected abstract void doReceive() throws CommunicationException, 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.
CommunicationException
InterruptedException
protected abstract void doProcess() throws CommunicationException, 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.
CommunicationException
InterruptedException
protected abstract void doUnbind() throws CommunicationException, InterruptedException
doUnbind()
is called whenever the connector goes
OFFLINE
, except if doBind()
has
thrown an exception.
CommunicationException
InterruptedException
public MBeanServer getMBeanServer()
MBeanServer
object to which incoming requests are
sent. This is either the MBean server in which this connector is
registered, or an MBeanServerForwarder
leading to that
server.
public void setMBeanServer(MBeanServer newMBS) throws IllegalArgumentException, IllegalStateException
MBeanServer
object to which incoming
requests are sent. This must be either the MBean server in
which this connector is registered, or an
MBeanServerForwarder
leading to that server. An
MBeanServerForwarder
mbsf
leads to an
MBean server mbs
if
mbsf.getMBeanServer()
is either mbs
or an MBeanServerForwarder
leading to
mbs
.
IllegalArgumentException
- if newMBS
is neither
the MBean server in which this connector is registered nor an
MBeanServerForwarder
leading to that server.
IllegalStateException
- This method has been invoked
while the communicator was ONLINE or STARTING.public void addNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) throws IllegalArgumentException
AttributeChangeNotification
,
sent when the State attribute of this CommunicatorServer
changes.
addNotificationListener
in interface NotificationBroadcaster
listener
- The listener object which will handle the emitted
notifications.filter
- The filter object. If filter is null, no filtering will
be performed before handling notifications.handback
- An object which will be sent back unchanged to the
listener when a notification is emitted.
IllegalArgumentException
- Listener parameter is null.public void removeNotificationListener(NotificationListener listener) throws ListenerNotFoundException
removeNotificationListener
in interface NotificationBroadcaster
listener
- The listener object to be removed.
ListenerNotFoundException
- The listener is not registered.public MBeanNotificationInfo[] getNotificationInfo()
AttributeChangeNotification
,
sent when the State attribute of this CommunicatorServer
changes.
getNotificationInfo
in interface NotificationBroadcaster
public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception
preRegister
in interface MBeanRegistration
server
- The MBeanServer
in which the MBean will be
registered.name
- The object name of the MBean.
Exception
- This exception should be caught by
the MBeanServer
and re-thrown
as an MBeanRegistrationException
.public void postRegister(Boolean registrationDone)
postRegister
in interface MBeanRegistration
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 Exception
preDeregister
in interface MBeanRegistration
Exception
- This exception should be caught by
the MBeanServer
and re-thrown
as an MBeanRegistrationException
.public void postDeregister()
postDeregister
in interface MBeanRegistration
|
Open Source build 02 opendmk-1.0-b02 2007.10.01_19:17:46_MEST |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |