final List<MBeanAttributeInfo> attributeInfos = new ArrayList<MBeanAttributeInfo>();
final List<MBeanOperationInfo> operationInfos = new ArrayList<MBeanOperationInfo>();
final List<MBeanNotificationInfo> notificationInfos = new ArrayList<MBeanNotificationInfo>();
// class
final Description classDescription = findAnnotation(annotatedMBean, Description.class);
description = getDescription(classDescription, "a MBean built by OpenEJB");
final NotificationInfo notification = findAnnotation(annotatedMBean, NotificationInfo.class);
if (notification != null) {
final MBeanNotificationInfo notificationInfo = getNotificationInfo(notification);
notificationInfos.add(notificationInfo);
}
final NotificationInfos notifications = findAnnotation(annotatedMBean, NotificationInfos.class);
if (notifications != null && notifications.value() != null) {
for (final NotificationInfo n : notifications.value()) {
final MBeanNotificationInfo notificationInfo = getNotificationInfo(n);
notificationInfos.add(notificationInfo);
}
}
// methods
for (final Method m : annotatedMBean.getMethods()) {
final int modifiers = m.getModifiers();
if (m.getDeclaringClass().equals(Object.class)
|| !Modifier.isPublic(modifiers)
|| Modifier.isAbstract(modifiers)) {
continue;
}
if (findAnnotation(m, ManagedAttribute.class) != null) {
final String methodName = m.getName();
String attrName = methodName;
if ((attrName.startsWith("get") && m.getParameterTypes().length == 0
|| attrName.startsWith("set") && m.getParameterTypes().length == 1)
&& attrName.length() > 3) {
attrName = attrName.substring(3);
if (attrName.length() > 1) {
attrName = Character.toLowerCase(attrName.charAt(0)) + attrName.substring(1);
} else {
attrName = attrName.toLowerCase();
}
} else {
logger.warning("ignoring attribute " + m.getName() + " for " + annotatedMBean.getName());
}
if (methodName.startsWith("get")) {
getters.put(attrName, m);
} else if (methodName.startsWith("set")) {
setters.put(attrName, m);
}
} else if (findAnnotation(m, ManagedOperation.class) != null) {
operations.put(m.getName(), m);
String operationDescr = "";
final Description descr = findAnnotation(m, Description.class);
if (descr != null) {
operationDescr = getDescription(descr, "-");
}
operationInfos.add(newMethodDescriptor(operationDescr, m));
}
}
for (final Map.Entry<String, Method> e : getters.entrySet()) {
final String key = e.getKey();
final Method mtd = e.getValue();
String attrDescr = "";
final Description descr = findAnnotation(mtd, Description.class);
if (descr != null) {
attrDescr = getDescription(descr, "-");
}
try {
attributeInfos.add(new MBeanAttributeInfo(key, attrDescr, mtd, setters.get(key)));
} catch (final IntrospectionException ex) {
logger.warning("can't manage " + key + " for " + mtd.getName(), ex);
}
}
// for updatable but not readable attributes
for (final Map.Entry<String, Method> e : setters.entrySet()) {
final String key = e.getKey();
if (getters.get(key) != null) {
continue; //already done
}
final Method mtd = e.getValue();
String attrDescr = "";
final Description descr = findAnnotation(mtd, Description.class);
if (descr != null) {
attrDescr = getDescription(descr, "-");
}
try {