类javax.management.RuntimeOperationsException源码实例Demo

下面列出了怎么用javax.management.RuntimeOperationsException的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: dragonwell8_jdk   文件: RepositoryWildcardTest.java
private static int mbeanCreation(MBeanServer mbs, String name)
    throws Exception {
    int error = 0;
    try {
        System.out.println("Test: createMBean(" + name + ")");
        mbs.createMBean(classname, ObjectName.getInstance(name));
        error++;
        System.out.println("Didn't get expected exception!");
        System.out.println("Test failed!");
    } catch (RuntimeOperationsException e) {
        System.out.println("Got expected exception = " +
                           e.getCause().toString());
        System.out.println("Test passed!");
    }
    return error;
}
 
源代码2 项目: Tomcat8-Source-Read   文件: BaseModelMBean.java
/**
 * Send an <code>AttributeChangeNotification</code> to all registered
 * listeners.
 *
 * @param notification The <code>AttributeChangeNotification</code>
 *  that will be passed
 *
 * @exception MBeanException if an object initializer throws an
 *  exception
 * @exception RuntimeOperationsException wraps IllegalArgumentException
 *  when the specified notification is <code>null</code> or invalid
 */
@Override
public void sendAttributeChangeNotification
    (AttributeChangeNotification notification)
    throws MBeanException, RuntimeOperationsException {

    if (notification == null)
        throw new RuntimeOperationsException
            (new IllegalArgumentException("Notification is null"),
             "Notification is null");
    if (attributeBroadcaster == null)
        return; // This means there are no registered listeners
    if( log.isDebugEnabled() )
        log.debug( "AttributeChangeNotification " + notification );
    attributeBroadcaster.sendNotification(notification);

}
 
源代码3 项目: Tomcat8-Source-Read   文件: BaseModelMBean.java
/**
 * Send an <code>AttributeChangeNotification</code> to all registered
 * listeners.
 *
 * @param oldValue The original value of the <code>Attribute</code>
 * @param newValue The new value of the <code>Attribute</code>
 *
 * @exception MBeanException if an object initializer throws an
 *  exception
 * @exception RuntimeOperationsException wraps IllegalArgumentException
 *  when the specified notification is <code>null</code> or invalid
 */
@Override
public void sendAttributeChangeNotification
    (Attribute oldValue, Attribute newValue)
    throws MBeanException, RuntimeOperationsException {

    // Calculate the class name for the change notification
    String type = null;
    if (newValue.getValue() != null)
        type = newValue.getValue().getClass().getName();
    else if (oldValue.getValue() != null)
        type = oldValue.getValue().getClass().getName();
    else
        return;  // Old and new are both null == no change

    AttributeChangeNotification notification =
        new AttributeChangeNotification
        (this, 1, System.currentTimeMillis(),
         "Attribute value has changed",
         oldValue.getName(), type,
         oldValue.getValue(), newValue.getValue());
    sendAttributeChangeNotification(notification);

}
 
源代码4 项目: Tomcat8-Source-Read   文件: SlowQueryReportJmx.java
protected void notifyJmx(String query, String type) {
    try {
        long sequence = notifySequence.incrementAndGet();

        if (isNotifyPool()) {
            if (this.pool!=null && this.pool.getJmxPool()!=null) {
                this.pool.getJmxPool().notify(type, query);
            }
        } else {
            if (notifier!=null) {
                Notification notification =
                    new Notification(type,
                                     this,
                                     sequence,
                                     System.currentTimeMillis(),
                                     query);

                notifier.sendNotification(notification);
            }
        }
    } catch (RuntimeOperationsException e) {
        if (log.isDebugEnabled()) {
            log.debug("Unable to send failed query notification.",e);
        }
    }
}
 
