use of javax.management.DynamicMBean in project jdk8u_jdk by JetBrains.
the class DefaultMBeanServerInterceptor method getNewMBeanClassName.
private static String getNewMBeanClassName(Object mbeanToRegister) throws NotCompliantMBeanException {
if (mbeanToRegister instanceof DynamicMBean) {
DynamicMBean mbean = (DynamicMBean) mbeanToRegister;
final String name;
try {
name = mbean.getMBeanInfo().getClassName();
} catch (Exception e) {
// Includes case where getMBeanInfo() returns null
NotCompliantMBeanException ncmbe = new NotCompliantMBeanException("Bad getMBeanInfo()");
ncmbe.initCause(e);
throw ncmbe;
}
if (name == null) {
final String msg = "MBeanInfo has null class name";
throw new NotCompliantMBeanException(msg);
}
return name;
} else
return mbeanToRegister.getClass().getName();
}
use of javax.management.DynamicMBean in project jdk8u_jdk by JetBrains.
the class DefaultMBeanServerInterceptor method getClassLoaderFor.
/**
* <p>Return the {@link java.lang.ClassLoader} that was used for
* loading the class of the named MBean.
* @param mbeanName The ObjectName of the MBean.
* @return The ClassLoader used for that MBean.
* @exception InstanceNotFoundException if the named MBean is not found.
*/
public ClassLoader getClassLoaderFor(ObjectName mbeanName) throws InstanceNotFoundException {
DynamicMBean instance = getMBean(mbeanName);
checkMBeanPermission(instance, null, mbeanName, "getClassLoaderFor");
return getResource(instance).getClass().getClassLoader();
}
use of javax.management.DynamicMBean in project jdk8u_jdk by JetBrains.
the class DefaultMBeanServerInterceptor method invoke.
public Object invoke(ObjectName name, String operationName, Object[] params, String[] signature) throws InstanceNotFoundException, MBeanException, ReflectionException {
name = nonDefaultDomain(name);
DynamicMBean instance = getMBean(name);
checkMBeanPermission(instance, operationName, name, "invoke");
try {
return instance.invoke(operationName, params, signature);
} catch (Throwable t) {
rethrowMaybeMBeanException(t);
throw new AssertionError();
}
}
use of javax.management.DynamicMBean in project jdk8u_jdk by JetBrains.
the class DefaultMBeanServerInterceptor method removeNotificationListener.
private void removeNotificationListener(ObjectName name, NotificationListener listener, NotificationFilter filter, Object handback, boolean removeAll) throws InstanceNotFoundException, ListenerNotFoundException {
if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
MBEANSERVER_LOGGER.logp(Level.FINER, DefaultMBeanServerInterceptor.class.getName(), "removeNotificationListener", "ObjectName = " + name);
}
DynamicMBean instance = getMBean(name);
checkMBeanPermission(instance, null, name, "removeNotificationListener");
/* We could simplify the code by assigning broadcaster after
assigning listenerWrapper, but that would change the error
behavior when both the broadcaster and the listener are
erroneous. */
Class<? extends NotificationBroadcaster> reqClass = removeAll ? NotificationBroadcaster.class : NotificationEmitter.class;
NotificationBroadcaster broadcaster = getNotificationBroadcaster(name, instance, reqClass);
NotificationListener listenerWrapper = getListenerWrapper(listener, name, instance, false);
if (listenerWrapper == null)
throw new ListenerNotFoundException("Unknown listener");
if (removeAll)
broadcaster.removeNotificationListener(listenerWrapper);
else {
NotificationEmitter emitter = (NotificationEmitter) broadcaster;
emitter.removeNotificationListener(listenerWrapper, filter, handback);
}
}
use of javax.management.DynamicMBean in project jdk8u_jdk by JetBrains.
the class DefaultMBeanServerInterceptor method getAttributes.
public AttributeList getAttributes(ObjectName name, String[] attributes) throws InstanceNotFoundException, ReflectionException {
if (name == null) {
throw new RuntimeOperationsException(new IllegalArgumentException("ObjectName name cannot be null"), "Exception occurred trying to invoke the getter on the MBean");
}
if (attributes == null) {
throw new RuntimeOperationsException(new IllegalArgumentException("Attributes cannot be null"), "Exception occurred trying to invoke the getter on the MBean");
}
name = nonDefaultDomain(name);
if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
MBEANSERVER_LOGGER.logp(Level.FINER, DefaultMBeanServerInterceptor.class.getName(), "getAttributes", "ObjectName = " + name);
}
final DynamicMBean instance = getMBean(name);
final String[] allowedAttributes;
final SecurityManager sm = System.getSecurityManager();
if (sm == null)
allowedAttributes = attributes;
else {
final String classname = getClassName(instance);
// Check if the caller has the right to invoke 'getAttribute'
//
checkMBeanPermission(classname, null, name, "getAttribute");
// Check if the caller has the right to invoke 'getAttribute'
// on each specific attribute
//
List<String> allowedList = new ArrayList<String>(attributes.length);
for (String attr : attributes) {
try {
checkMBeanPermission(classname, attr, name, "getAttribute");
allowedList.add(attr);
} catch (SecurityException e) {
// OK: Do not add this attribute to the list
}
}
allowedAttributes = allowedList.toArray(new String[allowedList.size()]);
}
try {
return instance.getAttributes(allowedAttributes);
} catch (Throwable t) {
rethrow(t);
throw new AssertionError();
}
}
Aggregations