Search in sources :

Example 41 with MBeanOperationInfo

use of javax.management.MBeanOperationInfo in project spring-framework by spring-projects.

the class MBeanClientInterceptor method invokeOperation.

/**
	 * Routes a method invocation (not a property get/set) to the corresponding
	 * operation on the managed resource.
	 * @param method the method corresponding to operation on the managed resource.
	 * @param args the invocation arguments
	 * @return the value returned by the method invocation.
	 */
private Object invokeOperation(Method method, Object[] args) throws JMException, IOException {
    MethodCacheKey key = new MethodCacheKey(method.getName(), method.getParameterTypes());
    MBeanOperationInfo info = this.allowedOperations.get(key);
    if (info == null) {
        throw new InvalidInvocationException("Operation '" + method.getName() + "' is not exposed on the management interface");
    }
    String[] signature = null;
    synchronized (this.signatureCache) {
        signature = this.signatureCache.get(method);
        if (signature == null) {
            signature = JmxUtils.getMethodSignature(method);
            this.signatureCache.put(method, signature);
        }
    }
    return this.serverToUse.invoke(this.objectName, method.getName(), args, signature);
}
Also used : MBeanOperationInfo(javax.management.MBeanOperationInfo)

Example 42 with MBeanOperationInfo

use of javax.management.MBeanOperationInfo in project spring-framework by spring-projects.

the class MethodNameBasedMBeanInfoAssemblerTests method testSetNameParameterIsNamed.

@Test
public void testSetNameParameterIsNamed() throws Exception {
    ModelMBeanInfo info = getMBeanInfoFromAssembler();
    MBeanOperationInfo operationSetAge = info.getOperation("setName");
    assertEquals("name", operationSetAge.getSignature()[0].getName());
}
Also used : MBeanOperationInfo(javax.management.MBeanOperationInfo) ModelMBeanInfo(javax.management.modelmbean.ModelMBeanInfo) Test(org.junit.Test)

Example 43 with MBeanOperationInfo

use of javax.management.MBeanOperationInfo in project spring-framework by spring-projects.

the class AbstractJmxAssemblerTests method testGetMBeanOperationInfo.

@Test
public void testGetMBeanOperationInfo() throws Exception {
    ModelMBeanInfo info = getMBeanInfoFromAssembler();
    MBeanOperationInfo[] inf = info.getOperations();
    assertEquals("Invalid number of Operations returned", getExpectedOperationCount(), inf.length);
    for (int x = 0; x < inf.length; x++) {
        assertNotNull("MBeanOperationInfo should not be null", inf[x]);
        assertNotNull("Description for MBeanOperationInfo should not be null", inf[x].getDescription());
    }
}
Also used : MBeanOperationInfo(javax.management.MBeanOperationInfo) ModelMBeanOperationInfo(javax.management.modelmbean.ModelMBeanOperationInfo) ModelMBeanInfo(javax.management.modelmbean.ModelMBeanInfo) Test(org.junit.Test)

Example 44 with MBeanOperationInfo

use of javax.management.MBeanOperationInfo in project Activiti by Activiti.

the class DefaultManagementMBeanAssemblerTest method testHappyPath.

@Test
public void testHappyPath() throws MalformedObjectNameException, JMException {
    TestMbean testMbean = new TestMbean();
    ModelMBean mbean = defaultManagementMBeanAssembler.assemble(testMbean, new ObjectName("org.activiti.jmx.Mbeans:type=something"));
    assertNotNull(mbean);
    assertNotNull(mbean.getMBeanInfo());
    assertNotNull(mbean.getMBeanInfo().getAttributes());
    MBeanAttributeInfo[] attributes = mbean.getMBeanInfo().getAttributes();
    assertEquals(2, attributes.length);
    assertTrue((attributes[0].getName().equals("TestAttributeString") && attributes[1].getName().equals("TestAttributeBoolean") || (attributes[1].getName().equals("TestAttributeString") && attributes[0].getName().equals("TestAttributeBoolean"))));
    assertNotNull(mbean.getMBeanInfo().getOperations());
    MBeanOperationInfo[] operations = mbean.getMBeanInfo().getOperations();
    assertNotNull(operations);
    assertEquals(3, operations.length);
}
Also used : ModelMBean(javax.management.modelmbean.ModelMBean) MBeanOperationInfo(javax.management.MBeanOperationInfo) TestMbean(org.activiti.management.jmx.testMbeans.TestMbean) MBeanAttributeInfo(javax.management.MBeanAttributeInfo) ObjectName(javax.management.ObjectName) Test(org.junit.Test)

Example 45 with MBeanOperationInfo

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

the class XSheet method displayMetadataNode.

