Search in sources :

Example 1 with Description

use of org.glassfish.admin.amx.annotation.Description in project Payara by payara.

the class MBeanInfoSupport method parameterInfos.

public static MBeanParameterInfo[] parameterInfos(final Method method) {
    final Class<?>[] sig = method.getParameterTypes();
    final Annotation[][] paramAnnotations = method.getParameterAnnotations();
    final MBeanParameterInfo[] infos = new MBeanParameterInfo[sig.length];
    for (int i = 0; i < sig.length; ++i) {
        final Class<?> paramClass = translatedType(sig[i]);
        final Annotation[] annotations = paramAnnotations[i];
        final Param p = getAnnotation(annotations, Param.class);
        final String paramName = (p == null || p.name().length() == 0) ? ("p" + i) : p.name();
        final Description d = getAnnotation(annotations, Description.class);
        String description = "";
        if (d != null && d.value().length() != 0) {
            description = d.value();
        }
        final String type = paramClass.getName();
        final MBeanParameterInfo info = new MBeanParameterInfo(paramName, type, description);
        infos[i] = info;
    }
    return (infos);
}
Also used : Description(org.glassfish.admin.amx.annotation.Description) Param(org.glassfish.admin.amx.annotation.Param) Annotation(java.lang.annotation.Annotation) MBeanParameterInfo(javax.management.MBeanParameterInfo)

Example 2 with Description

use of org.glassfish.admin.amx.annotation.Description in project Payara by payara.

the class MBeanInfoSupport method attributeInfo.

/**
 * Return MBeanAttributeInfo for the method.  If it's a getter,
 * it's marked as read-only, if it's a setter, it's marked as read/write.
 * @param m
 * @return
 */
public static MBeanAttributeInfo attributeInfo(final Method m) {
    final ManagedAttribute managed = m.getAnnotation(ManagedAttribute.class);
    if (managed == null) {
        return null;
    }
    final Description d = m.getAnnotation(Description.class);
    final String description = d == null ? "" : d.value();
    String attrName = JMXUtil.getAttributeName(m);
    final boolean isGetter = JMXUtil.isGetter(m);
    final boolean isSetter = JMXUtil.isSetter(m);
    final boolean isIs = JMXUtil.isIs(m);
    final MBeanAttributeInfo info = new MBeanAttributeInfo(attrName, m.getReturnType().getName(), description, isGetter, isSetter, isIs, null);
    return info;
}
Also used : Description(org.glassfish.admin.amx.annotation.Description) ManagedAttribute(org.glassfish.admin.amx.annotation.ManagedAttribute) MBeanAttributeInfo(javax.management.MBeanAttributeInfo)

Aggregations

Description (org.glassfish.admin.amx.annotation.Description)2 Annotation (java.lang.annotation.Annotation)1 MBeanAttributeInfo (javax.management.MBeanAttributeInfo)1 MBeanParameterInfo (javax.management.MBeanParameterInfo)1 ManagedAttribute (org.glassfish.admin.amx.annotation.ManagedAttribute)1 Param (org.glassfish.admin.amx.annotation.Param)1