java类javax.management.RuntimeOperationsException的实例源码

DefaultMBeanServerInterceptor.java 文件源码 项目:OpenJSharp 阅读 21 收藏 0 点赞 0 评论 0
public Object getAttribute(ObjectName name, String attribute)
    throws MBeanException, AttributeNotFoundException,
           InstanceNotFoundException, ReflectionException {

    if (name == null) {
        throw new RuntimeOperationsException(new
            IllegalArgumentException("Object name cannot be null"),
            "Exception occurred trying to invoke the getter on the MBean");
    }
    if (attribute == null) {
        throw new RuntimeOperationsException(new
            IllegalArgumentException("Attribute 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(),
                "getAttribute",
                "Attribute = " + attribute + ", ObjectName = " + name);
    }

    final DynamicMBean instance = getMBean(name);
    checkMBeanPermission(instance, attribute, name, "getAttribute");

    try {
        return instance.getAttribute(attribute);
    } catch (AttributeNotFoundException e) {
        throw e;
    } catch (Throwable t) {
        rethrowMaybeMBeanException(t);
        throw new AssertionError(); // not reached
    }
}
ModelMBeanInfoSupport.java 文件源码 项目:openjdk-jdk10 阅读 24 收藏 0 点赞 0 评论 0
public ModelMBeanAttributeInfo getAttribute(String inName)
throws MBeanException, RuntimeOperationsException {
    ModelMBeanAttributeInfo retInfo = null;
    if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
        MODELMBEAN_LOGGER.log(Level.TRACE, "Entry");
    }
    if (inName == null) {
        throw new RuntimeOperationsException(
                new IllegalArgumentException("Attribute Name is null"),
                "Exception occurred trying to get the " +
                "ModelMBeanAttributeInfo of the MBean");
    }
    MBeanAttributeInfo[] attrList = modelMBeanAttributes;
    int numAttrs = 0;
    if (attrList != null) numAttrs = attrList.length;

    for (int i=0; (i < numAttrs) && (retInfo == null); i++) {
        if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
            final StringBuilder strb = new StringBuilder()
            .append("\t\n this.getAttributes() MBeanAttributeInfo Array ")
            .append(i).append(":")
            .append(((ModelMBeanAttributeInfo)attrList[i]).getDescriptor())
            .append("\t\n this.modelMBeanAttributes MBeanAttributeInfo Array ")
            .append(i).append(":")
            .append(((ModelMBeanAttributeInfo)modelMBeanAttributes[i]).getDescriptor());
            MODELMBEAN_LOGGER.log(Level.TRACE, strb::toString);
        }
        if (inName.equals(attrList[i].getName())) {
            retInfo = ((ModelMBeanAttributeInfo)attrList[i].clone());
        }
    }
    if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
        MODELMBEAN_LOGGER.log(Level.TRACE, "Exit");
    }

    return retInfo;
}
DefaultMBeanServerInterceptor.java 文件源码 项目:OpenJSharp 阅读 20 收藏 0 点赞 0 评论 0
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);
}
DefaultMBeanServerInterceptor.java 文件源码 项目:OpenJSharp 阅读 24 收藏 0 点赞 0 评论 0
public void addNotificationListener(ObjectName name,
                                    ObjectName listener,
                                    NotificationFilter filter,
                                    Object handback)
        throws InstanceNotFoundException {

    // ------------------------------
    // ------------------------------

    // ----------------
    // Get listener object
    // ----------------
    DynamicMBean instance = getMBean(listener);
    Object resource = getResource(instance);
    if (!(resource instanceof NotificationListener)) {
        throw new RuntimeOperationsException(new
            IllegalArgumentException(listener.getCanonicalName()),
            "The MBean " + listener.getCanonicalName() +
            "does not implement the NotificationListener interface") ;
    }

    // ----------------
    // Add a listener on an MBean
    // ----------------
    if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
        MBEANSERVER_LOGGER.logp(Level.FINER,
                DefaultMBeanServerInterceptor.class.getName(),
                "addNotificationListener",
                "ObjectName = " + name + ", Listener = " + listener);
    }
    server.addNotificationListener(name,(NotificationListener) resource,
                                   filter, handback) ;
}
MBeanServerDelegateImpl.java 文件源码 项目:OpenJSharp 阅读 25 收藏 0 点赞 0 评论 0
/**
 * This method always fail since all MBeanServerDelegateMBean attributes
 * are read-only.
 *
 * @param attribute The identification of the attribute to
 * be set and  the value it is to be set to.
 *
 * @exception AttributeNotFoundException
 */
