src/share/classes/sun/management/ManagementFactoryHelper.java
Print this page
@@ -25,24 +25,22 @@
package sun.management;
import java.lang.management.*;
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
import javax.management.InstanceAlreadyExistsException;
import javax.management.InstanceNotFoundException;
+import javax.management.MBeanServer;
import javax.management.MBeanRegistrationException;
import javax.management.NotCompliantMBeanException;
+import javax.management.ObjectName;
import javax.management.RuntimeOperationsException;
-import java.nio.BufferPoolMXBean;
import java.security.AccessController;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import sun.security.action.LoadLibraryAction;
-import java.util.logging.PlatformLoggingMXBean;
import sun.util.logging.LoggingSupport;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -137,21 +135,27 @@
}
}
return result;
}
- public static List<PlatformLoggingMXBean> getLoggingMXBean() {
+ public static PlatformLoggingMXBean getPlatformLoggingMXBean() {
if (LoggingSupport.isAvailable()) {
- return Collections.singletonList(createPlatformLoggingMXBean());
+ return PlatformLoggingImpl.instance;
} else {
- return Collections.emptyList();
+ return null;
}
}
- private final static String LOGGING_MXBEAN_NAME = "java.util.logging:type=Logging";
- private static PlatformLoggingMXBean createPlatformLoggingMXBean() {
- return new PlatformLoggingMXBean() {
+ interface LoggingMXBean
+ extends PlatformLoggingMXBean, java.util.logging.LoggingMXBean {
+ }
+
+ static class PlatformLoggingImpl implements LoggingMXBean
+ {
+ final static PlatformLoggingMXBean instance = new PlatformLoggingImpl();
+ final static String LOGGING_MXBEAN_NAME = "java.util.logging:type=Logging";
+
private volatile ObjectName objname; // created lazily
@Override
public ObjectName getObjectName() {
ObjectName result = objname;
if (result == null) {
@@ -182,21 +186,23 @@
@Override
public String getParentLoggerName(String loggerName) {
return LoggingSupport.getParentLoggerName(loggerName);
}
- };
}
- public static List<BufferPoolMXBean> getBufferPoolMXBeans() {
- List<BufferPoolMXBean> pools = new ArrayList<BufferPoolMXBean>(2);
- pools.add(createBufferPoolMXBean(sun.misc.SharedSecrets.getJavaNioAccess()
+ private static List<BufferPoolMXBean> bufferPools = null;
+ public static synchronized List<BufferPoolMXBean> getBufferPoolMXBeans() {
+ if (bufferPools == null) {
+ bufferPools = new ArrayList<>(2);
+ bufferPools.add(createBufferPoolMXBean(sun.misc.SharedSecrets.getJavaNioAccess()
.getDirectBufferPool()));
- pools.add(createBufferPoolMXBean(sun.nio.ch.FileChannelImpl
+ bufferPools.add(createBufferPoolMXBean(sun.nio.ch.FileChannelImpl
.getMappedBufferPool()));
- return pools;
}
+ return bufferPools;
+ }
private final static String BUFFER_POOL_MXBEAN_NAME = "java.nio:type=BufferPool";
/**
* Creates management interface for the given buffer pool.