源代码5 项目: dragonwell8_jdk   文件: MBeanServerDelegateImpl.java
/**
 * Always fails since the MBeanServerDelegate MBean has no operation.
 *
 * @param actionName The name of the action to be invoked.
 * @param params An array containing the parameters to be set when the
 *        action is invoked.
 * @param signature An array containing the signature of the action.
 *
 * @return  The object returned by the action, which represents
 *          the result of invoking the action on the MBean specified.
 *
 * @exception MBeanException  Wraps a <CODE>java.lang.Exception</CODE>
 *         thrown by the MBean's invoked method.
 * @exception ReflectionException  Wraps a
 *      <CODE>java.lang.Exception</CODE> thrown while trying to invoke
 *      the method.
 */
public Object invoke(String actionName, Object params[],
                     String signature[])
    throws MBeanException, ReflectionException {
    // Check that operation name is not null.
    //
    if (actionName == null) {
        final RuntimeException r =
          new IllegalArgumentException("Operation name  cannot be null");
        throw new RuntimeOperationsException(r,
        "Exception occurred trying to invoke the operation on the MBean");
    }

    throw new ReflectionException(
                      new NoSuchMethodException(actionName),
                      "The operation with name " + actionName +
                      " could not be found");
}
 
源代码6 项目: TencentKona-8   文件: MBeanInstantiator.java
/**
 * 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;
}
 
源代码7 项目: dragonwell8_jdk   文件: MBeanInstantiator.java
/**
 * Gets the class for the specified class name using the specified
 * class loader
 */
public Class<?> findClass(String className, ObjectName aLoader)
    throws ReflectionException, InstanceNotFoundException  {

    if (aLoader == null)
        throw new RuntimeOperationsException(new
            IllegalArgumentException(), "Null loader passed in parameter");

    // Retrieve the class loader from the repository
    ClassLoader loader = null;
    synchronized (this) {
        loader = getClassLoader(aLoader);
    }
    if (loader == null) {
        throw new InstanceNotFoundException("The loader named " +
                   aLoader + " is not registered in the MBeanServer");
    }
    return findClass(className,loader);
}
 
/**
 * 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;
}
 
/**
 * Gets the class for the specified class name using the specified
 * class loader
 */
public Class<?> findClass(String className, ObjectName aLoader)
    throws ReflectionException, InstanceNotFoundException  {

    if (aLoader == null)
        throw new RuntimeOperationsException(new
            IllegalArgumentException(), "Null loader passed in parameter");

    // Retrieve the class loader from the repository
    ClassLoader loader = null;
    synchronized (this) {
        loader = getClassLoader(aLoader);
    }
    if (loader == null) {
        throw new InstanceNotFoundException("The loader named " +
                   aLoader + " is not registered in the MBeanServer");
    }
    return findClass(className,loader);
}
 
源代码10 项目: jdk1.8-source-analysis   文件: MBeanInstantiator.java
/**
 * 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;
}
 
源代码11 项目: TencentKona-8   文件: RepositoryWildcardTest.java
private static int mbeanCreation(MBeanServer mbs, String name)
    throws Exception {
    int error = 0;
    try {
        System.out.println("Test: createMBean(" + name + ")");
        mbs.createMBean(classname, ObjectName.getInstance(name));
        error++;
        System.out.println("Didn't get expected exception!");
        System.out.println("Test failed!");
    } catch (RuntimeOperationsException e) {
        System.out.println("Got expected exception = " +
                           e.getCause().toString());
        System.out.println("Test passed!");
    }
    return error;
}
 
源代码12 项目: jdk1.8-source-analysis   文件: DescriptorSupport.java
/**
 * Descriptor constructor.  Takes as parameter the initial
 * capacity of the Map that stores the descriptor fields.
 * Capacity will grow as needed.<br> Note that the created empty
 * descriptor is not a valid descriptor (the method {@link
 * #isValid isValid} returns <CODE>false</CODE>).
 *
 * @param initNumFields The initial capacity of the Map that
 * stores the descriptor fields.
 *
 * @exception RuntimeOperationsException for illegal value for
 * initNumFields (&lt;= 0)
 * @exception MBeanException Wraps a distributed communication Exception.
 */
