Methods Summary |
---|
private static synchronized void | addMBeanServer(javax.management.MBeanServer mbs)
mBeanServerList.add(mbs);
|
private static synchronized void | checkMBeanServerBuilder()Instantiate a new builder according to the
javax.management.builder.initial System property - if needed.
try {
GetPropertyAction act =
new GetPropertyAction(JmxProperties.JMX_INITIAL_BUILDER);
String builderClassName = AccessController.doPrivileged(act);
try {
final Class newBuilderClass;
if (builderClassName == null || builderClassName.length() == 0)
newBuilderClass = MBeanServerBuilder.class;
else
newBuilderClass = loadBuilderClass(builderClassName);
// Check whether a new builder needs to be created
if (builder != null) {
final Class builderClass = builder.getClass();
if (newBuilderClass == builderClass)
return; // no need to create a new builder...
}
// Create a new builder
builder = newBuilder(newBuilderClass);
} catch (ClassNotFoundException x) {
final String msg =
"Failed to load MBeanServerBuilder class " +
builderClassName + ": " + x;
throw new JMRuntimeException(msg, x);
}
} catch (RuntimeException x) {
debug("checkMBeanServerBuilder",
"Failed to instantiate MBeanServerBuilder: " + x +
"\n\t\tCheck the value of the " +
JmxProperties.JMX_INITIAL_BUILDER + " property." );
throw x;
}
|
private static void | checkPermission(java.lang.String action)
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
Permission perm = new MBeanServerPermission(action);
sm.checkPermission(perm);
}
|
public static javax.management.MBeanServer | createMBeanServer()Return a new object implementing the MBeanServer interface
with a standard default domain name. The default domain name
is used as the domain part in the ObjectName of MBeans when the
domain is specified by the user is null.
The standard default domain name is
DefaultDomain .
The MBeanServer reference is internally kept. This will
allow findMBeanServer to return a reference to
this MBeanServer object.
This method is equivalent to createMBeanServer(null) .
return createMBeanServer(null);
|
public static javax.management.MBeanServer | createMBeanServer(java.lang.String domain)Return a new object implementing the {@link MBeanServer}
interface with the specified default domain name. The given
domain name is used as the domain part in the ObjectName of
MBeans when the domain is specified by the user is null.
The MBeanServer reference is internally kept. This will
allow findMBeanServer to return a reference to
this MBeanServer object.
checkPermission("createMBeanServer");
final MBeanServer mBeanServer = newMBeanServer(domain);
addMBeanServer(mBeanServer);
return mBeanServer;
|
private static void | debug(java.lang.String method, java.lang.String message)Private Stuff
if (Trace.isSelected(Trace.LEVEL_DEBUG, Trace.INFO_MBEANSERVER)) {
Trace.send(Trace.LEVEL_DEBUG, Trace.INFO_MBEANSERVER,
MBeanServerFactory.class.getName(), method, message);
}
|
private static void | error(java.lang.String method, java.lang.String message)Private Stuff
if (Trace.isSelected(Trace.LEVEL_ERROR, Trace.INFO_MBEANSERVER)) {
Trace.send(Trace.LEVEL_ERROR, Trace.INFO_MBEANSERVER,
MBeanServerFactory.class.getName(), method, message);
}
|
public static synchronized java.util.ArrayList | findMBeanServer(java.lang.String agentId)Return a list of registered MBeanServer objects. A
registered MBeanServer object is one that was created by one of
the createMBeanServer methods and not subsequently
released with releaseMBeanServer .
checkPermission("findMBeanServer");
if (agentId == null)
return new ArrayList<MBeanServer>(mBeanServerList);
ArrayList<MBeanServer> result = new ArrayList<MBeanServer>();
for (MBeanServer mbs : mBeanServerList) {
String name = mBeanServerName(mbs);
if (agentId.equals(name))
result.add(mbs);
}
return result;
|
public static javax.management.loading.ClassLoaderRepository | getClassLoaderRepository(javax.management.MBeanServer server)Return the ClassLoaderRepository used by the given MBeanServer.
This method is equivalent to {@link MBeanServer#getClassLoaderRepository() server.getClassLoaderRepository()}.
return server.getClassLoaderRepository();
|
private static synchronized javax.management.MBeanServerBuilder | getNewMBeanServerBuilder()Get the current {@link javax.management.MBeanServerBuilder},
as specified by the current value of the
javax.management.builder.initial property.
This method consults the property and instantiates a new builder
if needed.
checkMBeanServerBuilder();
return builder;
|
private static java.lang.Class | loadBuilderClass(java.lang.String builderClassName)Load the builder class through the context class loader.
final ClassLoader loader =
Thread.currentThread().getContextClassLoader();
if (loader != null) {
// Try with context class loader
return loader.loadClass(builderClassName);
}
// No context class loader? Try with Class.forName()
return Class.forName(builderClassName);
|
private static java.lang.String | mBeanServerName(javax.management.MBeanServer mbs)
try {
return (String) mbs.getAttribute(MBeanServerDelegate.DELEGATE_NAME,
"MBeanServerId");
} catch (JMException e) {
return null;
}
|
private static javax.management.MBeanServerBuilder | newBuilder(java.lang.Class builderClass)Creates the initial builder according to the
javax.management.builder.initial System property - if specified.
If any checked exception needs to be thrown, it is embedded in
a JMRuntimeException.
try {
final Object builder = builderClass.newInstance();
return (MBeanServerBuilder)builder;
} catch (RuntimeException x) {
throw x;
} catch (Exception x) {
final String msg =
"Failed to instantiate a MBeanServerBuilder from " +
builderClass + ": " + x;
throw new JMRuntimeException(msg, x);
}
|
public static javax.management.MBeanServer | newMBeanServer()Return a new object implementing the MBeanServer interface
with a standard default domain name, without keeping an
internal reference to this new object. The default domain name
is used as the domain part in the ObjectName of MBeans when the
domain is specified by the user is null.
The standard default domain name is
DefaultDomain .
No reference is kept. findMBeanServer will not
be able to return a reference to this MBeanServer object, but
the garbage collector will be able to remove the MBeanServer
object when it is no longer referenced.
This method is equivalent to newMBeanServer(null) .
return newMBeanServer(null);
|
public static javax.management.MBeanServer | newMBeanServer(java.lang.String domain)Return a new object implementing the MBeanServer interface
with the specified default domain name, without keeping an
internal reference to this new object. The given domain name
is used as the domain part in the ObjectName of MBeans when the
domain is specified by the user is null.
No reference is kept. findMBeanServer will not
be able to return a reference to this MBeanServer object, but
the garbage collector will be able to remove the MBeanServer
object when it is no longer referenced.
checkPermission("newMBeanServer");
// Get the builder. Creates a new one if necessary.
//
final MBeanServerBuilder mbsBuilder = getNewMBeanServerBuilder();
// Returned value cannot be null. NullPointerException if violated.
synchronized(mbsBuilder) {
final MBeanServerDelegate delegate =
mbsBuilder.newMBeanServerDelegate();
if (delegate == null) {
final String msg =
"MBeanServerBuilder.newMBeanServerDelegate() " +
"returned null";
throw new JMRuntimeException(msg);
}
final MBeanServer mbeanServer =
mbsBuilder.newMBeanServer(domain,null,delegate);
if (mbeanServer == null) {
final String msg =
"MBeanServerBuilder.newMBeanServer() returned null";
throw new JMRuntimeException(msg);
}
return mbeanServer;
}
|
public static void | releaseMBeanServer(javax.management.MBeanServer mbeanServer)Remove internal MBeanServerFactory references to a created
MBeanServer. This allows the garbage collector to remove the
MBeanServer object.
// public static synchronized void
// setMBeanServerBuilder(MBeanServerBuilder builder) {
// checkPermission("setMBeanServerBuilder");
// MBeanServerFactory.builder = builder;
// }
// public static synchronized MBeanServerBuilder getMBeanServerBuilder() {
// checkPermission("getMBeanServerBuilder");
// return builder;
// }
checkPermission("releaseMBeanServer");
removeMBeanServer(mbeanServer);
|
private static synchronized void | removeMBeanServer(javax.management.MBeanServer mbs)
boolean removed = mBeanServerList.remove(mbs);
if (!removed) {
trace("removeMBeanServer", "MBeanServer was not in list!");
throw new IllegalArgumentException("MBeanServer was not in list!");
}
|
private static void | trace(java.lang.String method, java.lang.String message)Private Stuff
if (Trace.isSelected(Trace.LEVEL_TRACE, Trace.INFO_MBEANSERVER)) {
Trace.send(Trace.LEVEL_TRACE, Trace.INFO_MBEANSERVER,
MBeanServerFactory.class.getName(), method, message);
}
|