/* * Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved. * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * * * * * * * * * * * * * * * * * * * * */ package javax.management.remote; import javax.management.Notification; import javax.management.ObjectName; /** *
Notification emitted when a client connection is opened or * closed or when notifications are lost. These notifications are * sent by connector servers (instances of {@link JMXConnectorServer}) * and by connector clients (instances of {@link JMXConnector}). For * certain connectors, a session can consist of a sequence of * connections. Connection-opened and connection-closed notifications * will be sent for each one.
* *The notification type is one of the following:
* *Type | *Meaning | *
---|---|
jmx.remote.connection.opened |
* A new client connection has been opened. | *
jmx.remote.connection.closed |
* A client connection has been closed. | *
jmx.remote.connection.failed |
* A client connection has failed unexpectedly. | *
jmx.remote.connection.notifs.lost |
* A client connection has potentially lost notifications. This * notification only appears on the client side. | *
The timeStamp
of the notification is a time value
* (consistent with {@link System#currentTimeMillis()}) indicating
* when the notification was constructed.
Notification type string for a connection-opened notification. */ public static final String OPENED = "jmx.remote.connection.opened"; /** *
Notification type string for a connection-closed notification. */ public static final String CLOSED = "jmx.remote.connection.closed"; /** *
Notification type string for a connection-failed notification. */ public static final String FAILED = "jmx.remote.connection.failed"; /** *
Notification type string for a connection that has possibly * lost notifications.
*/ public static final String NOTIFS_LOST = "jmx.remote.connection.notifs.lost"; /** * Constructs a new connection notification. The {@link * #getSource() source} of the notification depends on whether it * is being sent by a connector server or a connector client: * *sequenceNumber
in a notification from
* this source.
*
* @param message an unspecified text message, typically containing
* a human-readable description of the event. Can be null.
*
* @param userData an object whose type and meaning is defined by
* the connector server. Can be null.
*
* @exception NullPointerException if type
,
* source
, or connectionId
is null.
*
* @exception IllegalArgumentException if
* sequenceNumber
is negative.
*/
public JMXConnectionNotification(String type,
Object source,
String connectionId,
long sequenceNumber,
String message,
Object userData) {
/* We don't know whether the parent class (Notification) will
throw an exception if the type or source is null, because
JMX 1.2 doesn't specify that. So we make sure it is not
null, in case it would throw the wrong exception
(e.g. IllegalArgumentException instead of
NullPointerException). Likewise for the sequence number. */
super((String) nonNull(type),
nonNull(source),
Math.max(0, sequenceNumber),
System.currentTimeMillis(),
message);
if (type == null || source == null || connectionId == null)
throw new NullPointerException("Illegal null argument");
if (sequenceNumber < 0)
throw new IllegalArgumentException("Negative sequence number");
this.connectionId = connectionId;
setUserData(userData);
}
private static Object nonNull(Object arg) {
if (arg == null)
return "";
else
return arg;
}
/**
* The connection ID to which this notification pertains. * * @return the connection ID. */ public String getConnectionId() { return connectionId; } /** * @serial The connection ID to which this notification pertains. * @see #getConnectionId() **/ private final String connectionId; }