Java 类javax.management.MBeanException 实例源码

项目:jerrydog    文件:MBeanUtils.java   
/**
 * Create, register, and return an MBean for this
 * <code>Context</code> object.
 *
 * @param context The Context to be managed
 *
 * @exception Exception if an MBean cannot be created or registered
 */
public static ModelMBean createMBean(Context context)
    throws Exception {

    String mname = createManagedName(context);
    ManagedBean managed = registry.findManagedBean(mname);
    if (managed == null) {
        Exception e = new Exception("ManagedBean is not found with "+mname);
        throw new MBeanException(e);
    }
    String domain = managed.getDomain();
    if (domain == null)
        domain = mserver.getDefaultDomain();
    ModelMBean mbean = managed.createMBean(context);
    ObjectName oname = createObjectName(domain, context);
    mserver.registerMBean(mbean, oname);
    return (mbean);

}
项目:hadoop-oss    文件:MetricsDynamicMBeanBase.java   
@Override
public Object invoke(String actionName, Object[] parms, String[] signature)
    throws MBeanException, ReflectionException {

  if (actionName == null || actionName.isEmpty()) 
    throw new IllegalArgumentException();


  // Right now we support only one fixed operation (if it applies)
  if (!(actionName.equals(RESET_ALL_MIN_MAX_OP)) || 
      mbeanInfo.getOperations().length != 1) {
    throw new ReflectionException(new NoSuchMethodException(actionName));
  }
  for (MetricsBase m : metricsRegistry.getMetricsList())  {
    if ( MetricsTimeVaryingRate.class.isInstance(m) ) {
      MetricsTimeVaryingRate.class.cast(m).resetMinMax();
    }
  }
  return null;
}
项目:hashsdn-controller    文件:DynamicWritableWrapper.java   
@Override
public synchronized void setAttribute(final Attribute attribute)
        throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException {
    Attribute newAttribute = attribute;
    if (configBeanModificationDisabled.get()) {
        throw new IllegalStateException("Operation is not allowed now");
    }

    if ("Attribute".equals(newAttribute.getName())) {
        setAttribute((Attribute) newAttribute.getValue());
        return;
    }

    try {
        if (newAttribute.getValue() instanceof ObjectName) {
            newAttribute = fixDependencyAttribute(newAttribute);
        } else if (newAttribute.getValue() instanceof ObjectName[]) {
            newAttribute = fixDependencyListAttribute(newAttribute);
        }

        internalServer.setAttribute(objectNameInternal, newAttribute);
    } catch (final InstanceNotFoundException e) {
        throw new MBeanException(e);
    }

}
项目:OpenJSharp    文件:MBeanServerAccessController.java   
/**
 * Call <code>checkCreate(className)</code>, then forward this method to the
 * wrapped object.
 */
public ObjectInstance createMBean(String className, ObjectName name)
    throws
    ReflectionException,
    InstanceAlreadyExistsException,
    MBeanRegistrationException,
    MBeanException,
    NotCompliantMBeanException {
    checkCreate(className);
    SecurityManager sm = System.getSecurityManager();
    if (sm == null) {
        Object object = getMBeanServer().instantiate(className);
        checkClassLoader(object);
        return getMBeanServer().registerMBean(object, name);
    } else {
        return getMBeanServer().createMBean(className, name);
    }
}
项目:OpenJSharp    文件:PerInterface.java   
void setAttribute(Object resource, String attribute, Object value,
                  Object cookie)
        throws AttributeNotFoundException,
               InvalidAttributeValueException,
               MBeanException,
               ReflectionException {

    final M cm = setters.get(attribute);
    if (cm == null) {
        final String msg;
        if (getters.containsKey(attribute))
            msg = "Read-only attribute: " + attribute;
        else
            msg = "No such attribute: " + attribute;
        throw new AttributeNotFoundException(msg);
    }
    introspector.invokeSetter(attribute, cm, resource, value, cookie);
}
项目:lazycat    文件:MBeanUtils.java   
/**
 * Create, register, and return an MBean for this
 * <code>ContextEnvironment</code> object.
 *
 * @param environment
 *            The ContextEnvironment to be managed
 *
 * @exception Exception
 *                if an MBean cannot be created or registered
 */