// Call on EDT
private void displayMetadataNode(final DefaultMutableTreeNode node) {
    final XNodeInfo uo = (XNodeInfo) node.getUserObject();
    final XMBeanInfo mbi = mbeanInfo;
    switch(uo.getType()) {
        case ATTRIBUTE:
            SwingWorker<MBeanAttributeInfo, Void> sw = new SwingWorker<MBeanAttributeInfo, Void>() {

                @Override
                public MBeanAttributeInfo doInBackground() {
                    Object attrData = uo.getData();
                    mbean = (XMBean) ((Object[]) attrData)[0];
                    MBeanAttributeInfo mbai = (MBeanAttributeInfo) ((Object[]) attrData)[1];
                    mbeanAttributes.loadAttributes(mbean, new MBeanInfo(null, null, new MBeanAttributeInfo[] { mbai }, null, null, null));
                    return mbai;
                }

                @Override
                protected void done() {
                    try {
                        MBeanAttributeInfo mbai = get();
                        if (!isSelectedNode(node, currentNode)) {
                            return;
                        }
                        invalidate();
                        mainPanel.removeAll();
                        JPanel attributePanel = new JPanel(new BorderLayout());
                        JPanel attributeBorderPanel = new JPanel(new BorderLayout());
                        attributeBorderPanel.setBorder(BorderFactory.createTitledBorder(Messages.ATTRIBUTE_VALUE));
                        JPanel attributeValuePanel = new JPanel(new BorderLayout());
                        attributeValuePanel.setBorder(LineBorder.createGrayLineBorder());
                        attributeValuePanel.add(mbeanAttributes.getTableHeader(), BorderLayout.PAGE_START);
                        attributeValuePanel.add(mbeanAttributes, BorderLayout.CENTER);
                        attributeBorderPanel.add(attributeValuePanel, BorderLayout.CENTER);
                        JPanel refreshButtonPanel = new JPanel();
                        refreshButtonPanel.add(refreshButton);
                        attributeBorderPanel.add(refreshButtonPanel, BorderLayout.SOUTH);
                        refreshButton.setEnabled(true);
                        attributePanel.add(attributeBorderPanel, BorderLayout.NORTH);
                        mbi.addMBeanAttributeInfo(mbai);
                        attributePanel.add(mbi, BorderLayout.CENTER);
                        mainPanel.add(attributePanel, 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 " + "attribute for MBean [" + mbean.getObjectName() + "]");
                            t.printStackTrace();
                        }
                        showErrorDialog(t.toString(), Messages.PROBLEM_DISPLAYING_MBEAN);
                    }
                }
            };
            sw.execute();
            break;
        case OPERATION:
            Object operData = uo.getData();
            mbean = (XMBean) ((Object[]) operData)[0];
            MBeanOperationInfo mboi = (MBeanOperationInfo) ((Object[]) operData)[1];
            mbeanOperations.loadOperations(mbean, new MBeanInfo(null, null, null, null, new MBeanOperationInfo[] { mboi }, null));
            invalidate();
            mainPanel.removeAll();
            JPanel operationPanel = new JPanel(new BorderLayout());
            JPanel operationBorderPanel = new JPanel(new BorderLayout());
            operationBorderPanel.setBorder(BorderFactory.createTitledBorder(Messages.OPERATION_INVOCATION));
            operationBorderPanel.add(new JScrollPane(mbeanOperations));
            operationPanel.add(operationBorderPanel, BorderLayout.NORTH);
            mbi.addMBeanOperationInfo(mboi);
            operationPanel.add(mbi, BorderLayout.CENTER);
            mainPanel.add(operationPanel, BorderLayout.CENTER);
            southPanel.setVisible(false);
            southPanel.removeAll();
            validate();
            repaint();
            break;
        case NOTIFICATION:
            Object notifData = uo.getData();
            invalidate();
            mainPanel.removeAll();
            mbi.addMBeanNotificationInfo((MBeanNotificationInfo) notifData);
            mainPanel.add(mbi, BorderLayout.CENTER);
            southPanel.setVisible(false);
            southPanel.removeAll();
            validate();
            repaint();
            break;
    }
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) MBeanInfo(javax.management.MBeanInfo) MBeanOperationInfo(javax.management.MBeanOperationInfo) MBeanAttributeInfo(javax.management.MBeanAttributeInfo) IntrospectionException(javax.management.IntrospectionException) InstanceNotFoundException(javax.management.InstanceNotFoundException) ReflectionException(javax.management.ReflectionException) IOException(java.io.IOException) BorderLayout(java.awt.BorderLayout) SwingWorker(javax.swing.SwingWorker)

Aggregations

MBeanOperationInfo (javax.management.MBeanOperationInfo)68 MBeanInfo (javax.management.MBeanInfo)39 MBeanAttributeInfo (javax.management.MBeanAttributeInfo)35 MBeanParameterInfo (javax.management.MBeanParameterInfo)25 ObjectName (javax.management.ObjectName)20 Test (org.junit.Test)12 ArrayList (java.util.ArrayList)11 MBeanNotificationInfo (javax.management.MBeanNotificationInfo)9 MBeanConstructorInfo (javax.management.MBeanConstructorInfo)8 MBeanServer (javax.management.MBeanServer)8 Method (java.lang.reflect.Method)7 Descriptor (javax.management.Descriptor)7 Attribute (javax.management.Attribute)5 ReflectionException (javax.management.ReflectionException)5 InstanceNotFoundException (javax.management.InstanceNotFoundException)4 AMX (com.sun.appserv.management.base.AMX)3 IOException (java.io.IOException)3 TreeMap (java.util.TreeMap)3 IntrospectionException (javax.management.IntrospectionException)3 MBeanServerConnection (javax.management.MBeanServerConnection)3