Search in sources :

Example 46 with InstanceNotFoundException

use of javax.management.InstanceNotFoundException in project jdk8u_jdk by JetBrains.

the class XSheet method displayMBeanAttributesNode.

// Call on EDT
private void displayMBeanAttributesNode(final DefaultMutableTreeNode node) {
    final XNodeInfo uo = (XNodeInfo) node.getUserObject();
    if (!uo.getType().equals(Type.ATTRIBUTES)) {
        return;
    }
    mbean = (XMBean) uo.getData();
    final XMBean xmb = mbean;
    SwingWorker<MBeanInfo, Void> sw = new SwingWorker<MBeanInfo, Void>() {

        @Override
        public MBeanInfo doInBackground() throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException {
            MBeanInfo mbi = xmb.getMBeanInfo();
            return mbi;
        }

        @Override
        protected void done() {
            try {
                MBeanInfo mbi = get();
                if (mbi != null && mbi.getAttributes() != null && mbi.getAttributes().length > 0) {
                    mbeanAttributes.loadAttributes(xmb, mbi);
                    if (!isSelectedNode(node, currentNode)) {
                        return;
                    }
                    invalidate();
                    mainPanel.removeAll();
                    JPanel borderPanel = new JPanel(new BorderLayout());
                    borderPanel.setBorder(BorderFactory.createTitledBorder(Messages.ATTRIBUTE_VALUES));
                    borderPanel.add(new JScrollPane(mbeanAttributes));
                    mainPanel.add(borderPanel, BorderLayout.CENTER);
                    // add the refresh button to the south panel
                    southPanel.removeAll();
                    southPanel.add(refreshButton, BorderLayout.SOUTH);
                    southPanel.setVisible(true);
                    refreshButton.setEnabled(true);
                    validate();
                    repaint();
                }
            } catch (Exception e) {
                Throwable t = Utils.getActualException(e);
                if (JConsole.isDebug()) {
                    System.err.println("Problem displaying MBean " + "attributes for MBean [" + mbean.getObjectName() + "]");
                    t.printStackTrace();
                }
                showErrorDialog(t.toString(), Messages.PROBLEM_DISPLAYING_MBEAN);
            }
        }
    };
    sw.execute();
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) MBeanInfo(javax.management.MBeanInfo) BorderLayout(java.awt.BorderLayout) SwingWorker(javax.swing.SwingWorker) IntrospectionException(javax.management.IntrospectionException) InstanceNotFoundException(javax.management.InstanceNotFoundException) ReflectionException(javax.management.ReflectionException) IOException(java.io.IOException)

Example 47 with InstanceNotFoundException

use of javax.management.InstanceNotFoundException in project jdk8u_jdk by JetBrains.

the class XSheet method displayMBeanNode.

// Call on EDT
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();
}
Also used : MBeanInfo(javax.management.MBeanInfo) SwingWorker(javax.swing.SwingWorker) IntrospectionException(javax.management.IntrospectionException) InstanceNotFoundException(javax.management.InstanceNotFoundException) ReflectionException(javax.management.ReflectionException) IOException(java.io.IOException)

Example 48 with InstanceNotFoundException

use of javax.management.InstanceNotFoundException in project jdk8u_jdk by JetBrains.

the class ScanManager method scanAllDirectories.

// ---------------------------------------------------------------
// We start scanning in background in a Timer thread.
// The methods below implement that logic.
// ---------------------------------------------------------------
private void scanAllDirectories() throws IOException, InstanceNotFoundException {
    int errcount = 0;
    final StringBuilder b = new StringBuilder();
    for (ObjectName key : scanmap.keySet()) {
        final DirectoryScannerMXBean s = scanmap.get(key);
        try {
            if (state == STOPPED)
                return;
            s.scan();
        } catch (Exception ex) {
            LOG.log(Level.FINE, key + " failed to scan: " + ex, ex);
            errcount++;
            append(b, "\t", ex);
        }
    }
    if (errcount > 0) {
        b.insert(0, "scan partially performed with " + errcount + " error(s):");
        throw new RuntimeException(b.toString());
    }
}
Also used : InstanceNotFoundException(javax.management.InstanceNotFoundException) IOException(java.io.IOException) MalformedObjectNameException(javax.management.MalformedObjectNameException) JMException(javax.management.JMException) ListenerNotFoundException(javax.management.ListenerNotFoundException) ObjectName(javax.management.ObjectName)

