/** * Return a method matching the specified signature */ public Method lookupMethod(String returnType, String name, String[] signature) { if (null == returnType) { throw new IllegalArgumentException("returnType cannot be null"); } if (null == name) { throw new IllegalArgumentException("method name cannot be null"); } return (Method) map.get(methodSignature(returnType, name, signature)); }
/** * Return a method matching the specified signature * * @param returnType the return type * @param name the name * @param signature the signature * @return the method */ public Method lookupMethod(String returnType, String name, String[] signature) { if (null == returnType) { throw new IllegalArgumentException("returnType cannot be null"); } if (null == name) { throw new IllegalArgumentException("method name cannot be null"); } return (Method) map.get(methodSignature(returnType, name, signature)); }
/** * creates the signature string to Method HashMap. */ protected HashMap createMap(Class resourceClass) { HashMap cmap = new HashMap(); if (resourceClass != null) { Method[] methods = resourceClass.getMethods(); for (int i = 0; i < methods.length; i++) { Method method = methods[i]; cmap.put(methodSignature(method), method); } } return cmap; }
/** * creates the signature string to Method HashMap. * * @param resourceClass the resource class * @return the map */ protected HashMap createMap(Class resourceClass) { HashMap cmap = new HashMap(); if (resourceClass != null) { Method[] methods = resourceClass.getMethods(); for (int i = 0; i < methods.length; i++) { Method method = methods[i]; cmap.put(methodSignature(method), method); } } return cmap; }
/** * Generates a signature string using a Method object. */ public static String methodSignature(Method method) { if (null == method) { throw new IllegalArgumentException("Method cannot be null"); } Class[] paramtypes = method.getParameterTypes(); String[] signature = new String[paramtypes.length]; for (int i = 0; i < signature.length; i++) { signature[i] = paramtypes[i].getName(); } return methodSignature(method.getReturnType().getName(), method.getName(), signature); }
/** * Generates a signature string using a Method object. * * @param method the method * @return signature */ public static String methodSignature(Method method) { if (null == method) { throw new IllegalArgumentException("Method cannot be null"); } Class[] paramtypes = method.getParameterTypes(); String[] signature = new String[paramtypes.length]; for (int i = 0; i < signature.length; i++) { signature[i] = paramtypes[i].getName(); } return methodSignature(method.getReturnType().getName(), method.getName(), signature); }
/** * Generates a signature string for an attribute setter method using standard rules * * @param info the info * @return signature */ public static String setterSignature(MBeanAttributeInfo info) { if (null == info) { throw new IllegalArgumentException("MBeanAttributeInfo cannot be null"); } String sig = null; if( info instanceof ModelMBeanAttributeInfo ) { ModelMBeanAttributeInfo minfo = (ModelMBeanAttributeInfo) info; Descriptor desc = minfo.getDescriptor(); String methodName = (String) desc.getFieldValue(ModelMBeanConstants.SET_METHOD); String[] typeSig = {info.getType()}; if( methodName != null ) sig = methodSignature(Void.TYPE.getName(), methodName, typeSig); } if( sig == null ) { String[] typeSig = {info.getType()}; sig = methodSignature(Void.TYPE.getName(), "set" + info.getName(), typeSig); } return sig; }
/** * Generates a signature string for an attribute setter method using standard rules */ public static String setterSignature(MBeanAttributeInfo info) { if (null == info) { throw new IllegalArgumentException("MBeanAttributeInfo cannot be null"); } String sig = null; if( info instanceof ModelMBeanAttributeInfo ) { ModelMBeanAttributeInfo minfo = (ModelMBeanAttributeInfo) info; Descriptor desc = minfo.getDescriptor(); String methodName = (String) desc.getFieldValue(ModelMBeanConstants.SET_METHOD); String[] typeSig = {info.getType()}; if( methodName != null ) sig = methodSignature(Void.TYPE.getName(), methodName, typeSig); } if( sig == null ) { String[] typeSig = {info.getType()}; sig = methodSignature(Void.TYPE.getName(), "set" + info.getName(), typeSig); } return sig; }
/** * Generates a signature string for an attribute getter method using standard rules */ public static String getterSignature(MBeanAttributeInfo info) { if (null == info) { throw new IllegalArgumentException("MBeanAttributeInfo cannot be null"); } String sig = null; if( info instanceof ModelMBeanAttributeInfo ) { ModelMBeanAttributeInfo minfo = (ModelMBeanAttributeInfo) info; Descriptor desc = minfo.getDescriptor(); String methodName = (String) desc.getFieldValue(ModelMBeanConstants.GET_METHOD); if( methodName != null ) sig = methodSignature(info.getType(), methodName, null); } if( sig == null ) { String prefix = (info.isIs()) ? "is" : "get"; sig = methodSignature(info.getType(), prefix + info.getName(), null); } return sig; }
/** * Generates a signature string for an attribute getter method using standard rules * * @param info the info * @return signature */ public static String getterSignature(MBeanAttributeInfo info) { if (null == info) { throw new IllegalArgumentException("MBeanAttributeInfo cannot be null"); } String sig = null; if( info instanceof ModelMBeanAttributeInfo ) { ModelMBeanAttributeInfo minfo = (ModelMBeanAttributeInfo) info; Descriptor desc = minfo.getDescriptor(); String methodName = (String) desc.getFieldValue(ModelMBeanConstants.GET_METHOD); if( methodName != null ) sig = methodSignature(info.getType(), methodName, null); } if( sig == null ) { String prefix = (info.isIs()) ? "is" : "get"; sig = methodSignature(info.getType(), prefix + info.getName(), null); } return sig; }
/** * Generates a signature string using the operation info. * * @param info the info * @return signature */ public static String operationSignature(MBeanOperationInfo info) { if (null == info) { throw new IllegalArgumentException("MBeanOperationInfo cannot be null"); } MBeanParameterInfo[] params = info.getSignature(); String[] signature = new String[params.length]; for (int i = 0; i < signature.length; i++) { signature[i] = params[i].getType(); } return methodSignature(info.getReturnType(), info.getName(), signature); }
/** * Generates a signature string using the operation info. */ public static String operationSignature(MBeanOperationInfo info) { if (null == info) { throw new IllegalArgumentException("MBeanOperationInfo cannot be null"); } MBeanParameterInfo[] params = info.getSignature(); String[] signature = new String[params.length]; for (int i = 0; i < signature.length; i++) { signature[i] = params[i].getType(); } return methodSignature(info.getReturnType(), info.getName(), signature); }