public static DynamicMBean createMBean(ContextEnvironment environment) throws Exception {

    String mname = createManagedName(environment);
    ManagedBean managed = registry.findManagedBean(mname);
    if (managed == null) {
        Exception e = new Exception("ManagedBean is not found with " + mname);
        throw new MBeanException(e);
    }
    String domain = managed.getDomain();
    if (domain == null)
        domain = mserver.getDefaultDomain();
    DynamicMBean mbean = managed.createMBean(environment);
    ObjectName oname = createObjectName(domain, environment);
    if (mserver.isRegistered(oname)) {
        mserver.unregisterMBean(oname);
    }
    mserver.registerMBean(mbean, oname);
    return (mbean);

}
项目:apache-tomcat-7.0.73-with-comment    文件:MBeanUtils.java   
/**
 * Create, register, and return an MBean for this
 * <code>Group</code> object.
 *
 * @param group The Group to be managed
 *
 * @exception Exception if an MBean cannot be created or registered
 */
static DynamicMBean createMBean(Group group)
    throws Exception {

    String mname = createManagedName(group);
    ManagedBean managed = registry.findManagedBean(mname);
    if (managed == null) {
        Exception e = new Exception("ManagedBean is not found with "+mname);
        throw new MBeanException(e);
    }
    String domain = managed.getDomain();
    if (domain == null)
        domain = mserver.getDefaultDomain();
    DynamicMBean mbean = managed.createMBean(group);
    ObjectName oname = createObjectName(domain, group);
    if( mserver.isRegistered( oname ))  {
        mserver.unregisterMBean(oname);
    }
    mserver.registerMBean(mbean, oname);
    return (mbean);

}
项目:monarch    文件:MX4JModelMBean.java   
public void sendAttributeChangeNotification(Attribute oldAttribute, Attribute newAttribute)
    throws MBeanException, RuntimeOperationsException {
  if (oldAttribute == null || newAttribute == null)
    throw new RuntimeOperationsException(new IllegalArgumentException(
        LocalizedStrings.MX4JModelMBean_ATTRIBUTE_CANNOT_BE_NULL.toLocalizedString()));
  if (!oldAttribute.getName().equals(newAttribute.getName()))
    throw new RuntimeOperationsException(new IllegalArgumentException(
        LocalizedStrings.MX4JModelMBean_ATTRIBUTE_NAMES_CANNOT_BE_DIFFERENT.toLocalizedString()));

  // TODO: the source must be the object name of the MBean if the listener was registered through
  // MBeanServer
  Object oldValue = oldAttribute.getValue();
  AttributeChangeNotification n = new AttributeChangeNotification(this, 1,
      System.currentTimeMillis(), "Attribute value changed", oldAttribute.getName(),
      oldValue == null ? null : oldValue.getClass().getName(), oldValue, newAttribute.getValue());
  sendAttributeChangeNotification(n);
}
项目:jdk8u-jdk    文件:MBeanServerAccessController.java   
/**
 * Call <code>checkCreate(className)</code>, then forward this method to the
 * wrapped object.
 */
public ObjectInstance createMBean(String className, ObjectName name,
                                  Object params[], String signature[])
    throws
    ReflectionException,
    InstanceAlreadyExistsException,
    MBeanRegistrationException,
    MBeanException,
    NotCompliantMBeanException {
    checkCreate(className);
    SecurityManager sm = System.getSecurityManager();
    if (sm == null) {
        Object object = getMBeanServer().instantiate(className,
                                                     params,
                                                     signature);
        checkClassLoader(object);
        return getMBeanServer().registerMBean(object, name);
    } else {
        return getMBeanServer().createMBean(className, name,
                                            params, signature);
    }
}
项目:apache-tomcat-7.0.73-with-comment    文件:MBeanUtils.java   
/**
 * Create, register, and return an MBean for this
 * <code>ContextResource</code> object.
 *
 * @param resource The ContextResource to be managed
 *
 * @exception Exception if an MBean cannot be created or registered
 */
