src/java.management/share/classes/java/lang/management/MemoryNotificationInfo.java
author mgronlun
Mon, 28 Oct 2019 18:43:04 +0100
branchJEP-349-branch
changeset 58823 6a21dba79b81
parent 47216 71c04702a3d5
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
44858
7183899b064b 8179415: Update java.management and java.management.rmi to be HTML-5 friendly
ksrini
parents: 32034
diff changeset
     2
 * Copyright (c) 2003, 2017, 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
package java.lang.management;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
import javax.management.openmbean.CompositeData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import sun.management.MemoryNotifInfoCompositeData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * The information about a memory notification.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * A memory notification is emitted by {@link MemoryMXBean}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * when the Java virtual machine detects that the memory usage
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * of a memory pool is exceeding a threshold value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * The notification emitted will contain the memory notification
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * information about the detected condition:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 *   <li>The name of the memory pool.</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 *   <li>The memory usage of the memory pool when the notification
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 *       was constructed.</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 *   <li>The number of times that the memory usage has crossed
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 *       a threshold when the notification was constructed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 *       For usage threshold notifications, this count will be the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 *       {@link MemoryPoolMXBean#getUsageThresholdCount usage threshold
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 *       count}.  For collection threshold notifications,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 *       this count will be the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 *       {@link MemoryPoolMXBean#getCollectionUsageThresholdCount
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 *       collection usage threshold count}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 *       </li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * A {@link CompositeData CompositeData} representing
32034
05676cfd40b5 8133040: docs: replace <tt> tags (obsolete in html5) for java.management
avstepan
parents: 25859
diff changeset
    56
 * the {@code MemoryNotificationInfo} object
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * is stored in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * {@link javax.management.Notification#setUserData user data}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * of a {@link javax.management.Notification notification}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * The {@link #from from} method is provided to convert from
32034
05676cfd40b5 8133040: docs: replace <tt> tags (obsolete in html5) for java.management
avstepan
parents: 25859
diff changeset
    61
 * a {@code CompositeData} to a {@code MemoryNotificationInfo}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * object. For example:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * <blockquote><pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 *      Notification notif;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 *      // receive the notification emitted by MemoryMXBean and set to notif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 *      ...
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 *      String notifType = notif.getType();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 *      if (notifType.equals(MemoryNotificationInfo.MEMORY_THRESHOLD_EXCEEDED) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 *          notifType.equals(MemoryNotificationInfo.MEMORY_COLLECTION_THRESHOLD_EXCEEDED)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 *          // retrieve the memory notification information
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 *          CompositeData cd = (CompositeData) notif.getUserData();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 *          MemoryNotificationInfo info = MemoryNotificationInfo.from(cd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 *          ....
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 *      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 * </pre></blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 * <p>
32034
05676cfd40b5 8133040: docs: replace <tt> tags (obsolete in html5) for java.management
avstepan
parents: 25859
diff changeset
    81
 * The types of notifications emitted by {@code MemoryMXBean} are:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
 * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
 *   <li>A {@link #MEMORY_THRESHOLD_EXCEEDED
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
 *       usage threshold exceeded notification}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
 *       <br>This notification will be emitted when
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
 *       the memory usage of a memory pool is increased and has reached
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
 *       or exceeded its
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
 *       <a href="MemoryPoolMXBean.html#UsageThreshold"> usage threshold</a> value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
 *       Subsequent crossing of the usage threshold value does not cause
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
 *       further notification until the memory usage has returned
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
 *       to become less than the usage threshold value.
24367
705490680527 8030709: Tidy warnings cleanup for java.lang package; minor cleanup in java.math, javax.script
yan
parents: 18799
diff changeset
    92
 *       </li>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
 *   <li>A {@link #MEMORY_COLLECTION_THRESHOLD_EXCEEDED
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
 *       collection usage threshold exceeded notification}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
 *       <br>This notification will be emitted when
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
 *       the memory usage of a memory pool is greater than or equal to its
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
 *       <a href="MemoryPoolMXBean.html#CollectionThreshold">
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
 *       collection usage threshold</a> after the Java virtual machine
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
 *       has expended effort in recycling unused objects in that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
 *       memory pool.</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
 * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
 * @author  Mandy Chung
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
 * @since   1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
public class MemoryNotificationInfo {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    private final String poolName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    private final MemoryUsage usage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    private final long count;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * Notification type denoting that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * the memory usage of a memory pool has
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * reached or exceeded its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     * <a href="MemoryPoolMXBean.html#UsageThreshold"> usage threshold</a> value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     * This notification is emitted by {@link MemoryMXBean}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     * Subsequent crossing of the usage threshold value does not cause
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     * further notification until the memory usage has returned
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     * to become less than the usage threshold value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * The value of this notification type is
32034
05676cfd40b5 8133040: docs: replace <tt> tags (obsolete in html5) for java.management
avstepan
parents: 25859
diff changeset
   122
     * {@code java.management.memory.threshold.exceeded}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    public static final String MEMORY_THRESHOLD_EXCEEDED =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        "java.management.memory.threshold.exceeded";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * Notification type denoting that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * the memory usage of a memory pool is greater than or equal to its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * <a href="MemoryPoolMXBean.html#CollectionThreshold">
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * collection usage threshold</a> after the Java virtual machine
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     * has expended effort in recycling unused objects in that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     * memory pool.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * This notification is emitted by {@link MemoryMXBean}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * The value of this notification type is
32034
05676cfd40b5 8133040: docs: replace <tt> tags (obsolete in html5) for java.management
avstepan
parents: 25859
diff changeset
   136
     * {@code java.management.memory.collection.threshold.exceeded}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    public static final String MEMORY_COLLECTION_THRESHOLD_EXCEEDED =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        "java.management.memory.collection.threshold.exceeded";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    /**
32034
05676cfd40b5 8133040: docs: replace <tt> tags (obsolete in html5) for java.management
avstepan
parents: 25859
diff changeset
   142
     * Constructs a {@code MemoryNotificationInfo} object.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     * @param poolName The name of the memory pool which triggers this notification.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * @param usage Memory usage of the memory pool.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * @param count The threshold crossing count.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    public MemoryNotificationInfo(String poolName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
                                  MemoryUsage usage,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
                                  long count) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        if (poolName == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
            throw new NullPointerException("Null poolName");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
        if (usage == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
            throw new NullPointerException("Null usage");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        this.poolName = poolName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        this.usage = usage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        this.count = count;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    MemoryNotificationInfo(CompositeData cd) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        MemoryNotifInfoCompositeData.validateCompositeData(cd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        this.poolName = MemoryNotifInfoCompositeData.getPoolName(cd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        this.usage = MemoryNotifInfoCompositeData.getUsage(cd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        this.count = MemoryNotifInfoCompositeData.getCount(cd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     * Returns the name of the memory pool that triggers this notification.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     * The memory pool usage has crossed a threshold.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     * @return the name of the memory pool that triggers this notification.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    public String getPoolName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        return poolName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     * Returns the memory usage of the memory pool
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * when this notification was constructed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     * @return the memory usage of the memory pool
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * when this notification was constructed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    public MemoryUsage getUsage() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        return usage;
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
     * Returns the number of times that the memory usage has crossed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     * a threshold when the notification was constructed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     * For usage threshold notifications, this count will be the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     * {@link MemoryPoolMXBean#getUsageThresholdCount threshold
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     * count}.  For collection threshold notifications,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     * this count will be the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     * {@link MemoryPoolMXBean#getCollectionUsageThresholdCount
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     * collection usage threshold count}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     * @return the number of times that the memory usage has crossed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     * a threshold when the notification was constructed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    public long getCount() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        return count;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    /**
32034
05676cfd40b5 8133040: docs: replace <tt> tags (obsolete in html5) for java.management
avstepan
parents: 25859
diff changeset
   210
     * Returns a {@code MemoryNotificationInfo} object represented by the
05676cfd40b5 8133040: docs: replace <tt> tags (obsolete in html5) for java.management
avstepan
parents: 25859
diff changeset
   211
     * given {@code CompositeData}.
05676cfd40b5 8133040: docs: replace <tt> tags (obsolete in html5) for java.management
avstepan
parents: 25859
diff changeset
   212
     * The given {@code CompositeData} must contain
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     * the following attributes:
47028
6df65183aa1f 8186932: Fix accessibility issues in the java.management module
jjg
parents: 44858
diff changeset
   214
     * <table class="striped" style="margin-left:2em">
44858
7183899b064b 8179415: Update java.management and java.management.rmi to be HTML-5 friendly
ksrini
parents: 32034
diff changeset
   215
     * <caption style="display:none">The attributes and the types the given CompositeData contains</caption>
47028
6df65183aa1f 8186932: Fix accessibility issues in the java.management module
jjg
parents: 44858
diff changeset
   216
     * <thead>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     * <tr>
47028
6df65183aa1f 8186932: Fix accessibility issues in the java.management module
jjg
parents: 44858
diff changeset
   218
     *   <th scope="col">Attribute Name</th>
6df65183aa1f 8186932: Fix accessibility issues in the java.management module
jjg
parents: 44858
diff changeset
   219
     *   <th scope="col">Type</th>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     * </tr>
47028
6df65183aa1f 8186932: Fix accessibility issues in the java.management module
jjg
parents: 44858
diff changeset
   221
     * </thead>
6df65183aa1f 8186932: Fix accessibility issues in the java.management module
jjg
parents: 44858
diff changeset
   222
     * <tbody style="text-align:left">
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     * <tr>
47028
6df65183aa1f 8186932: Fix accessibility issues in the java.management module
jjg
parents: 44858
diff changeset
   224
     *   <th scope="row">poolName</th>
32034
05676cfd40b5 8133040: docs: replace <tt> tags (obsolete in html5) for java.management
avstepan
parents: 25859
diff changeset
   225
     *   <td>{@code java.lang.String}</td>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
     * </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     * <tr>
47028
6df65183aa1f 8186932: Fix accessibility issues in the java.management module
jjg
parents: 44858
diff changeset
   228
     *   <th scope="row">usage</th>
32034
05676cfd40b5 8133040: docs: replace <tt> tags (obsolete in html5) for java.management
avstepan
parents: 25859
diff changeset
   229
     *   <td>{@code javax.management.openmbean.CompositeData}</td>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     * </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     * <tr>
47028
6df65183aa1f 8186932: Fix accessibility issues in the java.management module
jjg
parents: 44858
diff changeset
   232
     *   <th scope="row">count</th>
32034
05676cfd40b5 8133040: docs: replace <tt> tags (obsolete in html5) for java.management
avstepan
parents: 25859
diff changeset
   233
     *   <td>{@code java.lang.Long}</td>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
     * </tr>
47028
6df65183aa1f 8186932: Fix accessibility issues in the java.management module
jjg
parents: 44858
diff changeset
   235
     * </tbody>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     * </table>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
     *
32034
05676cfd40b5 8133040: docs: replace <tt> tags (obsolete in html5) for java.management
avstepan
parents: 25859
diff changeset
   238
     * @param cd {@code CompositeData} representing a
05676cfd40b5 8133040: docs: replace <tt> tags (obsolete in html5) for java.management
avstepan
parents: 25859
diff changeset
   239
     *           {@code MemoryNotificationInfo}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     *
32034
05676cfd40b5 8133040: docs: replace <tt> tags (obsolete in html5) for java.management
avstepan
parents: 25859
diff changeset
   241
     * @throws IllegalArgumentException if {@code cd} does not
05676cfd40b5 8133040: docs: replace <tt> tags (obsolete in html5) for java.management
avstepan
parents: 25859
diff changeset
   242
     *   represent a {@code MemoryNotificationInfo} object.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
     *
32034
05676cfd40b5 8133040: docs: replace <tt> tags (obsolete in html5) for java.management
avstepan
parents: 25859
diff changeset
   244
     * @return a {@code MemoryNotificationInfo} object represented
05676cfd40b5 8133040: docs: replace <tt> tags (obsolete in html5) for java.management
avstepan
parents: 25859
diff changeset
   245
     *         by {@code cd} if {@code cd} is not {@code null};
05676cfd40b5 8133040: docs: replace <tt> tags (obsolete in html5) for java.management
avstepan
parents: 25859
diff changeset
   246
     *         {@code null} otherwise.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
    public static MemoryNotificationInfo from(CompositeData cd) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
        if (cd == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
        if (cd instanceof MemoryNotifInfoCompositeData) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
            return ((MemoryNotifInfoCompositeData) cd).getMemoryNotifInfo();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
            return new MemoryNotificationInfo(cd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
}