Example 49 with InstanceNotFoundException

use of javax.management.InstanceNotFoundException in project sling by apache.

the class DataSourceFactory method unregisterJmx.

private void unregisterJmx() {
    try {
        if (jmxName != null) {
            MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
            mbs.unregisterMBean(jmxName);
        }
    } catch (InstanceNotFoundException ignore) {
    // NOOP
    } catch (Exception e) {
        log.error("Unable to unregister JDBC pool with JMX", e);
    }
}
Also used : InstanceNotFoundException(javax.management.InstanceNotFoundException) SQLException(java.sql.SQLException) InstanceNotFoundException(javax.management.InstanceNotFoundException) MBeanServer(javax.management.MBeanServer)

Example 50 with InstanceNotFoundException

use of javax.management.InstanceNotFoundException in project sling by apache.

the class JMXResourceProvider method parse.

/**
     * Parse the path
     */
private PathInfo parse(final String path) {
    for (final String root : this.rootsWithSlash) {
        if (path.startsWith(root)) {
            final String subPath = path.substring(root.length());
            if (subPath.length() == 0) {
                return new PathInfo(true);
            }
            // MBean name / path
            String checkPath = subPath;
            String pathInfo = null;
            ObjectName objectName = null;
            MBeanInfo mbi = null;
            while (checkPath.length() > 0 && mbi == null) {
                try {
                    objectName = this.convertResourcePathToObjectName(checkPath);
                    if (objectName != null) {
                        mbi = this.mbeanServer.getMBeanInfo(objectName);
                    }
                } catch (final IntrospectionException e) {
                // ignore
                } catch (final InstanceNotFoundException e) {
                // ignore
                } catch (final ReflectionException e) {
                // ignore
                }
                if (mbi == null) {
                    final int sep = checkPath.lastIndexOf('/');
                    if (sep == -1) {
                        checkPath = "";
                        pathInfo = subPath;
                    } else {
                        checkPath = checkPath.substring(0, sep);
                        pathInfo = subPath.substring(sep + 1);
                    }
                }
            }
            final PathInfo info = new PathInfo(pathInfo);
            if (mbi != null) {
                info.objectName = objectName;
                info.mbeanInfo = mbi;
            }
            return info;
        }
    }
    for (final String root : this.roots) {
        if (path.equals(root)) {
            return new PathInfo(true);
        }
    }
    return null;
}
Also used : ReflectionException(javax.management.ReflectionException) MBeanInfo(javax.management.MBeanInfo) InstanceNotFoundException(javax.management.InstanceNotFoundException) IntrospectionException(javax.management.IntrospectionException) ObjectName(javax.management.ObjectName)

Aggregations

InstanceNotFoundException (javax.management.InstanceNotFoundException)102 ObjectName (javax.management.ObjectName)59 ReflectionException (javax.management.ReflectionException)44 MBeanException (javax.management.MBeanException)32 MalformedObjectNameException (javax.management.MalformedObjectNameException)28 MBeanRegistrationException (javax.management.MBeanRegistrationException)25 InstanceAlreadyExistsException (javax.management.InstanceAlreadyExistsException)19 MBeanServer (javax.management.MBeanServer)17 IOException (java.io.IOException)16 AttributeNotFoundException (javax.management.AttributeNotFoundException)16 Attribute (javax.management.Attribute)15 IntrospectionException (javax.management.IntrospectionException)14 NotCompliantMBeanException (javax.management.NotCompliantMBeanException)14 AttributeList (javax.management.AttributeList)12 ObjectInstance (javax.management.ObjectInstance)12 MBeanInfo (javax.management.MBeanInfo)11 InvalidAttributeValueException (javax.management.InvalidAttributeValueException)10 RuntimeOperationsException (javax.management.RuntimeOperationsException)9 ArrayList (java.util.ArrayList)7 MBeanAttributeInfo (javax.management.MBeanAttributeInfo)7