Methods Summary |
---|
protected void | connectionClosed(java.lang.String connectionId, java.lang.String message, java.lang.Object userData)Called by a subclass when a client connection is closed
normally. Removes connectionId from the list returned
by {@link #getConnectionIds()}, then emits a {@link
JMXConnectionNotification} with type {@link
JMXConnectionNotification#CLOSED}.
if (connectionId == null)
throw new NullPointerException("Illegal null argument");
synchronized (connectionIds) {
connectionIds.remove(connectionId);
}
sendNotification(JMXConnectionNotification.CLOSED, connectionId,
message, userData);
|
protected void | connectionFailed(java.lang.String connectionId, java.lang.String message, java.lang.Object userData)Called by a subclass when a client connection fails.
Removes connectionId from the list returned by
{@link #getConnectionIds()}, then emits a {@link
JMXConnectionNotification} with type {@link
JMXConnectionNotification#FAILED}.
if (connectionId == null)
throw new NullPointerException("Illegal null argument");
synchronized (connectionIds) {
connectionIds.remove(connectionId);
}
sendNotification(JMXConnectionNotification.FAILED, connectionId,
message, userData);
|
protected void | connectionOpened(java.lang.String connectionId, java.lang.String message, java.lang.Object userData)Called by a subclass when a new client connection is opened.
Adds connectionId to the list returned by {@link
#getConnectionIds()}, then emits a {@link
JMXConnectionNotification} with type {@link
JMXConnectionNotification#OPENED}.
if (connectionId == null)
throw new NullPointerException("Illegal null argument");
synchronized (connectionIds) {
connectionIds.add(connectionId);
}
sendNotification(JMXConnectionNotification.OPENED, connectionId,
message, userData);
|
public java.lang.String[] | getConnectionIds()
synchronized (connectionIds) {
return (String[])
connectionIds.toArray(new String[connectionIds.size()]);
}
|
public synchronized javax.management.MBeanServer | getMBeanServer()Returns the MBean server that this connector server is
attached to.
return mbeanServer;
|
public javax.management.MBeanNotificationInfo[] | getNotificationInfo()Returns an array indicating the notifications that this MBean
sends. The implementation in JMXConnectorServer
returns an array with one element, indicating that it can emit
notifications of class {@link JMXConnectionNotification} with
the types defined in that class. A subclass that can emit other
notifications should return an array that contains this element
plus descriptions of the other notifications.
final String[] types = {
JMXConnectionNotification.OPENED,
JMXConnectionNotification.CLOSED,
JMXConnectionNotification.FAILED,
};
final String className = JMXConnectionNotification.class.getName();
final String description =
"A client connection has been opened or closed";
return new MBeanNotificationInfo[] {
new MBeanNotificationInfo(types, className, description),
};
|
private synchronized java.lang.Object | getNotificationSource()
if (myName != null)
return myName;
else
return this;
|
private static long | nextSequenceNumber()
synchronized (sequenceNumberLock) {
return sequenceNumber++;
}
|
public void | postDeregister()
myName = null;
|
public void | postRegister(java.lang.Boolean registrationDone)
// do nothing
|
public synchronized void | preDeregister()Called by an MBean server when this connector server is
unregistered from that MBean server. If this connector server
was attached to that MBean server by being registered in it,
and if the connector server is still active,
then unregistering it will call the {@link #stop stop} method.
If the stop method throws an exception, the
unregistration attempt will fail. It is recommended to call
the stop method explicitly before unregistering
the MBean.
if (myName != null && isActive()) {
stop();
myName = null; // just in case stop is buggy and doesn't stop
}
|
public synchronized javax.management.ObjectName | preRegister(javax.management.MBeanServer mbs, javax.management.ObjectName name)Called by an MBean server when this connector server is
registered in that MBean server. This connector server becomes
attached to the MBean server and its {@link #getMBeanServer()}
method will return mbs .
If this connector server is already attached to an MBean
server, this method has no effect. The MBean server it is
attached to is not necessarily the one it is being registered
in.
if (mbs == null || name == null)
throw new NullPointerException("Null MBeanServer or ObjectName");
if (mbeanServer == null) {
mbeanServer = mbs;
myName = name;
}
return name;
|
private void | sendNotification(java.lang.String type, java.lang.String connectionId, java.lang.String message, java.lang.Object userData)
Notification notif =
new JMXConnectionNotification(type,
getNotificationSource(),
connectionId,
nextSequenceNumber(),
message,
userData);
sendNotification(notif);
|
public synchronized void | setMBeanServerForwarder(javax.management.remote.MBeanServerForwarder mbsf)
if (mbsf == null)
throw new IllegalArgumentException("Invalid null argument: mbsf");
if (mbeanServer != null) mbsf.setMBeanServer(mbeanServer);
mbeanServer = mbsf;
|
public javax.management.remote.JMXConnector | toJMXConnector(java.util.Map env)Returns a client stub for this connector server. A client
stub is a serializable object whose {@link
JMXConnector#connect(Map) connect} method can be used to make
one new connection to this connector server.
A given connector need not support the generation of client
stubs. However, the connectors specified by the JMX Remote API do
(JMXMP Connector and RMI Connector).
The default implementation of this method uses {@link
#getAddress} and {@link JMXConnectorFactory} to generate the
stub, with code equivalent to the following:
JMXServiceURL addr = {@link #getAddress() getAddress()};
return {@link JMXConnectorFactory#newJMXConnector(JMXServiceURL, Map)
JMXConnectorFactory.newJMXConnector(addr, env)};
A connector server for which this is inappropriate must
override this method so that it either implements the
appropriate logic or throws {@link
UnsupportedOperationException}.
if (!isActive()) throw new
IllegalStateException("Connector is not active");
JMXServiceURL addr = getAddress();
return JMXConnectorFactory.newJMXConnector(addr, env);
|