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);
}
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());
}
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());
}
}
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);
}
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;
}
}
Aggregations