public DescriptorSupport(int initNumFields)
        throws MBeanException, RuntimeOperationsException {
    if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) {
        MODELMBEAN_LOGGER.logp(Level.FINEST,
                DescriptorSupport.class.getName(),
                "Descriptor(initNumFields = " + initNumFields + ")",
                "Constructor");
    }
    if (initNumFields <= 0) {
        if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) {
            MODELMBEAN_LOGGER.logp(Level.FINEST,
                    DescriptorSupport.class.getName(),
                    "Descriptor(initNumFields)",
                    "Illegal arguments: initNumFields <= 0");
        }
        final String msg =
            "Descriptor field limit invalid: " + initNumFields;
        final RuntimeException iae = new IllegalArgumentException(msg);
        throw new RuntimeOperationsException(iae, msg);
    }
    init(null);
}
 
源代码13 项目: jdk1.8-source-analysis   文件: DescriptorSupport.java
public synchronized Object getFieldValue(String fieldName)
        throws RuntimeOperationsException {

    if ((fieldName == null) || (fieldName.equals(""))) {
        if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) {
            MODELMBEAN_LOGGER.logp(Level.FINEST,
                    DescriptorSupport.class.getName(),
                    "getFieldValue(String fieldName)",
                    "Illegal arguments: null field name");
        }
        final String msg = "Fieldname requested is null";
        final RuntimeException iae = new IllegalArgumentException(msg);
        throw new RuntimeOperationsException(iae, msg);
    }
    Object retValue = descriptorMap.get(fieldName);
    if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) {
        MODELMBEAN_LOGGER.logp(Level.FINEST,
                DescriptorSupport.class.getName(),
                "getFieldValue(String fieldName = " + fieldName + ")",
                "Returns '" + retValue + "'");
    }
    return(retValue);
}
 
源代码14 项目: TencentKona-8   文件: MBeanInstantiator.java
/**
 * 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;
}
 
源代码15 项目: TencentKona-8   文件: MBeanServerDelegateImpl.java
/**
 * Always fails since the MBeanServerDelegate MBean has no operation.
 *
 * @param actionName The name of the action to be invoked.
 * @param params An array containing the parameters to be set when the
 *        action is invoked.
 * @param signature An array containing the signature of the action.
 *
 * @return  The object returned by the action, which represents
 *          the result of invoking the action on the MBean specified.
 *
 * @exception MBeanException  Wraps a <CODE>java.lang.Exception</CODE>
 *         thrown by the MBean's invoked method.
 * @exception ReflectionException  Wraps a
 *      <CODE>java.lang.Exception</CODE> thrown while trying to invoke
 *      the method.
 */
public Object invoke(String actionName, Object params[],
                     String signature[])
    throws MBeanException, ReflectionException {
    // Check that operation name is not null.
    //
    if (actionName == null) {
        final RuntimeException r =
          new IllegalArgumentException("Operation name  cannot be null");
        throw new RuntimeOperationsException(r,
        "Exception occurred trying to invoke the operation on the MBean");
    }

    throw new ReflectionException(
                      new NoSuchMethodException(actionName),
                      "The operation with name " + actionName +
                      " could not be found");
}
 
源代码16 项目: kogito-runtimes   文件: KnowledgeBaseMonitoring.java
public Object getAttribute(String attributeName) throws AttributeNotFoundException,
                                                MBeanException,
                                                ReflectionException {
    if ( attributeName == null ) {
        throw new RuntimeOperationsException( new IllegalArgumentException( "attributeName cannot be null" ),
                                              "Cannot invoke a getter of " + getClass().getName() );
    } else if ( attributeName.equals( ATTR_ID ) ) {
        return getId();
    } else if ( attributeName.equals( ATTR_SESSION_COUNT ) ) {
        return Long.valueOf( getSessionCount() );
    } else if ( attributeName.equals( ATTR_GLOBALS ) ) {
        try {
            return getGlobals();
        } catch ( OpenDataException e ) {
            throw new RuntimeOperationsException( new RuntimeException( "Error retrieving globals list",
                                                                        e ),
                                                  "Error retrieving globals list " + e.getMessage() );
        }
    } else if ( attributeName.equals( ATTR_PACKAGES ) ) {
        return getPackages();
    }
    throw new AttributeNotFoundException( "Cannot find " + attributeName + " attribute " );
}
 
