in examples-trunk/dynamic-proxy-to-access-mbean/src/main/java/org/superbiz/dynamic/mbean/DynamicMBeanHandler.java [46:68]
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
final String methodName = method.getName();
if (method.getDeclaringClass().equals(Object.class) && "toString".equals(methodName)) {
return getClass().getSimpleName() + " Proxy";
}
if (method.getAnnotation(PreDestroy.class) != null) {
return destroy();
}
final ConnectionInfo info = getConnectionInfo(method);
final MBeanInfo infos = info.getMBeanInfo();
if (methodName.startsWith("set") && methodName.length() > 3 && args != null && args.length == 1
&& (Void.TYPE.equals(method.getReturnType()) || Void.class.equals(method.getReturnType()))) {
final String attributeName = attributeName(infos, methodName, method.getParameterTypes()[0]);
info.setAttribute(new Attribute(attributeName, args[0]));
return null;
} else if (methodName.startsWith("get") && (args == null || args.length == 0) && methodName.length() > 3) {
final String attributeName = attributeName(infos, methodName, method.getReturnType());
return info.getAttribute(attributeName);
}
// operation
return info.invoke(methodName, args, getSignature(method));
}