java.lang.Object | |
↳ | com.sun.jmx.snmp.daemon.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.
This API is a Sun Microsystems internal API and is subject to change without notice.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | OFFLINE | Represents an OFFLINE state. |
|||||||||
int | ONLINE | Represents an ONLINE state. |
|||||||||
int | SNMP_TYPE | Indicates that it is an SNMP connector type. | |||||||||
int | STARTING | Represents a STARTING state. |
|||||||||
int | STOPPING | Represents a STOPPING state. |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Instantiates a
CommunicatorServer . |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Adds a listener for the notifications emitted by this
CommunicatorServer.
| |||||||||||
Gets the host name used by this
CommunicatorServer . | |||||||||||
Get the
MBeanServer object to which incoming requests are
sent. | |||||||||||
Returns an array of MBeanNotificationInfo objects describing
the notification types sent by this CommunicatorServer.
| |||||||||||
Gets the port number used by this
CommunicatorServer . | |||||||||||
Gets the protocol being used by this
CommunicatorServer . | |||||||||||
Gets the state of this
CommunicatorServer as an integer. | |||||||||||
Gets the state of this
CommunicatorServer as a string. | |||||||||||
Tests whether the
CommunicatorServer is active. | |||||||||||
Do nothing.
| |||||||||||
Allows the MBean to perform any operations needed after having been
registered in the MBean server or after the registration has failed.
| |||||||||||
Stop the connector.
| |||||||||||
Preregister method of connector.
| |||||||||||
Removes the specified listener from this CommunicatorServer.
| |||||||||||
For SNMP Runtime internal use only.
| |||||||||||
Set the
MBeanServer object to which incoming
requests are sent. | |||||||||||
Sets the port number used by this
CommunicatorServer . | |||||||||||
Starts this
CommunicatorServer . | |||||||||||
Starts this
CommunicatorServer . | |||||||||||
Stops this
CommunicatorServer . | |||||||||||
Waits until either the State attribute of this MBean equals the specified wantedState parameter, or the specified timeOut has elapsed. |
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
doProcess() is called after doReceive() :
it should process the requests of the incoming client. | |||||||||||
doReceive() should block until a client is available. | |||||||||||
doUnbind() is called whenever the connector goes
OFFLINE , except if doBind() has thrown an
exception. | |||||||||||
The delay, in ms, during which the communicator server will sleep before
attempting to bind again.
| |||||||||||
The number of times the communicator server will attempt
to bind before giving up.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() |
Represents an OFFLINE
state.
Represents an ONLINE
state.
Indicates that it is an SNMP connector type.
Represents a STARTING
state.
Represents a STOPPING
state.
Instantiates a CommunicatorServer
.
connectorType | Indicates the connector type. Possible values are: SNMP_TYPE. |
---|
This connector type is not correct. | |
IllegalArgumentException |
Adds a listener for the notifications emitted by this
CommunicatorServer.
There is only one type of notifications sent by the CommunicatorServer:
they are AttributeChangeNotification
,
sent when the State attribute of this CommunicatorServer
changes.
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. |
---|
Gets the host name used by this CommunicatorServer
.
CommunicatorServer
.
Get the 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.
Returns an array of MBeanNotificationInfo objects describing
the notification types sent by this CommunicatorServer.
There is only one type of notifications sent by the CommunicatorServer:
it is AttributeChangeNotification
,
sent when the State attribute of this CommunicatorServer
changes.
Gets the port number used by this CommunicatorServer
.
CommunicatorServer
.
Gets the protocol being used by this CommunicatorServer
.
Gets the state of this CommunicatorServer
as an integer.
ONLINE
, OFFLINE
,
STARTING
or STOPPING
.
Gets the state of this CommunicatorServer
as a string.
Tests whether the CommunicatorServer
is active.
ONLINE
; false otherwise.
Do nothing.
Allows the MBean to perform any operations needed after having been registered in the MBean server or after the registration has failed.
registrationDone | Indicates whether or not the MBean has been
successfully registered in the MBeanServer .
The value false means that the registration phase has failed.
|
---|
Stop the connector.
This exception should be caught by
the MBeanServer and re-thrown
as an MBeanRegistrationException .
|
|
Exception |
Preregister method of connector.
server | The MBeanServer in which the MBean will
be registered. |
---|---|
name | The object name of the MBean. |
This exception should be caught by
the MBeanServer and re-thrown
as an MBeanRegistrationException .
|
|
Exception |
Removes the specified listener from this CommunicatorServer. Note that if the listener has been registered with different handback objects or notification filters, all entries corresponding to the listener will be removed.
listener | The listener object to be removed. |
---|
ListenerNotFoundException | The listener is not registered. |
---|
For SNMP Runtime internal use only.
The run
method executed by this connector's main thread.
Set the 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. |
Sets the port number used by this CommunicatorServer
.
port | The port number used by this
CommunicatorServer . |
---|
IllegalStateException | This method has been invoked while the communicator was ONLINE or STARTING. |
---|
Starts this CommunicatorServer
.
Has no effect if this CommunicatorServer
is
ONLINE
or STOPPING
.
Starts this CommunicatorServer
.
Has no effect if this CommunicatorServer
is
ONLINE
or STOPPING
.
timeout | Time in ms to wait for the connector to start.
If timeout is positive, wait for at most
the specified time. An infinite timeout can be specified
by passing a timeout value equals
Long.MAX_VALUE . In that case the method
will wait until the connector starts or fails to start.
If timeout is negative or zero, returns as soon as possible
without waiting. |
---|
CommunicationException | if the connectors fails to start. |
---|---|
InterruptedException | if the thread is interrupted or the timeout expires. |
Stops this CommunicatorServer
.
Has no effect if this CommunicatorServer
is
OFFLINE
or STOPPING
.
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 untill 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).wantedState | The value of this MBean's State attribute to wait
for. wantedState can be one of:
|
---|---|
timeOut | The maximum time to wait for, in milliseconds, if positive. Infinite time out if 0, or no waiting at all if negative. |
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.
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.
doUnbind()
is called whenever the connector goes
OFFLINE
, except if doBind()
has thrown an
exception.
The delay, in ms, during which the communicator server will sleep before attempting to bind again.
The number of times the communicator server will attempt to bind before giving up.