jdk/src/jdk.management/share/classes/com/sun/management/GarbageCollectionNotificationInfo.java
author sjiang
Fri, 17 Apr 2015 09:40:02 +0200
changeset 30355 e37c7eba132f
parent 28059 jdk/src/java.management/share/classes/com/sun/management/GarbageCollectionNotificationInfo.java@e576535359cc
child 30365 551470085a1d
permissions -rw-r--r--
8042901: Allow com.sun.management to be in a different module to java.lang.management Reviewed-by: mchung, dfuchs, erikj, jbachorik
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9698
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
     1
/*
30355
e37c7eba132f 8042901: Allow com.sun.management to be in a different module to java.lang.management
sjiang
parents: 28059
diff changeset
     2
 * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
9698
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
     4
 *
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    10
 *
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    15
 * accompanied this code).
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    16
 *
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    20
 *
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    23
 * questions.
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    24
 */
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    25
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    26
package com.sun.management;
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    27
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    28
import javax.management.openmbean.CompositeData;
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    29
import javax.management.openmbean.CompositeDataView;
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    30
import javax.management.openmbean.CompositeType;
30355
e37c7eba132f 8042901: Allow com.sun.management to be in a different module to java.lang.management
sjiang
parents: 28059
diff changeset
    31
import com.sun.management.internal.GarbageCollectionNotifInfoCompositeData;
9698
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    32
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    33
/**
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    34
 * The information about a garbage collection
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    35
 *
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    36
 * <p>
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    37
 * A garbage collection notification is emitted by {@link GarbageCollectorMXBean}
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    38
 * when the Java virtual machine completes a garbage collection action
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    39
 * The notification emitted will contain the garbage collection notification
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    40
 * information about the status of the memory:
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    41
 * <u1>
28059
e576535359cc 8067377: My hobby: caning, then then canning, the the can-can
martin
parents: 25859
diff changeset
    42
 *   <li>The name of the garbage collector used to perform the collection.</li>
9698
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    43
 *   <li>The action performed by the garbage collector.</li>
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    44
 *   <li>The cause of the garbage collection action.</li>
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    45
 *   <li>A {@link GcInfo} object containing some statistics about the GC cycle
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    46
          (start time, end time) and the memory usage before and after
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    47
          the GC cycle.</li>
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    48
 * </u1>
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    49
 *
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    50
 * <p>
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    51
 * A {@link CompositeData CompositeData} representing
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    52
 * the {@code GarbageCollectionNotificationInfo} object
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    53
 * is stored in the
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    54
 * {@linkplain javax.management.Notification#setUserData userdata}
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    55
 * of a {@linkplain javax.management.Notification notification}.
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    56
 * The {@link #from from} method is provided to convert from
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    57
 * a {@code CompositeData} to a {@code GarbageCollectionNotificationInfo}
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    58
 * object. For example:
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    59
 *
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    60
 * <blockquote><pre>
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    61
 *      Notification notif;
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    62
 *
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    63
 *      // receive the notification emitted by a GarbageCollectorMXBean and set to notif
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    64
 *      ...
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    65
 *
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    66
 *      String notifType = notif.getType();
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    67
 *      if (notifType.equals(GarbageCollectionNotificationInfo.GARBAGE_COLLECTION_NOTIFICATION)) {
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    68
 *          // retrieve the garbage collection notification information
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    69
 *          CompositeData cd = (CompositeData) notif.getUserData();
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    70
 *          GarbageCollectionNotificationInfo info = GarbageCollectionNotificationInfo.from(cd);
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    71
 *          ....
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    72
 *      }
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    73
 * </pre></blockquote>
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    74
 *
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    75
 * <p>
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    76
 * The type of the notification emitted by a {@code GarbageCollectorMXBean} is:
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    77
 * <ul>
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    78
 *   <li>A {@linkplain #GARBAGE_COLLECTION_NOTIFICATION garbage collection notification}.
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    79
 *       <br>Used by every notification emitted by the garbage collector, the details about
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    80
 *             the notification are provided in the {@linkplain #getGcAction action} String
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    81
 *       <p></li>
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    82
 * </ul>
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    83
 **/
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    84
20742
4ae78e8060d6 8008662: Add @jdk.Exported to JDK-specific/exported APIs
alanb
parents: 9698
diff changeset
    85
