Search in sources :

Example 11 with MBeanOperationInfo

use of javax.management.MBeanOperationInfo in project Entitas-Java by Rubentxu.

the class VisualDebbuger method start.

@Override
public void start(Stage primaryStage) throws Exception {
    FXMLLoader loader = new FXMLLoader(getClass().getClassLoader().getResource("VisualDebbuger.fxml"));
    Parent root = loader.load();
    primaryStage.setTitle("CodeGenerator");
    primaryStage.setScene(new Scene(root, 560, 575));
    primaryStage.setResizable(false);
    primaryStage.show();
    stage = primaryStage;
    client = new JmxClient("localhost", 1313);
    Set<ObjectName> names = client.getBeanNames();
    beanNames.setText(names.stream().map(n -> n.getKeyPropertyListString()).reduce(String::concat).get());
//        MBeanAttributeInfo[] attributeInfos =
//                client.getAttributesInfo(objectName);
//        MBeanOperationInfo[] operationInfos =
//                client.getOperationsInfo(objectName);
}
Also used : Scene(javafx.scene.Scene) Initializable(javafx.fxml.Initializable) Properties(java.util.Properties) javafx.scene.control(javafx.scene.control) URL(java.net.URL) MBeanOperationInfo(javax.management.MBeanOperationInfo) MBeanAttributeInfo(javax.management.MBeanAttributeInfo) Set(java.util.Set) JmxClient(com.j256.simplejmx.client.JmxClient) ObjectName(javax.management.ObjectName) Application(javafx.application.Application) FXML(javafx.fxml.FXML) Parent(javafx.scene.Parent) ActionEvent(javafx.event.ActionEvent) Stage(javafx.stage.Stage) java.io(java.io) ResourceBundle(java.util.ResourceBundle) FXMLLoader(javafx.fxml.FXMLLoader) DirectoryChooser(javafx.stage.DirectoryChooser) Parent(javafx.scene.Parent) JmxClient(com.j256.simplejmx.client.JmxClient) Scene(javafx.scene.Scene) FXMLLoader(javafx.fxml.FXMLLoader) ObjectName(javax.management.ObjectName)

Example 12 with MBeanOperationInfo

use of javax.management.MBeanOperationInfo in project tdi-studio-se by Talend.

the class InvokeAction method selectionChanged.

/*
     * @see ISelectionChangedListener#selectionChanged(SelectionChangedEvent)
     */