public static DynamicMBean createMBean(ContextResource resource)
    throws Exception {

    String mname = createManagedName(resource);
    ManagedBean managed = registry.findManagedBean(mname);
    if (managed == null) {
        Exception e = new Exception("ManagedBean is not found with "+mname);
        throw new MBeanException(e);
    }
    String domain = managed.getDomain();
    if (domain == null)
        domain = mserver.getDefaultDomain();
    DynamicMBean mbean = managed.createMBean(resource);
    ObjectName oname = createObjectName(domain, resource);
    if( mserver.isRegistered( oname ))  {
        mserver.unregisterMBean(oname);
    }
    mserver.registerMBean(mbean, oname);
    return (mbean);

}
项目:jdk8u-jdk    文件:RMIConnector.java   
public Object getAttribute(ObjectName name,
        String attribute)
        throws MBeanException,
        AttributeNotFoundException,
        InstanceNotFoundException,
        ReflectionException,
        IOException {
    if (logger.debugOn()) logger.debug("getAttribute",
            "name=" + name + ", attribute="
            + attribute);

    final ClassLoader old = pushDefaultClassLoader();
    try {
        return connection.getAttribute(name,
                attribute,
                delegationSubject);
    } catch (IOException ioe) {
        communicatorAdmin.gotIOException(ioe);

        return connection.getAttribute(name,
                attribute,
                delegationSubject);
    } finally {
        popDefaultClassLoader(old);
    }
}
项目:lams    文件:MBeanUtils.java   
/**
 * Create, register, and return an MBean for this
 * <code>Engine</code> object.
 *
 * @param engine The Engine to be managed
 *
 * @exception Exception if an MBean cannot be created or registered
 */
static DynamicMBean createMBean(Engine engine)
    throws Exception {

    String mname = createManagedName(engine);
    ManagedBean managed = registry.findManagedBean(mname);
    if (managed == null) {
        Exception e = new Exception("ManagedBean is not found with "+mname);
        throw new MBeanException(e);
    }
    String domain = managed.getDomain();
    if (domain == null)
        domain = mserver.getDefaultDomain();
    DynamicMBean mbean = managed.createMBean(engine);
    ObjectName oname = createObjectName(domain, engine);
    if( mserver.isRegistered( oname ))  {
        mserver.unregisterMBean(oname);
    }
    mserver.registerMBean(mbean, oname);
    return (mbean);

}
项目:jerrydog    文件:MBeanUtils.java   
/**
 * Create, register, and return an MBean for this
 * <code>Service</code> object.
 *
 * @param service The Service to be managed
 *
 * @exception Exception if an MBean cannot be created or registered
 */
public static ModelMBean createMBean(Service service)
    throws Exception {

    String mname = createManagedName(service);
    ManagedBean managed = registry.findManagedBean(mname);
    if (managed == null) {
        Exception e = new Exception("ManagedBean is not found with "+mname);
        throw new MBeanException(e);
    }
    String domain = managed.getDomain();
    if (domain == null)
        domain = mserver.getDefaultDomain();
    ModelMBean mbean = managed.createMBean(service);
    ObjectName oname = createObjectName(domain, service);
    mserver.registerMBean(mbean, oname);
    return (mbean);

}
项目:lams    文件:MBeanUtils.java   
/**
 * Create, register, and return an MBean for this
 * <code>Valve</code> object.
 *
 * @param valve The Valve to be managed
 *
 * @exception Exception if an MBean cannot be created or registered
 */
