Search in sources :

Example 26 with ReflectionException

use of javax.management.ReflectionException 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 27 with ReflectionException

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

Example 28 with ReflectionException

use of javax.management.ReflectionException in project jdk8u_jdk by JetBrains.

the class SnmpGenericObjectServer method set.

/**
     * Set the value of an SNMP variable.
     *
     * <p><b><i>
     * You should never need to use this method directly.
     * </i></b></p>
     *
     * @param meta  The impacted metadata object
     * @param name  The ObjectName of the impacted MBean
     * @param x     The new requested SnmpValue
     * @param id    The OID arc identifying the variable we're trying to set.
     * @param data  User contextual data allocated through the
     *        {@link com.sun.jmx.snmp.agent.SnmpUserDataFactory}
     *
     * @return The new value of the variable after the operation.
     *
     * @exception SnmpStatusException whenever an SNMP exception must be
     *      raised. Raising an exception will abort the request. <br>
     *      Exceptions should never be raised directly, but only by means of
     * <code>
     * req.registerSetException(<i>VariableId</i>,<i>SnmpStatusException</i>)
     * </code>
     **/
public SnmpValue set(SnmpGenericMetaServer meta, ObjectName name, SnmpValue x, long id, Object data) throws SnmpStatusException {
    final String attname = meta.getAttributeName(id);
    final Object attvalue = meta.buildAttributeValue(id, x);
    final Attribute att = new Attribute(attname, attvalue);
    Object result = null;
    try {
        server.setAttribute(name, att);
        result = server.getAttribute(name, attname);
    } catch (InvalidAttributeValueException iv) {
        throw new SnmpStatusException(SnmpStatusException.snmpRspWrongValue);
    } catch (InstanceNotFoundException f) {
        throw new SnmpStatusException(SnmpStatusException.snmpRspInconsistentName);
    } catch (ReflectionException r) {
        throw new SnmpStatusException(SnmpStatusException.snmpRspInconsistentName);
    } catch (MBeanException m) {
        Exception t = m.getTargetException();
        if (t instanceof SnmpStatusException)
            throw (SnmpStatusException) t;
        throw new SnmpStatusException(SnmpStatusException.noAccess);
    } catch (Exception e) {
        throw new SnmpStatusException(SnmpStatusException.noAccess);
    }
    return meta.buildSnmpValue(id, result);
}
Also used : SnmpStatusException(com.sun.jmx.snmp.SnmpStatusException) ReflectionException(javax.management.ReflectionException) Attribute(javax.management.Attribute) InstanceNotFoundException(javax.management.InstanceNotFoundException) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) MBeanException(javax.management.MBeanException) InvalidAttributeValueException(javax.management.InvalidAttributeValueException) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) MBeanException(javax.management.MBeanException) InvalidAttributeValueException(javax.management.InvalidAttributeValueException) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) SnmpStatusException(com.sun.jmx.snmp.SnmpStatusException) MBeanRegistrationException(javax.management.MBeanRegistrationException) InstanceNotFoundException(javax.management.InstanceNotFoundException) ReflectionException(javax.management.ReflectionException) RuntimeOperationsException(javax.management.RuntimeOperationsException)

Example 29 with ReflectionException

use of javax.management.ReflectionException in project jdk8u_jdk by JetBrains.

the class SnmpGenericObjectServer method check.

/**
     * Checks whether a SET operation can be performed on a given SNMP
     * variable.
     *
     * @param meta  The impacted metadata object
     * @param name  The ObjectName of the impacted MBean
     * @param x     The new requested SnmpValue
     * @param id    The OID arc identifying the variable we're trying to set.
     * @param data  User contextual data allocated through the
     *        {@link com.sun.jmx.snmp.agent.SnmpUserDataFactory}
     *
     * <p>
     * This method calls checkSetAccess() on the meta object, and then
     * tries to invoke the check<i>AttributeName</i>() method on the MBean.
     * If this method is not defined then it is assumed that the SET
     * won't fail.
     * </p>
     *
     * <p><b><i>
     * This method is called internally by <code>mibgen</code> generated
     * objects and you should never need to call it directly.
     * </i></b></p>
     *
     * @exception SnmpStatusException if the requested SET operation must
     *      be rejected. Raising an exception will abort the request. <br>
     *      Exceptions should never be raised directly, but only by means of
     * <code>
     * req.registerCheckException(<i>VariableId</i>,<i>SnmpStatusException</i>)
     * </code>
     *
     **/
