jdk/src/share/classes/javax/management/remote/JMXConnectionNotification.java
author yan
Mon, 12 May 2014 14:33:13 +0400
changeset 24368 2b4801b94265
parent 23010 6dadb192ad81
permissions -rw-r--r--
8038795: Tidy warnings cleanup for javax.management Reviewed-by: dfuchs Contributed-by: Alexander Stepanov <alexander.v.stepanov@oracle.com>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
23010
6dadb192ad81 8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013
lana
parents: 21656
diff changeset
     2
 * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
package javax.management.remote;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import javax.management.Notification;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import javax.management.ObjectName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * <p>Notification emitted when a client connection is opened or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * closed or when notifications are lost.  These notifications are
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * sent by connector servers (instances of {@link JMXConnectorServer})
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * and by connector clients (instances of {@link JMXConnector}).  For
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * certain connectors, a session can consist of a sequence of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * connections.  Connection-opened and connection-closed notifications
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * will be sent for each one.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * <p>The notification type is one of the following:</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 *
21656
d4c777ccb1db 8028014: Doclint warning/error cleanup in javax.management
rriggs
parents: 5506
diff changeset
    43
 * <table summary="JMXConnectionNotification Types">
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * <th align=left>Type</th>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * <th align=left>Meaning</th>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * <td><code>jmx.remote.connection.opened</code></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * <td>A new client connection has been opened.</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * <td><code>jmx.remote.connection.closed</code></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * <td>A client connection has been closed.</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * <td><code>jmx.remote.connection.failed</code></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * <td>A client connection has failed unexpectedly.</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * <td><code>jmx.remote.connection.notifs.lost</code></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 * <td>A client connection has potentially lost notifications.  This
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 * notification only appears on the client side.</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 * </table>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 * <p>The <code>timeStamp</code> of the notification is a time value
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 * (consistent with {@link System#currentTimeMillis()}) indicating
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 * when the notification was constructed.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
public class JMXConnectionNotification extends Notification {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    private static final long serialVersionUID = -2331308725952627538L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * <p>Notification type string for a connection-opened notification.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    public static final String OPENED = "jmx.remote.connection.opened";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     * <p>Notification type string for a connection-closed notification.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    public static final String CLOSED = "jmx.remote.connection.closed";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * <p>Notification type string for a connection-failed notification.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    public static final String FAILED = "jmx.remote.connection.failed";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * <p>Notification type string for a connection that has possibly
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * lost notifications.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    public static final String NOTIFS_LOST =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        "jmx.remote.connection.notifs.lost";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * Constructs a new connection notification.  The {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * #getSource() source} of the notification depends on whether it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * is being sent by a connector server or a connector client:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * <li>For a connector server, if it is registered in an MBean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * server, the source is the {@link ObjectName} under which it is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * registered.  Otherwise, it is a reference to the connector
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * server object itself, an instance of a subclass of {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * JMXConnectorServer}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     * <li>For a connector client, the source is a reference to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     * connector client object, an instance of a class implementing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     * {@link JMXConnector}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     * @param type the type of the notification.  This is usually one
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * of the constants {@link #OPENED}, {@link #CLOSED}, {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     * #FAILED}, {@link #NOTIFS_LOST}.  It is not an error for it to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * be a different string.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * @param source the connector server or client emitting the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * notification.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * @param connectionId the ID of the connection within its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     * connector server.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * @param sequenceNumber a non-negative integer.  It is expected
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * but not required that this number will be greater than any
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     * previous <code>sequenceNumber</code> in a notification from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     * this source.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     * @param message an unspecified text message, typically containing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     * a human-readable description of the event.  Can be null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     * @param userData an object whose type and meaning is defined by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     * the connector server.  Can be null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * @exception NullPointerException if <code>type</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * <code>source</code>, or <code>connectionId</code> is null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * @exception IllegalArgumentException if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * <code>sequenceNumber</code> is negative.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    public JMXConnectionNotification(String type,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
                                     Object source,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
                                     String connectionId,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
                                     long sequenceNumber,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
                                     String message,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
                                     Object userData) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        /* We don't know whether the parent class (Notification) will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
           throw an exception if the type or source is null, because
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
           JMX 1.2 doesn't specify that.  So we make sure it is not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
           null, in case it would throw the wrong exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
           (e.g. IllegalArgumentException instead of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
           NullPointerException).  Likewise for the sequence number.  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        super((String) nonNull(type),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
              nonNull(source),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
              Math.max(0, sequenceNumber),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
              System.currentTimeMillis(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
              message);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        if (type == null || source == null || connectionId == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
            throw new NullPointerException("Illegal null argument");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
        if (sequenceNumber < 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
            throw new IllegalArgumentException("Negative sequence number");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        this.connectionId = connectionId;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        setUserData(userData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    private static Object nonNull(Object arg) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        if (arg == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
            return "";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
            return arg;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     * <p>The connection ID to which this notification pertains.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * @return the connection ID.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    public String getConnectionId() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        return connectionId;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     * @serial The connection ID to which this notification pertains.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     * @see #getConnectionId()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     **/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
    private final String connectionId;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
}