static DynamicMBean createMBean(Valve valve)
    throws Exception {

    String mname = createManagedName(valve);
    ManagedBean managed = registry.findManagedBean(mname);
    if (managed == null) {
        Exception e = new Exception("ManagedBean is not found with "+mname);
        throw new MBeanException(e);
    }
    String domain = managed.getDomain();
    if (domain == null)
        domain = mserver.getDefaultDomain();
    DynamicMBean mbean = managed.createMBean(valve);
    ObjectName oname = createObjectName(domain, valve);
    if( mserver.isRegistered( oname ))  {
        mserver.unregisterMBean(oname);
    }
    mserver.registerMBean(mbean, oname);
    return (mbean);

}
项目:Pogamut3    文件:DynamicProxy.java   
public void setAttribute(Attribute attribute) throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException {
    try {
        mbsc.setAttribute(objectName, attribute);
    } catch (Exception ex) {
        throw new MBeanException(ex);
    }
}
项目:OpenJSharp    文件:RMIConnector.java   
public ObjectInstance createMBean(String className,
        ObjectName name,
        Object params[],
        String signature[])
        throws ReflectionException,
        InstanceAlreadyExistsException,
        MBeanRegistrationException,
        MBeanException,
        NotCompliantMBeanException,
        IOException {
    if (logger.debugOn())
        logger.debug("createMBean(String,ObjectName,Object[],String[])",
                "className=" + className + ", name="
                + name + ", params="
                + objects(params) + ", signature="
                + strings(signature));

    final MarshalledObject<Object[]> sParams =
            new MarshalledObject<Object[]>(params);
    final ClassLoader old = pushDefaultClassLoader();
    try {
        return connection.createMBean(className,
                name,
                sParams,
                signature,
                delegationSubject);
    } catch (IOException ioe) {
        communicatorAdmin.gotIOException(ioe);

        return connection.createMBean(className,
                name,
                sParams,
                signature,
                delegationSubject);
    } finally {
        popDefaultClassLoader(old);
    }
}
项目:monarch    文件:MBeanServerWrapper.java   
@Override
public void setAttribute(ObjectName name, Attribute attribute)
    throws InstanceNotFoundException, AttributeNotFoundException, InvalidAttributeValueException,
    MBeanException, ReflectionException {
  ResourcePermission ctx = getOperationContext(name, attribute.getName(), false);
  this.securityService.authorize(ctx);
  mbs.setAttribute(name, attribute);
}
项目:openjdk-jdk10    文件:DefaultMBeanServerInterceptor.java   
public ObjectInstance createMBean(String className, ObjectName name,
                                  ObjectName loaderName,
                                  Object[] params, String[] signature)
    throws ReflectionException, InstanceAlreadyExistsException,
           MBeanRegistrationException, MBeanException,
           NotCompliantMBeanException, InstanceNotFoundException  {

    return createMBean(className, name, loaderName, false,
                       params, signature);
}
项目:Pogamut3    文件:PogamutMBeanServer.java   
@Override
public synchronized ObjectInstance createMBean(String className, ObjectName name,
        ObjectName loaderName, Object[] params, String[] signature)
        throws ReflectionException, InstanceAlreadyExistsException,
        MBeanRegistrationException, MBeanException,
        NotCompliantMBeanException, InstanceNotFoundException {
    throw new UnsupportedOperationException("Not supported by PogamutMBeanServer yet...");      
}
项目:hadoop    文件:MetricsSourceAdapter.java   
@Override
public Object getAttribute(String attribute)
    throws AttributeNotFoundException, MBeanException, ReflectionException {
  updateJmxCache();
  synchronized(this) {
    Attribute a = attrCache.get(attribute);
    if (a == null) {
      throw new AttributeNotFoundException(attribute +" not found");
    }
    if (LOG.isDebugEnabled()) {
      LOG.debug(attribute +": "+ a);
    }
    return a.getValue();
  }
}
项目:openjdk-jdk10    文件:TestUnifiedLoggingSwitchStress.java   
@Override
public void run() {

    while (!shouldStop) {
        int fileNum = RND.nextInt(logCount);
        int logLevel = RND.nextInt(LOG_LEVELS.length);

        String outputCommand = String.format("output=%s_%d.log", logFilePrefix, fileNum);
        String logLevelCommand = "what='gc*=" + LOG_LEVELS[logLevel] + "'";

        try {
            Object out = MBS.invoke(new ObjectName("com.sun.management:type=DiagnosticCommand"),
                                    "vmLog",
                                    new Object[]{new String[]{outputCommand, logLevelCommand}},
                                    new String[]{String[].class.getName()});

            if (!out.toString().isEmpty()) {
                System.out.format("WARNING: Diagnostic command vmLog with arguments %s,%s returned not empty"
                                + " output %s\n",
                        outputCommand, logLevelCommand, out);
            }
        } catch (InstanceNotFoundException | MBeanException | ReflectionException | MalformedObjectNameException e) {
            System.out.println("Got exception trying to change log level:" + e);
            e.printStackTrace();
            throw new Error(e);
        }
        Thread.yield();
    }
    System.out.println("Log Switcher finished");
}
项目:OpenJSharp    文件:DefaultMBeanServerInterceptor.java   
public ObjectInstance createMBean(String className, ObjectName name,
                                  ObjectName loaderName,
                                  Object[] params, String[] signature)
    throws ReflectionException, InstanceAlreadyExistsException,
           MBeanRegistrationException, MBeanException,
           NotCompliantMBeanException, InstanceNotFoundException  {

    return createMBean(className, name, loaderName, false,
                       params, signature);
}
项目:hadoop-oss    文件:MetricsSourceAdapter.java   
@Override
public Object getAttribute(String attribute)
    throws AttributeNotFoundException, MBeanException, ReflectionException {
  updateJmxCache();
  synchronized(this) {
    Attribute a = attrCache.get(attribute);
    if (a == null) {
      throw new AttributeNotFoundException(attribute +" not found");
    }
    if (LOG.isDebugEnabled()) {
      LOG.debug(attribute +": "+ a);
    }
    return a.getValue();
  }
}
项目:openjdk-jdk10    文件:ModelMBeanInfoSupport.java   
public ModelMBeanOperationInfo getOperation(String inName)
throws MBeanException, RuntimeOperationsException {
    ModelMBeanOperationInfo retInfo = null;
    if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
        MODELMBEAN_LOGGER.log(Level.TRACE, "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.TRACE)) {
        MODELMBEAN_LOGGER.log(Level.TRACE, "Exit");
    }

    return retInfo;
}
项目:tomcat7    文件:JMXProxyServlet.java   
/**
 * Sets an MBean attribute's value.
 */
