use of javax.management.RuntimeOperationsException in project jdk8u_jdk by JetBrains.
the class MBeanInstantiator method findClassWithDefaultLoaderRepository.
/**
* Loads the class with the specified name using this object's
* Default Loader Repository.
**/
public Class<?> findClassWithDefaultLoaderRepository(String className) throws ReflectionException {
Class<?> theClass;
if (className == null) {
throw new RuntimeOperationsException(new IllegalArgumentException("The class name cannot be null"), "Exception occurred during object instantiation");
}
ReflectUtil.checkPackageAccess(className);
try {
if (clr == null)
throw new ClassNotFoundException(className);
theClass = clr.loadClass(className);
} catch (ClassNotFoundException ee) {
throw new ReflectionException(ee, "The MBean class could not be loaded by the default loader repository");
}
return theClass;
}
use of javax.management.RuntimeOperationsException in project jdk8u_jdk by JetBrains.
the class DefaultMBeanServerInterceptor method addClassLoader.
/**
* Registers a ClassLoader with the CLR.
* This method is called by the ResourceContext from within the
* repository lock.
* @param loader The ClassLoader.
* @param logicalName The ClassLoader MBean ObjectName.
*/
private void addClassLoader(ClassLoader loader, final ObjectName logicalName) {
/**
* Called when the newly registered MBean is a ClassLoader
* If so, tell the ClassLoaderRepository (CLR) about it. We do
* this even if the loader is a PrivateClassLoader. In that
* case, the CLR remembers the loader for use when it is
* explicitly named (e.g. as the loader in createMBean) but
* does not add it to the list that is consulted by
* ClassLoaderRepository.loadClass.
*/
final ModifiableClassLoaderRepository clr = getInstantiatorCLR();
if (clr == null) {
final RuntimeException wrapped = new IllegalArgumentException("Dynamic addition of class loaders" + " is not supported");
throw new RuntimeOperationsException(wrapped, "Exception occurred trying to register" + " the MBean as a class loader");
}
clr.addClassLoader(logicalName, loader);
}
use of javax.management.RuntimeOperationsException 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();
}
}
use of javax.management.RuntimeOperationsException in project jdk8u_jdk by JetBrains.
the class RequiredModelMBean method sendNotification.
public void sendNotification(String ntfyText) throws MBeanException, RuntimeOperationsException {
if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
MODELMBEAN_LOGGER.logp(Level.FINER, RequiredModelMBean.class.getName(), "sendNotification(String)", "Entry");
}
if (ntfyText == null)
throw new RuntimeOperationsException(new IllegalArgumentException("notification message must not " + "be null"), "Exception occurred trying to send a text notification " + "from a ModelMBean");
Notification myNtfyObj = new Notification("jmx.modelmbean.generic", this, 1, ntfyText);
sendNotification(myNtfyObj);
if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
MODELMBEAN_LOGGER.logp(Level.FINER, RequiredModelMBean.class.getName(), "sendNotification(String)", "Notification sent");
MODELMBEAN_LOGGER.logp(Level.FINER, RequiredModelMBean.class.getName(), "sendNotification(String)", "Exit");
}
}
use of javax.management.RuntimeOperationsException in project jdk8u_jdk by JetBrains.
the class RequiredModelMBean method removeAttributeChangeNotificationListener.
public void removeAttributeChangeNotificationListener(NotificationListener inlistener, String inAttributeName) throws MBeanException, RuntimeOperationsException, ListenerNotFoundException {
if (inlistener == null)
throw new ListenerNotFoundException("Notification listener is null");
final String mth = "removeAttributeChangeNotificationListener(" + "NotificationListener, String)";
if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
MODELMBEAN_LOGGER.logp(Level.FINER, RequiredModelMBean.class.getName(), mth, "Entry");
}
if (attributeBroadcaster == null)
throw new ListenerNotFoundException("No attribute change notification listeners registered");
MBeanAttributeInfo[] attrInfo = modelMBeanInfo.getAttributes();
boolean found = false;
if ((attrInfo != null) && (attrInfo.length > 0)) {
for (int i = 0; i < attrInfo.length; i++) {
if (attrInfo[i].getName().equals(inAttributeName)) {
found = true;
break;
}
}
}
if ((!found) && (inAttributeName != null)) {
throw new RuntimeOperationsException(new IllegalArgumentException("Invalid attribute name"), "Exception occurred trying to remove " + "attribute change notification listener");
}
/* note: */
/* this may be a problem if the same listener is registered for
multiple attributes with multiple filters and/or handback
objects. It may remove all of them */
attributeBroadcaster.removeNotificationListener(inlistener);
if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
MODELMBEAN_LOGGER.logp(Level.FINER, RequiredModelMBean.class.getName(), mth, "Exit");
}
}
Aggregations