use of javax.management.RuntimeOperationsException in project geode by apache.
the class MX4JModelMBean method setManagedResource.
public void setManagedResource(Object resource, String resourceType) throws MBeanException, RuntimeOperationsException, InstanceNotFoundException, InvalidTargetObjectTypeException {
if (resource == null)
throw new RuntimeOperationsException(new IllegalArgumentException(LocalizedStrings.MX4JModelMBean_MANAGED_RESOURCE_CANNOT_BE_NULL.toLocalizedString()));
if (!isResourceTypeSupported(resourceType))
throw new InvalidTargetObjectTypeException(resourceType);
Logger logger = getLogger();
if (logger.isEnabledFor(Logger.DEBUG))
logger.debug("Setting managed resource to be: " + resource);
m_managedResource = resource;
}
use of javax.management.RuntimeOperationsException in project jdk8u_jdk by JetBrains.
the class DefaultMBeanServerInterceptor method unregisterMBean.
public void unregisterMBean(ObjectName name) throws InstanceNotFoundException, MBeanRegistrationException {
if (name == null) {
final RuntimeException wrapped = new IllegalArgumentException("Object name cannot be null");
throw new RuntimeOperationsException(wrapped, "Exception occurred trying to unregister the MBean");
}
name = nonDefaultDomain(name);
synchronized (beingUnregistered) {
while (beingUnregistered.contains(name)) {
try {
beingUnregistered.wait();
} catch (InterruptedException e) {
throw new MBeanRegistrationException(e, e.toString());
// pretend the exception came from preDeregister;
// in another execution sequence it could have
}
}
beingUnregistered.add(name);
}
try {
exclusiveUnregisterMBean(name);
} finally {
synchronized (beingUnregistered) {
beingUnregistered.remove(name);
beingUnregistered.notifyAll();
}
}
}
use of javax.management.RuntimeOperationsException in project jdk8u_jdk by JetBrains.
the class DefaultMBeanServerInterceptor method setAttribute.
public void setAttribute(ObjectName name, Attribute attribute) throws InstanceNotFoundException, AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException {
if (name == null) {
throw new RuntimeOperationsException(new IllegalArgumentException("ObjectName name cannot be null"), "Exception occurred trying to invoke the setter on the MBean");
}
if (attribute == null) {
throw new RuntimeOperationsException(new IllegalArgumentException("Attribute cannot be null"), "Exception occurred trying to invoke the setter on the MBean");
}
name = nonDefaultDomain(name);
if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
MBEANSERVER_LOGGER.logp(Level.FINER, DefaultMBeanServerInterceptor.class.getName(), "setAttribute", "ObjectName = " + name + ", Attribute = " + attribute.getName());
}
DynamicMBean instance = getMBean(name);
checkMBeanPermission(instance, attribute.getName(), name, "setAttribute");
try {
instance.setAttribute(attribute);
} catch (AttributeNotFoundException e) {
throw e;
} catch (InvalidAttributeValueException e) {
throw e;
} catch (Throwable t) {
rethrowMaybeMBeanException(t);
throw new AssertionError();
}
}
use of javax.management.RuntimeOperationsException in project jdk8u_jdk by JetBrains.
the class MBeanInstantiator method loadClass.
/**
* Load a class with the specified loader, or with this object
* class loader if the specified loader is null.
**/
static Class<?> loadClass(String className, ClassLoader loader) 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 (loader == null)
loader = MBeanInstantiator.class.getClassLoader();
if (loader != null) {
theClass = Class.forName(className, false, loader);
} else {
theClass = Class.forName(className);
}
} catch (ClassNotFoundException e) {
throw new ReflectionException(e, "The MBean class could not be loaded");
}
return theClass;
}
use of javax.management.RuntimeOperationsException in project jdk8u_jdk by JetBrains.
the class MBeanInstantiator method deserialize.
/**
* De-serializes a byte array in the context of a classloader.
*
* @param loader the classloader to use for de-serialization
* @param data The byte array to be de-sererialized.
*
* @return The de-serialized object stream.
*
* @exception OperationsException Any of the usual Input/Output related
* exceptions.
*/
public ObjectInputStream deserialize(ClassLoader loader, byte[] data) throws OperationsException {
// Check parameter validity
if (data == null) {
throw new RuntimeOperationsException(new IllegalArgumentException(), "Null data passed in parameter");
}
if (data.length == 0) {
throw new RuntimeOperationsException(new IllegalArgumentException(), "Empty data passed in parameter");
}
// Object deserialization
ByteArrayInputStream bIn;
ObjectInputStream objIn;
bIn = new ByteArrayInputStream(data);
try {
objIn = new ObjectInputStreamWithLoader(bIn, loader);
} catch (IOException e) {
throw new OperationsException("An IOException occurred trying to de-serialize the data");
}
return objIn;
}
Aggregations