Search in sources :

Example 16 with RuntimeOperationsException

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;
}
Also used : InvalidTargetObjectTypeException(javax.management.modelmbean.InvalidTargetObjectTypeException) Logger(mx4j.log.Logger) FileLogger(mx4j.log.FileLogger) MBeanLogger(mx4j.log.MBeanLogger) RuntimeOperationsException(javax.management.RuntimeOperationsException)

Example 17 with RuntimeOperationsException

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();
        }
    }
}
Also used : JMRuntimeException(javax.management.JMRuntimeException) MBeanRegistrationException(javax.management.MBeanRegistrationException) RuntimeOperationsException(javax.management.RuntimeOperationsException)

Example 18 with RuntimeOperationsException

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();
    }
}
Also used : DynamicMBean(javax.management.DynamicMBean) AttributeNotFoundException(javax.management.AttributeNotFoundException) InvalidAttributeValueException(javax.management.InvalidAttributeValueException) RuntimeOperationsException(javax.management.RuntimeOperationsException)

Example 19 with RuntimeOperationsException

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;
}
Also used : ReflectionException(javax.management.ReflectionException) RuntimeOperationsException(javax.management.RuntimeOperationsException)

Example 20 with RuntimeOperationsException

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;
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) IOException(java.io.IOException) RuntimeOperationsException(javax.management.RuntimeOperationsException) ObjectInputStream(java.io.ObjectInputStream) OperationsException(javax.management.OperationsException) RuntimeOperationsException(javax.management.RuntimeOperationsException)

Aggregations

RuntimeOperationsException (javax.management.RuntimeOperationsException)67 AttributeNotFoundException (javax.management.AttributeNotFoundException)23 InstanceNotFoundException (javax.management.InstanceNotFoundException)20 ReflectionException (javax.management.ReflectionException)20 MBeanException (javax.management.MBeanException)18 Descriptor (javax.management.Descriptor)17 InvalidAttributeValueException (javax.management.InvalidAttributeValueException)16 ListenerNotFoundException (javax.management.ListenerNotFoundException)16 RuntimeErrorException (javax.management.RuntimeErrorException)14 InvocationTargetException (java.lang.reflect.InvocationTargetException)13 ServiceNotFoundException (javax.management.ServiceNotFoundException)13 DynamicMBean (javax.management.DynamicMBean)10 FileLogger (mx4j.log.FileLogger)10 Logger (mx4j.log.Logger)10 MBeanLogger (mx4j.log.MBeanLogger)10 MBeanRegistrationException (javax.management.MBeanRegistrationException)9 JMRuntimeException (javax.management.JMRuntimeException)8 InvalidTargetObjectTypeException (javax.management.modelmbean.InvalidTargetObjectTypeException)8 Attribute (javax.management.Attribute)7 Date (java.util.Date)6