# Class JMXConnectionNotification

java.lang.Object
java.util.EventObject
javax.management.Notification
javax.management.remote.JMXConnectionNotification

All Implemented Interfaces:
  `Serializable`

public class JMXConnectionNotification extends Notification

Notification emitted when a client connection is opened or closed or when notifications are lost. These notifications are sent by connector servers (instances of `JMXConnectorServer`) and by connector clients (instances of `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:

JMXConnectionNotification Types
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 `System.currentTimeMillis()`) indicating when the notification was constructed.

Since:
  1.5
See Also:
  - Serialized Form

## Field Summary

Fields
Modifier and Type
Field
Description
`static final String`
`CLOSED`
Notification type string for a connection-closed notification.
`static final String`
`FAILED`
Notification type string for a connection-failed notification.
`static final String`
`NOTIFS_LOST`
Notification type string for a connection that has possibly lost notifications.
`static final String`
`OPENED`
Notification type string for a connection-opened notification.

### Fields declared in class Notification

`source`
Modifier and Type
Field
Description
`protected Object`
`source`
This field hides the `EventObject.source` field in the parent class to make it non-transient and therefore part of the serialized form.

## Constructor Summary

Constructors
Constructor
Description
`JMXConnectionNotification(String type, Object source, String connectionId, long sequenceNumber, String message, Object userData)`
Constructs a new connection notification.

## Method Summary

Modifier and Type
Method
Description
`String`
`getConnectionId()`
The connection ID to which this notification pertains.

### Methods declared in class Notification

`getMessage, getSequenceNumber, getTimeStamp, getType, getUserData, setSequenceNumber, setSource, setTimeStamp, setUserData, toString`
Modifier and Type
Method
Description
`String`
`getMessage()`
Get the notification message.
`long`
`getSequenceNumber()`
Get the notification sequence number.
`long`
`getTimeStamp()`
Get the notification timestamp.
`String`
`getType()`
Get the notification type.
`Object`
`getUserData()`
Get the user data.
`void`
`setSequenceNumber(long sequenceNumber)`
Set the notification sequence number.
`void`
`setSource(Object source)`
Sets the source.
`void`
`setTimeStamp(long timeStamp)`
Set the notification timestamp.
`void`
`setUserData(Object userData)`
Set the user data.
`String`
`toString()`
Returns a String representation of this notification.

### Methods declared in class EventObject

`getSource`
Modifier and Type
Method
Description
`Object`
`getSource()`
The object on which the Event initially occurred.

### Methods declared in class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`
Modifier and Type
Method
Description
`protected Object`
`clone()`
Creates and returns a copy of this object.
`boolean`
`equals(Object obj)`
Indicates whether some other object is "equal to" this one.
`protected void`
`finalize()`
Deprecated, for removal: This API element is subject to removal in a future version.
Finalization is deprecated and subject to removal in a future release.
`final Class<?>`
`getClass()`
Returns the runtime class of this `Object`.
`int`
`hashCode()`
Returns a hash code value for this object.
`final void`
`notify()`
Wakes up a single thread that is waiting on this object's monitor.
`final void`
`notifyAll()`
Wakes up all threads that are waiting on this object's monitor.
`final void`
`wait()`
Causes the current thread to wait until it is awakened, typically by being notified or interrupted.
`final void`
`wait(long timeoutMillis)`
Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
`final void`
`wait(long timeoutMillis, int nanos)`
Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

## Field Details

### OPENED

public static final String OPENED

Notification type string for a connection-opened notification.

See Also:
  - Constant Field Values

### CLOSED

public static final String CLOSED

Notification type string for a connection-closed notification.

See Also:
  - Constant Field Values

### FAILED

public static final String FAILED

Notification type string for a connection-failed notification.

See Also:
  - Constant Field Values

### NOTIFS_LOST

public static final String NOTIFS_LOST

Notification type string for a connection that has possibly lost notifications.

See Also:
  - Constant Field Values

## Constructor Details

### JMXConnectionNotification

public JMXConnectionNotification(String type, Object source, String connectionId, long sequenceNumber, String message, Object userData)
Constructs a new connection notification. The `source` of the notification depends on whether it is being sent by a connector server or a connector client:

- For a connector server, if it is registered in an MBean server, the source is the `ObjectName` under which it is registered. Otherwise, it is a reference to the connector server object itself, an instance of a subclass of `JMXConnectorServer`.
- For a connector client, the source is a reference to the connector client object, an instance of a class implementing `JMXConnector`.

Parameters:
  `type` - the type of the notification. This is usually one of the constants `OPENED`, `CLOSED`, `FAILED`, `NOTIFS_LOST`. It is not an error for it to be a different string.
  `source` - the connector server or client emitting the notification.
  `connectionId` - the ID of the connection within its connector server.
  `sequenceNumber` - a non-negative integer. It is expected but not required that this number will be greater than any previous `sequenceNumber` in a notification from this source.
  `message` - an unspecified text message, typically containing a human-readable description of the event. Can be null.
  `userData` - an object whose type and meaning is defined by the connector server. Can be null.
Throws:
  `NullPointerException` - if `type`, `source`, or `connectionId` is null.
  `IllegalArgumentException` - if `sequenceNumber` is negative.

## Method Details

### getConnectionId

public String getConnectionId()

The connection ID to which this notification pertains.

Returns:
  the connection ID.