@Override
public void selectionChanged(SelectionChangedEvent event) {
    info = null;
    ISelection selection = event.getSelection();
    if (selection instanceof IStructuredSelection) {
        Object element = ((IStructuredSelection) selection).getFirstElement();
        if (element instanceof MBeanOperationInfo) {
            info = (MBeanOperationInfo) element;
        }
    }
    setEnabled(info != null);
}
Also used : MBeanOperationInfo(javax.management.MBeanOperationInfo) ISelection(org.eclipse.jface.viewers.ISelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 13 with MBeanOperationInfo

use of javax.management.MBeanOperationInfo in project tdi-studio-se by Talend.

the class OperationsTab method getValidOperations.

/**
     * Gets the valid MBean operations.
     * 
     * @param operations
     * @return The valid MBean operations
     */
static MBeanOperationInfo[] getValidOperations(MBeanOperationInfo[] operations) {
    List<MBeanOperationInfo> validOperations = new ArrayList<MBeanOperationInfo>();
    for (MBeanOperationInfo operation : operations) {
        boolean invalid = false;
        MBeanParameterInfo[] signature = operation.getSignature();
        for (int i = 0; i < signature.length; i++) {
            String name = signature[i].getName();
            String type = signature[i].getType();
            String description = signature[i].getDescription();
            if (name == null || type == null || description == null) {
                invalid = true;
                signature[i] = new MBeanParameterInfo(getNonNull(name), getNonNull(type), getNonNull(description), signature[i].getDescriptor());
            }
        }
        if (invalid) {
            operation = new MBeanOperationInfo(operation.getName(), operation.getDescription(), signature, operation.getReturnType(), operation.getImpact(), operation.getDescriptor());
        }
        validOperations.add(operation);
    }
    return validOperations.toArray(new MBeanOperationInfo[validOperations.size()]);
}
Also used : MBeanOperationInfo(javax.management.MBeanOperationInfo) ArrayList(java.util.ArrayList) MBeanParameterInfo(javax.management.MBeanParameterInfo)

Example 14 with MBeanOperationInfo

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

the class JobExecutorMBeanTest method testAnnotations.

@Test
public void testAnnotations() throws MalformedObjectNameException, JMException {
    ModelMBean modelBean = assembler.assemble(jobExecutorMbean, new ObjectName("domain", "key", "value"));
    assertNotNull(modelBean);
    MBeanInfo beanInfo = modelBean.getMBeanInfo();
    assertNotNull(beanInfo);
    assertNotNull(beanInfo.getOperations());
    assertEquals(2, beanInfo.getOperations().length);
    int counter = 0;
    for (MBeanOperationInfo op : beanInfo.getOperations()) {
        if (op.getName().equals("setJobExecutorActivate")) {
            counter++;
            assertEquals("set job executor activate", op.getDescription());
            assertEquals("void", op.getReturnType());
            assertEquals(1, op.getSignature().length);
            assertEquals("java.lang.Boolean", op.getSignature()[0].getType());
        }
    }
    assertEquals(1, counter);
    // check attributes
    assertNotNull(beanInfo.getAttributes());
    assertEquals(1, beanInfo.getAttributes().length);
    counter = 0;
    for (MBeanAttributeInfo attr : beanInfo.getAttributes()) {
        if (attr.getName().equals("JobExecutorActivated")) {
            counter++;
            assertEquals("check if the job executor is activated", attr.getDescription());
            assertEquals("boolean", attr.getType());
        }
    }
    assertEquals(1, counter);
}
Also used : ModelMBean(javax.management.modelmbean.ModelMBean) MBeanInfo(javax.management.MBeanInfo) MBeanOperationInfo(javax.management.MBeanOperationInfo) MBeanAttributeInfo(javax.management.MBeanAttributeInfo) ObjectName(javax.management.ObjectName) Test(org.junit.Test)

Example 15 with MBeanOperationInfo

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

the class ProcessDefinitionsTest method testAnnotations.

@Test
public void testAnnotations() throws MalformedObjectNameException, JMException {
    ModelMBean modelBean = assembler.assemble(processDefinitionsMBean, new ObjectName("domain", "key", "value"));
    assertNotNull(modelBean);
    MBeanInfo beanInfo = modelBean.getMBeanInfo();
    assertNotNull(beanInfo);
    assertNotNull(beanInfo.getOperations());
    assertEquals(9, beanInfo.getOperations().length);
    int counter = 0;
    for (MBeanOperationInfo op : beanInfo.getOperations()) {
        if (op.getName().equals("deleteDeployment")) {
            counter++;
            assertEquals("delete deployment", op.getDescription());
            assertEquals("void", op.getReturnType());
            assertEquals(1, op.getSignature().length);
            assertEquals("java.lang.String", op.getSignature()[0].getType());
        } else if (op.getName().equals("suspendProcessDefinitionById")) {
            counter++;
            assertEquals("Suspend given process ID", op.getDescription());
            assertEquals("void", op.getReturnType());
            assertEquals(1, op.getSignature().length);
            assertEquals("java.lang.String", op.getSignature()[0].getType());
        } else if (op.getName().equals("activatedProcessDefinitionById")) {
            counter++;
            assertEquals("Activate given process ID", op.getDescription());
            assertEquals("void", op.getReturnType());
            assertEquals(1, op.getSignature().length);
            assertEquals("java.lang.String", op.getSignature()[0].getType());
        } else if (op.getName().equals("suspendProcessDefinitionByKey")) {
            counter++;
            assertEquals("Suspend given process ID", op.getDescription());
            assertEquals("void", op.getReturnType());
            assertEquals(1, op.getSignature().length);
            assertEquals("java.lang.String", op.getSignature()[0].getType());
        } else if (op.getName().equals("activatedProcessDefinitionByKey")) {
            counter++;
            assertEquals("Activate given process ID", op.getDescription());
            assertEquals("void", op.getReturnType());
            assertEquals(1, op.getSignature().length);
            assertEquals("java.lang.String", op.getSignature()[0].getType());
        } else if (op.getName().equals("deployProcessDefinition")) {
            counter++;
            assertEquals("Deploy Process Definition", op.getDescription());
            assertEquals("void", op.getReturnType());
            assertEquals(2, op.getSignature().length);
            assertEquals("java.lang.String", op.getSignature()[0].getType());
            assertEquals("java.lang.String", op.getSignature()[1].getType());
        }
    }
    assertEquals(6, counter);
    // check attributes
    assertNotNull(beanInfo.getAttributes());
    assertEquals(2, beanInfo.getAttributes().length);
    counter = 0;
    for (MBeanAttributeInfo attr : beanInfo.getAttributes()) {
        if (attr.getName().equals("ProcessDefinitions")) {
            counter++;
            assertEquals("List of Process definitions", attr.getDescription());
            assertEquals("java.util.List", attr.getType());
        } else if (attr.getName().equals("Deployments")) {
            counter++;
            assertEquals("List of deployed Processes", attr.getDescription());
            assertEquals("java.util.List", attr.getType());
        }
    }
    assertEquals(2, counter);
}
Also used : ModelMBean(javax.management.modelmbean.ModelMBean) MBeanInfo(javax.management.MBeanInfo) MBeanOperationInfo(javax.management.MBeanOperationInfo) MBeanAttributeInfo(javax.management.MBeanAttributeInfo) ObjectName(javax.management.ObjectName) Test(org.junit.Test)

Aggregations

MBeanOperationInfo (javax.management.MBeanOperationInfo)46 MBeanInfo (javax.management.MBeanInfo)33 MBeanAttributeInfo (javax.management.MBeanAttributeInfo)24 ObjectName (javax.management.ObjectName)18 MBeanParameterInfo (javax.management.MBeanParameterInfo)17 Test (org.junit.Test)10 ArrayList (java.util.ArrayList)8 MBeanServer (javax.management.MBeanServer)8 MBeanConstructorInfo (javax.management.MBeanConstructorInfo)7 MBeanNotificationInfo (javax.management.MBeanNotificationInfo)7 ReflectionException (javax.management.ReflectionException)5 Method (java.lang.reflect.Method)4 Descriptor (javax.management.Descriptor)4 TreeMap (java.util.TreeMap)3 Attribute (javax.management.Attribute)3 InstanceNotFoundException (javax.management.InstanceNotFoundException)3 IntrospectionException (javax.management.IntrospectionException)3 MalformedObjectNameException (javax.management.MalformedObjectNameException)3 OpenType (javax.management.openmbean.OpenType)3 IOException (java.io.IOException)2