private void introspect(Object instance, ManagementInfo info) { for (Method method : instance.getClass().getMethods()) { ManagementOperation annotation = method.getAnnotation(ManagementOperation.class); if (annotation == null) { continue; } String description = annotation.description(); if (description.trim().length() == 0) { description = null; } Signature signature = new Signature(method); String[] roleNames = annotation.rolesAllowed(); Set<Role> roles = new HashSet<Role>(); for (String name : roleNames) { roles.add(new Role(name)); } String path = annotation.path(); ManagementOperationInfo operationInfo = new ManagementOperationInfo(signature, path, OperationType.UNDEFINED, description, roles); info.addOperation(operationInfo); } }
Map<OperationKey, MethodHolder> operations = new HashMap<OperationKey, MethodHolder>(); for (ManagementOperationInfo operationInfo : info.getOperations()) { Method method = operationInfo.getSignature().getMethod(clazz); String description = operationInfo.getDescription(); Set<Role> roles = operationInfo.getRoles();
public void visitMethod(ManagementOperation annotation, Method method, Class<?> implClass, InjectingComponentType componentType, IntrospectionContext context) { ManagementInfo info = componentType.getManagementInfo(); if (info == null) { // there was no management annotation on the type - record an error Class<?> clazz = method.getDeclaringClass(); context.addError(new InvalidAnnotation("Implementation is missing @" + Management.class.getSimpleName(), clazz)); return; } String description = annotation.description(); if (description.trim().length() == 0) { description = null; } Signature signature = new Signature(method); Set<Role> roles = new HashSet<Role>(); for (String roleName : annotation.rolesAllowed()) { roles.add(new Role(roleName)); } String path = annotation.path(); org.fabric3.api.annotation.management.OperationType operationType = annotation.type(); OperationType type = OperationType.valueOf(operationType.toString()); ManagementOperationInfo operationInfo = new ManagementOperationInfo(signature, path, type, description, roles); info.addOperation(operationInfo); }