Search in sources :

Example 21 with RuntimeOperationsException

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

Example 22 with RuntimeOperationsException

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);
}
Also used : JMRuntimeException(javax.management.JMRuntimeException) ModifiableClassLoaderRepository(com.sun.jmx.mbeanserver.ModifiableClassLoaderRepository) RuntimeOperationsException(javax.management.RuntimeOperationsException)

Example 23 with RuntimeOperationsException

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

Example 24 with RuntimeOperationsException

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

Example 25 with RuntimeOperationsException

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");
    }
}
Also used : ListenerNotFoundException(javax.management.ListenerNotFoundException) MBeanAttributeInfo(javax.management.MBeanAttributeInfo) 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