Search in sources :

Example 1 with ManagedOperation

use of org.activiti.management.jmx.annotations.ManagedOperation in project Activiti by Activiti.

the class MBeanInfoAssembler method doDoExtractAttributesAndOperations.

private void doDoExtractAttributesAndOperations(Class<?> managedClass, Map<String, ManagedAttributeInfo> attributes, Set<ManagedOperationInfo> operations) {
    LOG.trace("Extracting attributes and operations from class: {}", managedClass);
    for (Method method : managedClass.getMethods()) {
        // must be from declaring class
        if (method.getDeclaringClass() != managedClass) {
            continue;
        }
        LOG.trace("Extracting attributes and operations from method: {}", method);
        ManagedAttribute ma = method.getAnnotation(ManagedAttribute.class);
        if (ma != null) {
            String key;
            String desc = ma.description();
            Method getter = null;
            Method setter = null;
            if (ReflectUtil.isGetter(method)) {
                key = ReflectUtil.getGetterShorthandName(method);
                getter = method;
            } else if (ReflectUtil.isSetter(method)) {
                key = ReflectUtil.getSetterShorthandName(method);
                setter = method;
            } else {
                throw new IllegalArgumentException("@ManagedAttribute can only be used on Java bean methods, was: " + method + " on bean: " + managedClass);
            }
            // they key must be capitalized
            key = capitalize(key);
            // lookup first
            ManagedAttributeInfo info = attributes.get(key);
            if (info == null) {
                info = new ManagedAttributeInfo(key, desc);
            }
            if (getter != null) {
                info.setGetter(getter);
            }
            if (setter != null) {
                info.setSetter(setter);
            }
            attributes.put(key, info);
            continue;
        }
        // operations
        ManagedOperation mo = method.getAnnotation(ManagedOperation.class);
        if (mo != null) {
            String desc = mo.description();
            Method operation = method;
            operations.add(new ManagedOperationInfo(desc, operation));
        }
    }
}
Also used : Method(java.lang.reflect.Method) ManagedAttribute(org.activiti.management.jmx.annotations.ManagedAttribute) ManagedOperation(org.activiti.management.jmx.annotations.ManagedOperation)

Example 2 with ManagedOperation

use of org.activiti.management.jmx.annotations.ManagedOperation in project Activiti by Activiti.

the class ProcessDefinitionsMBean method getProcessDefinitionById.

@ManagedOperation(description = "get a specific process definition")
public List<String> getProcessDefinitionById(String id) {
    ProcessDefinition pd = repositoryService.createProcessDefinitionQuery().processDefinitionId(id).singleResult();
    List<String> item = new ArrayList<String>(3);
    item.add(pd.getId());
    item.add(pd.getName());
    item.add(Integer.toString(pd.getVersion()));
    item.add(Boolean.toString(pd.isSuspended()));
    item.add(pd.getDescription());
    return item;
}
Also used : ArrayList(java.util.ArrayList) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) ManagedOperation(org.activiti.management.jmx.annotations.ManagedOperation)

Example 3 with ManagedOperation

use of org.activiti.management.jmx.annotations.ManagedOperation in project Activiti by Activiti.

the class ProcessDefinitionsMBean method deployProcessDefinition.

@ManagedOperation(description = "Deploy Process Definition")
public void deployProcessDefinition(String resourceName, String processDefinitionFile) throws FileNotFoundException {
    DeploymentBuilder deploymentBuilder = repositoryService.createDeployment();
    Deployment deployment = deploymentBuilder.addInputStream(resourceName, new FileInputStream(processDefinitionFile)).deploy();
}
Also used : Deployment(org.activiti.engine.repository.Deployment) DeploymentBuilder(org.activiti.engine.repository.DeploymentBuilder) FileInputStream(java.io.FileInputStream) ManagedOperation(org.activiti.management.jmx.annotations.ManagedOperation)

Aggregations

ManagedOperation (org.activiti.management.jmx.annotations.ManagedOperation)3 FileInputStream (java.io.FileInputStream)1 Method (java.lang.reflect.Method)1 ArrayList (java.util.ArrayList)1 Deployment (org.activiti.engine.repository.Deployment)1 DeploymentBuilder (org.activiti.engine.repository.DeploymentBuilder)1 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)1 ManagedAttribute (org.activiti.management.jmx.annotations.ManagedAttribute)1