源代码17 项目: TencentKona-8   文件: DescriptorSupport.java
/**
 * Descriptor constructor.  Takes as parameter the initial
 * capacity of the Map that stores the descriptor fields.
 * Capacity will grow as needed.<br> Note that the created empty
 * descriptor is not a valid descriptor (the method {@link
 * #isValid isValid} returns <CODE>false</CODE>).
 *
 * @param initNumFields The initial capacity of the Map that
 * stores the descriptor fields.
 *
 * @exception RuntimeOperationsException for illegal value for
 * initNumFields (&lt;= 0)
 * @exception MBeanException Wraps a distributed communication Exception.
 */
public DescriptorSupport(int initNumFields)
        throws MBeanException, RuntimeOperationsException {
    if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) {
        MODELMBEAN_LOGGER.logp(Level.FINEST,
                DescriptorSupport.class.getName(),
                "Descriptor(initNumFields = " + initNumFields + ")",
                "Constructor");
    }
    if (initNumFields <= 0) {
        if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) {
            MODELMBEAN_LOGGER.logp(Level.FINEST,
                    DescriptorSupport.class.getName(),
                    "Descriptor(initNumFields)",
                    "Illegal arguments: initNumFields <= 0");
        }
        final String msg =
            "Descriptor field limit invalid: " + initNumFields;
        final RuntimeException iae = new IllegalArgumentException(msg);
        throw new RuntimeOperationsException(iae, msg);
    }
    init(null);
}
 
源代码18 项目: dragonwell8_jdk   文件: MBeanInstantiator.java
/**
 * 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;
}
 
/**
 * Obtain and return the value of a specific attribute of this MBean.
 *
 * @param name Name of the requested attribute
 *
 * @exception AttributeNotFoundException if this attribute is not
 *  supported by this MBean
 * @exception MBeanException if the initializer of an object
 *  throws an exception
 * @exception ReflectionException if a Java reflection exception
 *  occurs when invoking the getter
 */
@Override
public Object getAttribute(String name) throws AttributeNotFoundException, MBeanException,
        ReflectionException {

    // Validate the input parameters
    if (name == null) {
        throw new RuntimeOperationsException(
                new IllegalArgumentException("Attribute name is null"),
                "Attribute name is null");
    }

    ContextResourceLink cl = doGetManagedResource();

    String value = null;
    if ("global".equals(name)) {
        return cl.getGlobal();
    } else if ("description".equals(name)) {
        return cl.getDescription();
    } else if ("name".equals(name)) {
        return cl.getName();
    } else if ("type".equals(name)) {
        return cl.getType();
    } else {
        value = (String) cl.getProperty(name);
        if (value == null) {
            throw new AttributeNotFoundException("Cannot find attribute [" + name + "]");
        }
    }

    return value;
}
 
/**
 * Set the value of a specific attribute of this MBean.
 *
 * @param attribute The identification of the attribute to be set
 *  and the new value
 *
 * @exception AttributeNotFoundException if this attribute is not
 *  supported by this MBean
 * @exception MBeanException if the initializer of an object
 *  throws an exception
 * @exception ReflectionException if a Java reflection exception
 *  occurs when invoking the getter
 */
 @Override
public void setAttribute(Attribute attribute) throws AttributeNotFoundException, MBeanException,
        ReflectionException {

    // Validate the input parameters
    if (attribute == null) {
        throw new RuntimeOperationsException(
                new IllegalArgumentException("Attribute is null"),
                "Attribute is null");
    }

    String name = attribute.getName();
    Object value = attribute.getValue();
    if (name == null) {
        throw new RuntimeOperationsException(
                new IllegalArgumentException("Attribute name is null"),
                "Attribute name is null");
    }

    ContextResourceLink crl = doGetManagedResource();

    if ("global".equals(name)) {
        crl.setGlobal((String) value);
    } else if ("description".equals(name)) {
        crl.setDescription((String) value);
    } else if ("name".equals(name)) {
        crl.setName((String) value);
    } else if ("type".equals(name)) {
        crl.setType((String) value);
    } else {
        crl.setProperty(name, "" + value);
    }

    // cannot use side-effects.  It's removed and added back each time
    // there is a modification in a resource.
    NamingResources nr = crl.getNamingResources();
    nr.removeResourceLink(crl.getName());
    nr.addResourceLink(crl);
}
 
