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