// XXX xxx ZZZ zzz Maybe we should go through the MBeanInfo here?
public void check(SnmpGenericMetaServer meta, ObjectName name, SnmpValue x, long id, Object data) throws SnmpStatusException {
    meta.checkSetAccess(x, id, data);
    try {
        final String attname = meta.getAttributeName(id);
        final Object attvalue = meta.buildAttributeValue(id, x);
        final Object[] params = new Object[1];
        final String[] signature = new String[1];
        params[0] = attvalue;
        signature[0] = attvalue.getClass().getName();
        server.invoke(name, "check" + attname, params, signature);
    } catch (SnmpStatusException e) {
        throw e;
    } catch (InstanceNotFoundException i) {
        throw new SnmpStatusException(SnmpStatusException.snmpRspInconsistentName);
    } catch (ReflectionException r) {
    // checkXXXX() not defined => do nothing
    } catch (MBeanException m) {
        Exception t = m.getTargetException();
        if (t instanceof SnmpStatusException)
            throw (SnmpStatusException) t;
        throw new SnmpStatusException(SnmpStatusException.noAccess);
    } catch (Exception e) {
        throw new SnmpStatusException(SnmpStatusException.noAccess);
    }
}
Also used : SnmpStatusException(com.sun.jmx.snmp.SnmpStatusException) ReflectionException(javax.management.ReflectionException) InstanceNotFoundException(javax.management.InstanceNotFoundException) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) MBeanException(javax.management.MBeanException) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) MBeanException(javax.management.MBeanException) InvalidAttributeValueException(javax.management.InvalidAttributeValueException) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) SnmpStatusException(com.sun.jmx.snmp.SnmpStatusException) MBeanRegistrationException(javax.management.MBeanRegistrationException) InstanceNotFoundException(javax.management.InstanceNotFoundException) ReflectionException(javax.management.ReflectionException) RuntimeOperationsException(javax.management.RuntimeOperationsException)

Example 30 with ReflectionException

use of javax.management.ReflectionException in project jdk8u_jdk by JetBrains.

the class SnmpMibAgent method setSnmpAdaptorName.

/**
     * Sets the reference to the SNMP protocol adaptor through which the MIB
     * will be SNMP accessible and add this new MIB in the SNMP MIB handler
     * associated to the specified <CODE>name</CODE>.
     *
     * @param name The name of the SNMP protocol adaptor.
     *
     * @exception InstanceNotFoundException The SNMP protocol adaptor does
     *     not exist in the MBean server.
     *
     * @exception ServiceNotFoundException This SNMP MIB is not registered
     *     in the MBean server or the requested service is not supported.
     */
@Override
public void setSnmpAdaptorName(ObjectName name) throws InstanceNotFoundException, ServiceNotFoundException {
    if (server == null) {
        throw new ServiceNotFoundException(mibName + " is not registered in the MBean server");
    }
    //
    if (adaptor != null) {
        adaptor.removeMib(this);
    }
    // Then update the reference to the new adaptor server.
    //
    Object[] params = { this };
    String[] signature = { "com.sun.jmx.snmp.agent.SnmpMibAgent" };
    try {
        adaptor = (SnmpMibHandler) (server.invoke(name, "addMib", params, signature));
    } catch (InstanceNotFoundException e) {
        throw new InstanceNotFoundException(name.toString());
    } catch (ReflectionException e) {
        throw new ServiceNotFoundException(name.toString());
    } catch (MBeanException e) {
    // Should never occur...
    }
    adaptorName = name;
}
Also used : ReflectionException(javax.management.ReflectionException) ServiceNotFoundException(javax.management.ServiceNotFoundException) InstanceNotFoundException(javax.management.InstanceNotFoundException) MBeanException(javax.management.MBeanException)

Aggregations

ReflectionException (javax.management.ReflectionException)72 InstanceNotFoundException (javax.management.InstanceNotFoundException)50 MBeanException (javax.management.MBeanException)46 AttributeNotFoundException (javax.management.AttributeNotFoundException)31 InvalidAttributeValueException (javax.management.InvalidAttributeValueException)23 ObjectName (javax.management.ObjectName)22 Attribute (javax.management.Attribute)19 RuntimeOperationsException (javax.management.RuntimeOperationsException)17 InvocationTargetException (java.lang.reflect.InvocationTargetException)16 IntrospectionException (javax.management.IntrospectionException)13 Method (java.lang.reflect.Method)12 AttributeList (javax.management.AttributeList)12 ServiceNotFoundException (javax.management.ServiceNotFoundException)12 IOException (java.io.IOException)11 MBeanInfo (javax.management.MBeanInfo)11 RuntimeErrorException (javax.management.RuntimeErrorException)11 MalformedObjectNameException (javax.management.MalformedObjectNameException)10 ListenerNotFoundException (javax.management.ListenerNotFoundException)9 MBeanAttributeInfo (javax.management.MBeanAttributeInfo)9 MBeanRegistrationException (javax.management.MBeanRegistrationException)9