mbeanInfo = (OpenMBeanInfo) mbeanServerConnection.getMBeanInfo(objectName);
Map<String, OpenMBeanAttributeInfo> attributesMap = new HashMap<String, OpenMBeanAttributeInfo>();
MBeanAttributeInfo[] attributes = mbeanInfo.getAttributes();
for (int i = 0; i < attributes.length; ++i)
{
OpenMBeanAttributeInfo openAttribute = (OpenMBeanAttributeInfo) attributes[i];
attributesMap.put(openAttribute.getName(), openAttribute);
}
MBeanOperationInfo[] operations = mbeanInfo.getOperations();
Map<Method, Action> result = new HashMap<Method, Action>();
Class[] interfaces = proxy.getClass().getInterfaces();
for (int i = 0; i < interfaces.length; ++i)
{
if (NotificationBroadcaster.class.isAssignableFrom(interfaces[i]))
{
result.put(ADD_NOTIFICATION_LISTENER, new AddNotificationListenerAction());
result.put(GET_NOTIFICATION_INFO, new GetNotificationInfoAction());
result.put(REMOVE_NOTIFICATION_LISTENER, new RemoveNotificationListenerAction());
result.put(REMOVE_NOTIFICATION_LISTENER_TRIPLET, new RemoveNotificationListenerTripletAction());
}
else
{
Method[] methods = interfaces[i].getMethods();
for (Method method : methods)
{
String methodName = method.getName();
Class returnType = method.getReturnType();
Class[] parameterTypes = method.getParameterTypes();
// Getter
if (methodName.startsWith("get") &&
methodName.length() > 3 &&
Void.TYPE.equals(returnType) == false &&
parameterTypes.length == 0)
{
String name = methodName.substring(3);
OpenMBeanAttributeInfo attribute = attributesMap.get(name);
if (attribute != null)
{
Type type = method.getGenericReturnType();
result.put(method, new GetAction(attribute, type));
continue;
}
}
// Getter (is)
else if(methodName.startsWith("is") &&
methodName.length() > 2 &&
Boolean.TYPE.equals(returnType) &&
parameterTypes.length == 0)
{
String name = methodName.substring(2);
OpenMBeanAttributeInfo attribute = attributesMap.get(name);
if (attribute != null)
{
Type type = method.getGenericReturnType();
result.put(method, new GetAction(attribute, type));
continue;
}
}
// Setter
else if(methodName.startsWith("set") &&
methodName.length() > 3 &&
Void.TYPE.equals(returnType) &&
parameterTypes.length == 1)
{
String name = methodName.substring(3);
OpenMBeanAttributeInfo attribute = attributesMap.get(name);
if (attribute != null)
{
result.put(method, new SetAction(attribute));
continue;
}