private void setAttributeInternal(String onameStr,
                                  String attributeName,
                                  String value)
    throws OperationsException, MBeanException, ReflectionException {
    ObjectName oname=new ObjectName( onameStr );
    String type=registry.getType(oname, attributeName);
    Object valueObj=registry.convertValue(type, value );
    mBeanServer.setAttribute( oname, new Attribute(attributeName, valueObj));
}
项目:hashsdn-controller    文件:ConfigTransactionClientsTest.java   
@Test(expected = ValidationException.class)
public void testValidateBean2() throws Exception {
    MBeanServer mbsLocal = mock(MBeanServer.class);
    MBeanException mBeanException = new MBeanException(new ValidationException(
            Collections.<String, Map<String, ExceptionMessageWithStackTrace>>emptyMap()));
    doThrow(mBeanException).when(mbsLocal).invoke(transactionControllerON, "validate", null, null);

    ConfigTransactionJMXClient jmxTransactionClientFake = new ConfigTransactionJMXClient(null,
            transactionControllerON,
            mbsLocal);
    jmxTransactionClientFake.validateBean(transactionControllerON);
}
项目:tqdev-metrics    文件:JmxReporterTest.java   
/**
 * Should throw exception on unknown type.
 *
 * @throws MBeanException
 *             the MBean exception
 * @throws AttributeNotFoundException
 *             the attribute not found exception
 * @throws ReflectionException
 *             the reflection exception
 */
