|
Java example source code file (GarbageCollectionNotificationInfo.java)
The GarbageCollectionNotificationInfo.java Java example source code
/*
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.management;
import javax.management.Notification;
import javax.management.openmbean.CompositeData;
import javax.management.openmbean.CompositeDataView;
import javax.management.openmbean.CompositeType;
import java.util.Collection;
import java.util.Collections;
import sun.management.GarbageCollectionNotifInfoCompositeData;
/**
* The information about a garbage collection
*
* <p>
* A garbage collection notification is emitted by {@link GarbageCollectorMXBean}
* when the Java virtual machine completes a garbage collection action
* The notification emitted will contain the garbage collection notification
* information about the status of the memory:
* <u1>
* <li>The name of the garbage collector used perform the collection.
* <li>The action performed by the garbage collector.
* <li>The cause of the garbage collection action.
* <li>A {@link GcInfo} object containing some statistics about the GC cycle
(start time, end time) and the memory usage before and after
the GC cycle.</li>
* </u1>
*
* <p>
* A {@link CompositeData CompositeData} representing
* the {@code GarbageCollectionNotificationInfo} object
* is stored in the
* {@linkplain javax.management.Notification#setUserData userdata}
* of a {@linkplain javax.management.Notification notification}.
* The {@link #from from} method is provided to convert from
* a {@code CompositeData} to a {@code GarbageCollectionNotificationInfo}
* object. For example:
*
* <blockquote> |
* <td>{@code java.lang.String}
* </tr>
* <tr>
* <td>gcAction
* <td>{@code java.lang.String}
* </tr>
* <tr>
* <td>gcCause
* <td>{@code java.lang.String}
* </tr>
* <tr>
* <td>gcInfo
* <td>{@code javax.management.openmbean.CompositeData}
* </tr>
* </table>
* </blockquote>
*
* @param cd {@code CompositeData} representing a
* {@code GarbageCollectionNotificationInfo}
*
* @throws IllegalArgumentException if {@code cd} does not
* represent a {@code GarbaageCollectionNotificationInfo} object.
*
* @return a {@code GarbageCollectionNotificationInfo} object represented
* by {@code cd} if {@code cd} is not {@code null};
* {@code null} otherwise.
*/
public static GarbageCollectionNotificationInfo from(CompositeData cd) {
if (cd == null) {
return null;
}
if (cd instanceof GarbageCollectionNotifInfoCompositeData) {
return ((GarbageCollectionNotifInfoCompositeData) cd).getGarbageCollectionNotifInfo();
} else {
return new GarbageCollectionNotificationInfo(cd);
}
}
public CompositeData toCompositeData(CompositeType ct) {
return cdata;
}
}
| ... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.