源代码21 项目: Tomcat8-Source-Read   文件: BaseCatalinaMBean.java
protected T doGetManagedResource() throws MBeanException {
    try {
        @SuppressWarnings("unchecked")
        T resource = (T) getManagedResource();
        return resource;
    } catch (InstanceNotFoundException | RuntimeOperationsException |
            InvalidTargetObjectTypeException e) {
        throw new MBeanException(e);
    }
}
 
源代码22 项目: Tomcat8-Source-Read   文件: ContextResourceMBean.java
/**
 * Obtain and return the value of a specific attribute of this MBean.
 *
 * @param name Name of the requested attribute
 *
 * @exception AttributeNotFoundException if this attribute is not
 *  supported by this MBean
 * @exception MBeanException if the initializer of an object
 *  throws an exception
 * @exception ReflectionException if a Java reflection exception
 *  occurs when invoking the getter
 */
@Override
public Object getAttribute(String name) throws AttributeNotFoundException, MBeanException,
        ReflectionException {

    // Validate the input parameters
    if (name == null) {
        throw new RuntimeOperationsException(
                new IllegalArgumentException("Attribute name is null"),
                "Attribute name is null");
    }

    ContextResource cr = doGetManagedResource();

    String value = null;
    if ("auth".equals(name)) {
        return cr.getAuth();
    } else if ("description".equals(name)) {
        return cr.getDescription();
    } else if ("name".equals(name)) {
        return cr.getName();
    } else if ("scope".equals(name)) {
        return cr.getScope();
    } else if ("type".equals(name)) {
        return cr.getType();
    } else {
        value = (String) cr.getProperty(name);
        if (value == null) {
            throw new AttributeNotFoundException
                ("Cannot find attribute [" + name + "]");
        }
    }

    return value;
}
 
源代码23 项目: Tomcat8-Source-Read   文件: BaseModelMBean.java
/**
     * Set the instance handle of the object against which we will execute
     * all methods in this ModelMBean management interface.
     *
     * The caller can provide the mbean instance or the object name to
     * the resource, if needed.
     *
     * @param resource The resource object to be managed
     * @param type The type of reference for the managed resource
     *  ("ObjectReference", "Handle", "IOR", "EJBHandle", or
     *  "RMIReference")
     *
     * @exception InstanceNotFoundException if the managed resource object
     *  cannot be found
     * @exception MBeanException if the initializer of the object throws
     *  an exception
     * @exception RuntimeOperationsException if the managed resource or the
     *  resource type is <code>null</code> or invalid
     */
    public void setManagedResource(Object resource, String type)
        throws InstanceNotFoundException,
        MBeanException, RuntimeOperationsException
    {
        if (resource == null)
            throw new RuntimeOperationsException
                (new IllegalArgumentException("Managed resource is null"),
                 "Managed resource is null");

//        if (!"objectreference".equalsIgnoreCase(type))
//            throw new InvalidTargetObjectTypeException(type);

        this.resource = resource;
        this.resourceType = resource.getClass().getName();

//        // Make the resource aware of the model mbean.
//        try {
//            Method m=resource.getClass().getMethod("setModelMBean",
//                    new Class[] {ModelMBean.class});
//            if( m!= null ) {
//                m.invoke(resource, new Object[] {this});
//            }
//        } catch( NoSuchMethodException t ) {
//            // ignore
//        } catch( Throwable t ) {
//            log.error( "Can't set model mbean ", t );
//        }
    }
 
