private OperationInfo(ManagedOperation operation, Method method) { _name = signature(method); _method = method; _proxied = operation.proxied(); Class<?> returnType = method.getReturnType(); _convert = isManagedObject(returnType); String returnSignature = _convert ? returnType.isArray() ? ObjectName[].class.getName() : ObjectName.class.getName() : returnType.getName(); String impactName = operation.impact(); int impact = MBeanOperationInfo.UNKNOWN; if ("ACTION".equals(impactName)) impact = MBeanOperationInfo.ACTION; else if ("INFO".equals(impactName)) impact = MBeanOperationInfo.INFO; else if ("ACTION_INFO".equals(impactName)) impact = MBeanOperationInfo.ACTION_INFO; String description = operation.value(); MBeanParameterInfo[] parameterInfos = parameters(method.getParameterTypes(), method.getParameterAnnotations()); _info = new MBeanOperationInfo(method.getName(), description, parameterInfos, returnSignature, impact); }
private void parseMethods(Class<?>... classes) { for (Class<?> klass : classes) { // Only work on the public method of the class, not of the hierarchy. for (Method method : klass.getDeclaredMethods()) { if (!Modifier.isPublic(method.getModifiers())) continue; ManagedAttribute attribute = method.getAnnotation(ManagedAttribute.class); if (attribute != null) { AttributeInfo info = new AttributeInfo(attribute, method); if (LOG.isDebugEnabled()) LOG.debug("Found attribute {} for {}: {}", info._name, klass.getName(), info); _attributes.put(info._name, info); } ManagedOperation operation = method.getAnnotation(ManagedOperation.class); if (operation != null) { OperationInfo info = new OperationInfo(operation, method); if (LOG.isDebugEnabled()) LOG.debug("Found operation {} for {}: {}", info._name, klass.getName(), info); _operations.put(info._name, info); } } } }
Object invoke(String name, String[] params, Object[] args, ObjectMBean mbean) throws ReflectionException, MBeanException { String signature = signature(name, params); OperationInfo info = findOperation(signature); if (info == null) throw new ReflectionException(new NoSuchMethodException(signature)); return info.invoke(args, mbean); }