Search in sources :

Example 1 with ManagedAttribute

use of org.activiti.management.jmx.annotations.ManagedAttribute 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 ManagedAttribute

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

the class ProcessDefinitionsMBean method getProcessDefinitions.

@ManagedAttribute(description = "List of Process definitions")
public List<List<String>> getProcessDefinitions() {
    List<ProcessDefinition> deployments = repositoryService.createProcessDefinitionQuery().list();
    List<List<String>> result = new ArrayList<List<String>>(deployments.size());
    for (ProcessDefinition deployment : deployments) {
        List<String> item = new ArrayList<String>(3);
        item.add(deployment.getId());
        item.add(deployment.getName());
        item.add(Integer.toString(deployment.getVersion()));
        item.add(Boolean.toString(deployment.isSuspended()));
        item.add(deployment.getDescription());
        result.add(item);
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) List(java.util.List) ArrayList(java.util.ArrayList) ManagedAttribute(org.activiti.management.jmx.annotations.ManagedAttribute)

Example 3 with ManagedAttribute

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

the class ProcessDefinitionsMBean method getDeployments.

@ManagedAttribute(description = "List of deployed Processes")
public List<List<String>> getDeployments() {
    List<Deployment> deployments = repositoryService.createDeploymentQuery().list();
    List<List<String>> result = new ArrayList<List<String>>(deployments.size());
    for (Deployment deployment : deployments) {
        List<String> item = new ArrayList<String>(3);
        item.add(deployment.getId());
        item.add(deployment.getName());
        item.add(deployment.getTenantId());
        result.add(item);
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) Deployment(org.activiti.engine.repository.Deployment) List(java.util.List) ArrayList(java.util.ArrayList) ManagedAttribute(org.activiti.management.jmx.annotations.ManagedAttribute)

Aggregations

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