源代码24 项目: TencentKona-8   文件: ModelMBeanInfoSupport.java
public void setMBeanDescriptor(Descriptor inMBeanDescriptor)
throws MBeanException, RuntimeOperationsException {
    if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
        MODELMBEAN_LOGGER.logp(Level.FINER,
                ModelMBeanInfoSupport.class.getName(),
                "setMBeanDescriptor(Descriptor)", "Entry");
    }
    modelMBeanDescriptor = validDescriptor(inMBeanDescriptor);
}
 
源代码25 项目: TencentKona-8   文件: ModelMBeanInfoSupport.java
public ModelMBeanOperationInfo getOperation(String inName)
throws MBeanException, RuntimeOperationsException {
    ModelMBeanOperationInfo retInfo = null;
    if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
        MODELMBEAN_LOGGER.logp(Level.FINER,
                ModelMBeanInfoSupport.class.getName(),
                "getOperation(String)", "Entry");
    }
    if (inName == null) {
        throw new RuntimeOperationsException(
                new IllegalArgumentException("inName is null"),
                "Exception occurred trying to get the " +
                "ModelMBeanOperationInfo of the MBean");
    }
    MBeanOperationInfo[] operList = modelMBeanOperations; //this.getOperations();
    int numOpers = 0;
    if (operList != null) numOpers = operList.length;

    for (int i=0; (i < numOpers) && (retInfo == null); i++) {
        if (inName.equals(operList[i].getName())) {
            retInfo = ((ModelMBeanOperationInfo) operList[i].clone());
        }
    }
    if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
        MODELMBEAN_LOGGER.logp(Level.FINER,
                ModelMBeanInfoSupport.class.getName(),
                "getOperation(String)", "Exit");
    }

    return retInfo;
}
 
源代码26 项目: dragonwell8_jdk   文件: RequiredModelMBean.java
/**
 * Sets the values of an array of attributes of this ModelMBean.
 * Executes the setAttribute() method for each attribute in the list.
 *
 * @param attributes A list of attributes: The identification of the
 * attributes to be set and  the values they are to be set to.
 *
 * @return  The array of attributes that were set, with their new
 *    values in Attribute instances.
 *
 * @exception RuntimeOperationsException Wraps an
 *   {@link IllegalArgumentException}: The object name in parameter
 *   is null or attributes in parameter is null.
 *
 * @see #getAttributes
 **/
public AttributeList setAttributes(AttributeList attributes) {

    if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
        MODELMBEAN_LOGGER.logp(Level.FINER,
                RequiredModelMBean.class.getName(),
            "setAttribute(Attribute)", "Entry");
    }

    if (attributes == null)
        throw new RuntimeOperationsException(new
            IllegalArgumentException("attributes must not be null"),
            "Exception occurred trying to set attributes of a "+
            "RequiredModelMBean");

    final AttributeList responseList = new AttributeList();

    // Go through the list of attributes
    for (Attribute attr : attributes.asList()) {
        try {
            setAttribute(attr);
            responseList.add(attr);
        } catch (Exception excep) {
            responseList.remove(attr);
        }
    }

    return responseList;
}
 
public boolean isRegistered(ObjectName name) {
    if (name == null) {
        throw new RuntimeOperationsException(
                 new IllegalArgumentException("Object name cannot be null"),
                 "Object name cannot be null");
    }

    name = nonDefaultDomain(name);

    /* No Permission check */
    // isRegistered is always unchecked as per JMX spec.

    return (repository.contains(name));
}
 