public void setAttribute(Attribute attribute)
    throws AttributeNotFoundException, InvalidAttributeValueException,
           MBeanException, ReflectionException {

    // Now we will always fail:
    // Either because the attribute is null or because it is not
    // accessible (or does not exist).
    //
    final String attname = (attribute==null?null:attribute.getName());
    if (attname == null) {
        final RuntimeException r =
            new IllegalArgumentException("Attribute name cannot be null");
        throw new RuntimeOperationsException(r,
            "Exception occurred trying to invoke the setter on the MBean");
    }

    // This is a hack: we call getAttribute in order to generate an
    // AttributeNotFoundException if the attribute does not exist.
    //
    Object val = getAttribute(attname);

    // If we reach this point, we know that the requested attribute
    // exists. However, since all attributes are read-only, we throw
    // an AttributeNotFoundException.
    //
    throw new AttributeNotFoundException(attname + " not accessible");
}
DescriptorSupport.java 文件源码 项目:OpenJSharp 阅读 16 收藏 0 点赞 0 评论 0
/**
 * 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");
    }
}
MX4JModelMBean.java 文件源码 项目:monarch 阅读 21 收藏 0 点赞 0 评论 0
public MX4JModelMBean() throws MBeanException, RuntimeOperationsException {
  try {
    load();
  } catch (Exception x) {
    Logger logger = getLogger();
    logger.warn(LocalizedStrings.MX4JModelMBean_CANNOT_RESTORE_PREVIOUSLY_SAVED_STATUS
        .toLocalizedString(), x);
  }
}
ModelMBeanInfoSupport.java 文件源码 项目:OpenJSharp 阅读 19 收藏 0 点赞 0 评论 0
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;
}
ModelMBeanInfoSupport.java 文件源码 项目:OpenJSharp 阅读 24 收藏 0 点赞 0 评论 0
/**
 * Returns the ModelMBeanConstructorInfo requested by name.
 * If no ModelMBeanConstructorInfo exists for this name null is returned.
 *
 * @param inName the name of the constructor.
 *
 * @return the constructor info for the named constructor, or null
 * if there is none.
 *
 * @exception MBeanException Wraps a distributed communication Exception.
 * @exception RuntimeOperationsException Wraps an IllegalArgumentException
 *            for a null constructor name.
 */

public ModelMBeanConstructorInfo getConstructor(String inName)
throws MBeanException, RuntimeOperationsException {
    ModelMBeanConstructorInfo retInfo = null;
    if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
        MODELMBEAN_LOGGER.logp(Level.FINER,
                ModelMBeanInfoSupport.class.getName(),
                "getConstructor(String)", "Entry");
    }
    if (inName == null) {
        throw new RuntimeOperationsException(
                new IllegalArgumentException("Constructor name is null"),
                "Exception occurred trying to get the " +
                "ModelMBeanConstructorInfo of the MBean");
    }
    MBeanConstructorInfo[] consList = modelMBeanConstructors; //this.getConstructors();
    int numCons = 0;
    if (consList != null) numCons = consList.length;

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

    return retInfo;
}
ModelMBeanInfoSupport.java 文件源码 项目:OpenJSharp 阅读 19 收藏 0 点赞 0 评论 0
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;
}


问题


面经


文章

微信
公众号

扫码关注公众号