@Test
public void shouldThrowExceptionOnUnknownType()
        throws MBeanException, AttributeNotFoundException, ReflectionException {
    try {
        readJmx("jdbc.Statement.Invocations", "select");
        Assert.fail("readJmx should have thrown an AttributeNotFoundException");
    } catch (Exception e) {
        assertThat(e.getClass().getSimpleName()).isEqualTo("AttributeNotFoundException");
    }
}
项目:jdk8u-jdk    文件:MBeanServerAccessController.java   
/**
 * Call <code>checkCreate(className)</code>, then forward this method to the
 * wrapped object.
 */
public ObjectInstance createMBean(String className,
                                  ObjectName name,
                                  ObjectName loaderName,
                                  Object params[],
                                  String signature[])
    throws
    ReflectionException,
    InstanceAlreadyExistsException,
    MBeanRegistrationException,
    MBeanException,
    NotCompliantMBeanException,
    InstanceNotFoundException {
    checkCreate(className);
    SecurityManager sm = System.getSecurityManager();
    if (sm == null) {
        Object object = getMBeanServer().instantiate(className,
                                                     loaderName,
                                                     params,
                                                     signature);
        checkClassLoader(object);
        return getMBeanServer().registerMBean(object, name);
    } else {
        return getMBeanServer().createMBean(className, name, loaderName,
                                            params, signature);
    }
}
项目:lazycat    文件: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);

}
项目:jdk8u-jdk    文件:MBeanServerAccessController.java   
/**
 * Call <code>checkCreate(className)</code>, then forward this method to the
 * wrapped object.
 */
public Object instantiate(String className,
                          Object params[],
                          String signature[])
    throws ReflectionException, MBeanException {
    checkCreate(className);
    return getMBeanServer().instantiate(className, params, signature);
}
项目:jdk8u-jdk    文件:DefaultMBeanServerInterceptor.java   
public ObjectInstance createMBean(String className, ObjectName name,
                                  ObjectName loaderName,
                                  Object[] params, String[] signature)
    throws ReflectionException, InstanceAlreadyExistsException,
           MBeanRegistrationException, MBeanException,
           NotCompliantMBeanException, InstanceNotFoundException  {

    return createMBean(className, name, loaderName, false,
                       params, signature);
}
项目:hashsdn-controller    文件:AbstractDynamicWrapper.java   
@Override
public Object getAttribute(final String attributeName)
        throws AttributeNotFoundException, MBeanException, ReflectionException {
    if ("MBeanInfo".equals(attributeName)) {
        return getMBeanInfo();
    }

    Object obj = null;
    try {
        obj = internalServer.getAttribute(objectNameInternal, attributeName);
    } catch (final InstanceNotFoundException e) {
        throw new MBeanException(e);
    }

    if (obj instanceof ObjectName) {
        AttributeHolder attributeHolder = attributeHolderMap.get(attributeName);
        if (attributeHolder.getRequireInterfaceOrNull() != null) {
            obj = fixObjectName((ObjectName) obj);
        }
        return obj;
    }

    if (isDependencyListAttr(attributeName, obj)) {
        obj = fixDependencyListAttribute(obj);
    }

    return obj;
}
项目:openjdk-jdk10    文件:AvoidGetMBeanInfoCallsTest.java   
public Object invoke(String actionName,
                     Object params[],
                     String signature[])
    throws MBeanException,
           ReflectionException {
    return null;
}
项目:tomcat7    文件:BaseModelMBean.java   
/**
 * Send a <code>Notification</code> to all registered listeners as a
 * <code>jmx.modelmbean.general</code> notification.
 *
 * @param notification The <code>Notification</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 sendNotification(Notification notification)
    throws MBeanException, RuntimeOperationsException {

    if (notification == null)
        throw new RuntimeOperationsException
            (new IllegalArgumentException("Notification is null"),
             "Notification is null");
    if (generalBroadcaster == null)
        return; // This means there are no registered listeners
    generalBroadcaster.sendNotification(notification);

}
项目:oscm    文件:SetConfigurationSetting.java   
@Override
public Object invoke(String actionName, Object[] params, String[] signature)
        throws MBeanException, ReflectionException {
    Object result = null;
    if (actionName.equals(SET_CONFIGURATION_SETTING)) {
        result = setConfigurationSetting((String) params[0],
                (String) params[1]);
    } else {
        throw new ReflectionException(new NoSuchMethodException(actionName));
    }
    return result;
}
项目:OpenJSharp    文件:SnmpGenericObjectServer.java   
/**
 * 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);
}
项目:openjdk-jdk10    文件:MBeanExceptionTest.java   
public Object getAttribute(String attrName)
        throws MBeanException {
    if (attrName.equals("UncheckedException"))
        throw theUncheckedException;
    else
        throw new AssertionError();
}
项目:lams    文件:SpringModelMBean.java   
/**
 * Sets managed resource to expose and stores its {@link ClassLoader}.
 */