源代码28 项目: TencentKona-8   文件: ModelMBeanInfoSupport.java
public ModelMBeanNotificationInfo getNotification(String inName)
throws MBeanException, RuntimeOperationsException {
    ModelMBeanNotificationInfo retInfo = null;
    if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
        MODELMBEAN_LOGGER.logp(Level.FINER,
                ModelMBeanInfoSupport.class.getName(),
                "getNotification(String)", "Entry");
    }
    if (inName == null) {
        throw new RuntimeOperationsException(
                new IllegalArgumentException("Notification name is null"),
                "Exception occurred trying to get the " +
                "ModelMBeanNotificationInfo of the MBean");
    }
    MBeanNotificationInfo[] notifList = modelMBeanNotifications; //this.getNotifications();
    int numNotifs = 0;
    if (notifList != null) numNotifs = notifList.length;

    for (int i=0; (i < numNotifs) && (retInfo == null); i++) {
        if (inName.equals(notifList[i].getName())) {
            retInfo = ((ModelMBeanNotificationInfo) notifList[i].clone());
        }
    }
    if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
        MODELMBEAN_LOGGER.logp(Level.FINER,
                ModelMBeanInfoSupport.class.getName(),
                "getNotification(String)", "Exit");
    }

    return retInfo;
}
 
public void addNotificationListener(ObjectName name,
                                    NotificationListener listener,
                                    NotificationFilter filter,
                                    Object handback)
        throws InstanceNotFoundException {

    // ------------------------------
    // ------------------------------
    if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
        MBEANSERVER_LOGGER.logp(Level.FINER,
                DefaultMBeanServerInterceptor.class.getName(),
                "addNotificationListener", "ObjectName = " + name);
    }

    DynamicMBean instance = getMBean(name);
    checkMBeanPermission(instance, null, name, "addNotificationListener");

    NotificationBroadcaster broadcaster =
            getNotificationBroadcaster(name, instance,
                                       NotificationBroadcaster.class);

    // ------------------
    // Check listener
    // ------------------
    if (listener == null) {
        throw new RuntimeOperationsException(new
            IllegalArgumentException("Null listener"),"Null listener");
    }

    NotificationListener listenerWrapper =
        getListenerWrapper(listener, name, instance, true);
    broadcaster.addNotificationListener(listenerWrapper, filter, handback);
}
 
源代码30 项目: TencentKona-8   文件: DescriptorSupport.java
/**
 * Constructor taking field names and field values.  Neither array
 * can be null.
 *
 * @param fieldNames String array of field names.  No elements of
 * this array can be null.
 * @param fieldValues Object array of the corresponding field
 * values.  Elements of the array can be null. The
 * <code>fieldValue</code> must be valid for the
 * <code>fieldName</code> (as defined in method {@link #isValid
 * isValid})
 *
 * <p>Note: array sizes of parameters should match. If both arrays
 * are empty, then an empty descriptor is created.</p>
 *
 * @exception RuntimeOperationsException for illegal value for
 * field Names or field Values.  The array lengths must be equal.
 * If the descriptor construction fails for any reason, this
 * exception will be thrown.
 *
 */
public DescriptorSupport(String[] fieldNames, Object[] fieldValues)
        throws RuntimeOperationsException {
    if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) {
        MODELMBEAN_LOGGER.logp(Level.FINEST,
                DescriptorSupport.class.getName(),
                "Descriptor(fieldNames,fieldObjects)", "Constructor");
    }

    if ((fieldNames == null) || (fieldValues == null) ||
        (fieldNames.length != fieldValues.length)) {
        if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) {
            MODELMBEAN_LOGGER.logp(Level.FINEST,
                    DescriptorSupport.class.getName(),
                    "Descriptor(fieldNames,fieldObjects)",
                    "Illegal arguments");
        }

        final String msg =
            "Null or invalid fieldNames or fieldValues";
        final RuntimeException iae = new IllegalArgumentException(msg);
        throw new RuntimeOperationsException(iae, msg);
    }

    /* populate internal structure with fields */
    init(null);
    for (int i=0; i < fieldNames.length; i++) {
        // setField will throw an exception if a fieldName is be null.
        // the fieldName and fieldValue will be validated in setField.
        setField(fieldNames[i], fieldValues[i]);
    }
    if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) {
        MODELMBEAN_LOGGER.logp(Level.FINEST,
                DescriptorSupport.class.getName(),
                "Descriptor(fieldNames,fieldObjects)", "Exit");
    }
}
 
 类所在包
 同包方法