@jdk.Exported
9698
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    86
public class GarbageCollectionNotificationInfo implements  CompositeDataView {
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    87
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    88
    private final String gcName;
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    89
    private final String gcAction;
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    90
    private final String gcCause;
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    91
    private final GcInfo gcInfo;
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    92
    private final CompositeData cdata;
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    93
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    94
    /**
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    95
     * Notification type denoting that
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    96
     * the Java virtual machine has completed a garbage collection cycle.
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    97
     * This notification is emitted by a {@link GarbageCollectorMXBean}.
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    98
     * The value of this notification type is
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    99
     * {@code com.sun.management.gc.notification}.
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   100
     */
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   101
    public static final String GARBAGE_COLLECTION_NOTIFICATION =
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   102
        "com.sun.management.gc.notification";
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   103
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   104
    /**
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   105
     * Constructs a {@code GarbageCollectionNotificationInfo} object.
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   106
     *
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   107
     * @param gcName The name of the garbage collector used to perform the collection
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   108
     * @param gcAction The name of the action performed by the garbage collector
28059
e576535359cc 8067377: My hobby: caning, then then canning, the the can-can
martin
parents: 25859
diff changeset
   109
     * @param gcCause The cause of the garbage collection action
9698
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   110
     * @param gcInfo  a GcInfo object providing statistics about the GC cycle
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   111
     */
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   112
    public GarbageCollectionNotificationInfo(String gcName,
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   113
                                             String gcAction,
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   114
                                             String gcCause,
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   115
                                             GcInfo gcInfo)  {
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   116
        if (gcName == null) {
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   117
            throw new NullPointerException("Null gcName");
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   118
        }
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   119
        if (gcAction == null) {
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   120
            throw new NullPointerException("Null gcAction");
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   121
        }
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   122
        if (gcCause == null) {
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   123
            throw new NullPointerException("Null gcCause");
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   124
        }
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   125
        this.gcName = gcName;
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   126
        this.gcAction = gcAction;
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   127
        this.gcCause = gcCause;
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   128
        this.gcInfo = gcInfo;
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   129
        this.cdata = new GarbageCollectionNotifInfoCompositeData(this);
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   130
    }
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   131
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   132
    GarbageCollectionNotificationInfo(CompositeData cd) {
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   133
        GarbageCollectionNotifInfoCompositeData.validateCompositeData(cd);
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   134
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   135
        this.gcName = GarbageCollectionNotifInfoCompositeData.getGcName(cd);
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   136
        this.gcAction = GarbageCollectionNotifInfoCompositeData.getGcAction(cd);
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   137
        this.gcCause = GarbageCollectionNotifInfoCompositeData.getGcCause(cd);
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   138
        this.gcInfo = GarbageCollectionNotifInfoCompositeData.getGcInfo(cd);
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   139
        this.cdata = cd;
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   140
    }
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   141
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   142
    /**
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   143
     * Returns the name of the garbage collector used to perform the collection
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   144
     *
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   145
     * @return the name of the garbage collector used to perform the collection
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   146
     */
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   147
    public String getGcName() {
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   148
        return gcName;
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   149
    }
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   150
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   151
    /**
28059
e576535359cc 8067377: My hobby: caning, then then canning, the the can-can
martin
parents: 25859
diff changeset
   152
     * Returns the action performed by the garbage collector
9698
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   153
     *
28059
e576535359cc 8067377: My hobby: caning, then then canning, the the can-can
martin
parents: 25859
diff changeset
   154
     * @return the action performed by the garbage collector
9698
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   155
     */
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   156
    public String getGcAction() {
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   157
        return gcAction;
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   158
    }
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   159
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   160
    /**
28059
e576535359cc 8067377: My hobby: caning, then then canning, the the can-can
martin
parents: 25859
diff changeset
   161
     * Returns the cause of the garbage collection
9698
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   162
     *
28059
e576535359cc 8067377: My hobby: caning, then then canning, the the can-can
martin
parents: 25859
diff changeset
   163
     * @return the cause of the garbage collection
9698
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   164
     */
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   165
    public String getGcCause() {
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   166
        return gcCause;
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   167
    }
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   168
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   169
    /**
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   170
     * Returns the GC information related to the last garbage collection
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   171
     *
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   172
     * @return the GC information related to the
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   173
     * last garbage collection
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   174
     */
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   175
    public GcInfo getGcInfo() {
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   176
        return gcInfo;
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   177
    }
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   178
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   179
    /**
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   180
     * Returns a {@code GarbageCollectionNotificationInfo} object represented by the
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   181
     * given {@code CompositeData}.
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   182
     * The given {@code CompositeData} must contain
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   183
     * the following attributes:
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   184
     * <blockquote>
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   185
     * <table border>
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   186
     * <tr>
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   187
     *   <th align=left>Attribute Name</th>
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   188
     *   <th align=left>Type</th>
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   189
     * </tr>
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   190
     * <tr>
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   191
     *   <td>gcName</td>
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   192
     *   <td>{@code java.lang.String}</td>
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   193
     * </tr>
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   194
     * <tr>
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   195
     *   <td>gcAction</td>
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   196
     *   <td>{@code java.lang.String}</td>
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   197
     * </tr>
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   198
     * <tr>
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   199
     *   <td>gcCause</td>
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   200
     *   <td>{@code java.lang.String}</td>
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   201
     * </tr>
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   202
     * <tr>
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   203
     *   <td>gcInfo</td>
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   204
     *   <td>{@code javax.management.openmbean.CompositeData}</td>
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   205
     * </tr>
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   206
     * </table>
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   207
     * </blockquote>
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   208
     *
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   209
     * @param cd {@code CompositeData} representing a
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   210
     *           {@code GarbageCollectionNotificationInfo}
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   211
     *
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   212
     * @throws IllegalArgumentException if {@code cd} does not
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   213
     *   represent a {@code GarbaageCollectionNotificationInfo} object.
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   214
     *
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   215
     * @return a {@code GarbageCollectionNotificationInfo} object represented
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   216
     *         by {@code cd} if {@code cd} is not {@code null};
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   217
     *         {@code null} otherwise.
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   218
     */
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   219
    public static GarbageCollectionNotificationInfo from(CompositeData cd) {
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   220
        if (cd == null) {
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   221
            return null;
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   222
        }
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   223
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   224
        if (cd instanceof GarbageCollectionNotifInfoCompositeData) {
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   225
            return ((GarbageCollectionNotifInfoCompositeData) cd).getGarbageCollectionNotifInfo();
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   226
        } else {
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   227
            return new GarbageCollectionNotificationInfo(cd);
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   228
        }
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   229
    }
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   230
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   231
    public CompositeData toCompositeData(CompositeType ct) {
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   232
        return cdata;
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   233
    }
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   234
8b66cd6c5ebc 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
   235
}