@Override
public void setManagedResource(Object managedResource, String managedResourceType)
        throws MBeanException, InstanceNotFoundException, InvalidTargetObjectTypeException {

    this.managedResourceClassLoader = managedResource.getClass().getClassLoader();
    super.setManagedResource(managedResource, managedResourceType);
}
项目:jdk8u-jdk    文件:RequiredModelMBean.java   
/**
 * Sets the instance handle of the object against which to
 * execute all methods in this ModelMBean management interface
 * (MBeanInfo and Descriptors).
 *
 * @param mr Object that is the managed resource
 * @param mr_type The type of reference for the managed resource.
 *     <br>Can be: "ObjectReference", "Handle", "IOR", "EJBHandle",
 *         or "RMIReference".
 *     <br>In this implementation only "ObjectReference" is supported.
 *
 * @exception MBeanException The initializer of the object has
 *            thrown an exception.
 * @exception InstanceNotFoundException The managed resource
 *            object could not be found
 * @exception InvalidTargetObjectTypeException The managed
 *            resource type should be "ObjectReference".
 * @exception RuntimeOperationsException Wraps a {@link
 *            RuntimeException} when setting the resource.
 **/
public void setManagedResource(Object mr, String mr_type)
    throws MBeanException, RuntimeOperationsException,
           InstanceNotFoundException, InvalidTargetObjectTypeException {
    if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
        MODELMBEAN_LOGGER.logp(Level.FINER,
                RequiredModelMBean.class.getName(),
            "setManagedResource(Object,String)","Entry");
    }

    // check that the mr_type is supported by this JMXAgent
    // only "objectReference" is supported
    if ((mr_type == null) ||
        (! mr_type.equalsIgnoreCase("objectReference"))) {
        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
            MODELMBEAN_LOGGER.logp(Level.FINER,
                    RequiredModelMBean.class.getName(),
                "setManagedResource(Object,String)",
                "Managed Resource Type is not supported: " + mr_type);
        }
        throw new InvalidTargetObjectTypeException(mr_type);
    }

    if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
        MODELMBEAN_LOGGER.logp(Level.FINER,
                RequiredModelMBean.class.getName(),
            "setManagedResource(Object,String)",
            "Managed Resource is valid");
    }
    managedResource = mr;

    if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
        MODELMBEAN_LOGGER.logp(Level.FINER,
                RequiredModelMBean.class.getName(),
            "setManagedResource(Object, String)", "Exit");
    }
}
项目:monarch    文件:MX4JModelMBean.java   
public void load() throws MBeanException, RuntimeOperationsException, InstanceNotFoundException {
  PersisterMBean persister = findPersister();
  if (persister != null) {
    ModelMBeanInfo info = (ModelMBeanInfo) persister.load();
    setModelMBeanInfo(info);
  }
}