use of javax.management.Descriptor in project jdk8u_jdk by JetBrains.
the class MBeanIntrospector method getClassMBeanInfo.
/**
* Return the basic MBeanInfo for resources of the given class and
* per-interface data. This MBeanInfo might not be the final MBeanInfo
* for instances of the class, because if the class is a
* NotificationBroadcaster then each instance gets to decide what
* MBeanNotificationInfo[] to put in its own MBeanInfo.
*/
final MBeanInfo getClassMBeanInfo(Class<?> resourceClass, PerInterface<M> perInterface) {
MBeanInfoMap map = getMBeanInfoMap();
synchronized (map) {
WeakHashMap<Class<?>, MBeanInfo> intfMap = map.get(resourceClass);
if (intfMap == null) {
intfMap = new WeakHashMap<Class<?>, MBeanInfo>();
map.put(resourceClass, intfMap);
}
Class<?> intfClass = perInterface.getMBeanInterface();
MBeanInfo mbi = intfMap.get(intfClass);
if (mbi == null) {
MBeanInfo imbi = perInterface.getMBeanInfo();
Descriptor descriptor = ImmutableDescriptor.union(imbi.getDescriptor(), getMBeanDescriptor(resourceClass));
mbi = new MBeanInfo(resourceClass.getName(), imbi.getDescription(), imbi.getAttributes(), findConstructors(resourceClass), imbi.getOperations(), (MBeanNotificationInfo[]) null, descriptor);
intfMap.put(intfClass, mbi);
}
return mbi;
}
}
use of javax.management.Descriptor in project tomee by apache.
the class DynamicMBeanWrapper method parameters.
static MBeanParameterInfo[] parameters(final MBeanOperationInfo jvmInfo, final Class<?>[] classes, final Annotation[][] annots) {
final MBeanParameterInfo[] params = new MBeanParameterInfo[classes.length];
assert classes.length == annots.length;
String desc = "";
for (int i = 0; i < classes.length; i++) {
final Descriptor d = jvmInfo.getSignature()[i].getDescriptor();
final String pn = "arg" + i;
for (final Annotation a : annots[i]) {
final Class<? extends Annotation> type = a.annotationType();
if (type.equals(Description.class) || type.equals(OPENEJB_API_TO_JAVAX.get(Description.class))) {
desc = getDescription(annotationProxy(a, Description.class), desc);
break;
}
}
params[i] = new MBeanParameterInfo(pn, classes[i].getName(), desc, d);
}
return params;
}
use of javax.management.Descriptor in project spring-framework by spring-projects.
the class AbstractReflectiveMBeanInfoAssembler method getAttributeInfo.
/**
* Iterate through all properties on the MBean class and gives subclasses
* the chance to vote on the inclusion of both the accessor and mutator.
* If a particular accessor or mutator is voted for inclusion, the appropriate
* metadata is assembled and passed to the subclass for descriptor population.
* @param managedBean the bean instance (might be an AOP proxy)
* @param beanKey the key associated with the MBean in the beans map
* of the {@code MBeanExporter}
* @return the attribute metadata
* @throws JMException in case of errors
* @see #populateAttributeDescriptor
*/
@Override
protected ModelMBeanAttributeInfo[] getAttributeInfo(Object managedBean, String beanKey) throws JMException {
PropertyDescriptor[] props = BeanUtils.getPropertyDescriptors(getClassToExpose(managedBean));
List<ModelMBeanAttributeInfo> infos = new ArrayList<>();
for (PropertyDescriptor prop : props) {
Method getter = prop.getReadMethod();
if (getter != null && getter.getDeclaringClass() == Object.class) {
continue;
}
if (getter != null && !includeReadAttribute(getter, beanKey)) {
getter = null;
}
Method setter = prop.getWriteMethod();
if (setter != null && !includeWriteAttribute(setter, beanKey)) {
setter = null;
}
if (getter != null || setter != null) {
// If both getter and setter are null, then this does not need exposing.
String attrName = JmxUtils.getAttributeName(prop, isUseStrictCasing());
String description = getAttributeDescription(prop, beanKey);
ModelMBeanAttributeInfo info = new ModelMBeanAttributeInfo(attrName, description, getter, setter);
Descriptor desc = info.getDescriptor();
if (getter != null) {
desc.setField(FIELD_GET_METHOD, getter.getName());
}
if (setter != null) {
desc.setField(FIELD_SET_METHOD, setter.getName());
}
populateAttributeDescriptor(desc, getter, setter, beanKey);
info.setDescriptor(desc);
infos.add(info);
}
}
return infos.toArray(new ModelMBeanAttributeInfo[infos.size()]);
}
use of javax.management.Descriptor in project spring-framework by spring-projects.
the class AbstractMetadataAssemblerTests method testMetricDescriptorDefaults.
@Test
public void testMetricDescriptorDefaults() throws Exception {
ModelMBeanInfo info = getMBeanInfoFromAssembler();
Descriptor desc = info.getAttribute(CACHE_ENTRIES_METRIC).getDescriptor();
assertNull("Currency Time Limit should not be populated", desc.getFieldValue("currencyTimeLimit"));
assertNull("Persist Policy should not be populated", desc.getFieldValue("persistPolicy"));
assertNull("Persist Period should not be populated", desc.getFieldValue("persistPeriod"));
assertNull("Unit should not be populated", desc.getFieldValue("units"));
assertEquals("Display Name should be populated by default via JMX", CACHE_ENTRIES_METRIC, desc.getFieldValue("displayName"));
assertEquals("Metric Type should be GAUGE", "GAUGE", desc.getFieldValue("metricType"));
assertNull("Metric Category should not be populated", desc.getFieldValue("metricCategory"));
}
use of javax.management.Descriptor in project spring-framework by spring-projects.
the class AbstractMetadataAssemblerTests method testOperationDescriptor.
@Test
public void testOperationDescriptor() throws Exception {
ModelMBeanInfo info = getMBeanInfoFromAssembler();
Descriptor desc = info.getOperation("myOperation").getDescriptor();
assertEquals("Currency Time Limit should be 30", "30", desc.getFieldValue("currencyTimeLimit"));
assertEquals("Role should be \"operation\"", "operation", desc.getFieldValue("role"));
}
Aggregations