Search in sources :

Example 41 with MBeanParameterInfo

use of javax.management.MBeanParameterInfo in project Payara by payara.

the class ConfigBeanJMXSupport method duckTypedToMBeanOperationInfo.

/**
 *    DuckTyped methods are <em>always</em> exposed as operations, never as Attributes.
 */
public MBeanOperationInfo duckTypedToMBeanOperationInfo(final DuckTypedInfo info) {
    final Descriptor descriptor = descriptor(info.duckTyped());
    final String name = info.name();
    final Class<?> type = remoteType(info.returnType());
    final String description = "@DuckTyped " + name + " of " + mIntf.getName();
    // how to tell?
    final int impact = MBeanOperationInfo.UNKNOWN;
    final List<MBeanParameterInfo> paramInfos = new ArrayList<MBeanParameterInfo>();
    int i = 0;
    for (final Class<?> paramClass : info.signature()) {
        final String paramName = "p" + i;
        final String paramType = remoteType(paramClass).getName();
        final String paramDescription = "parameter " + i;
        final MBeanParameterInfo paramInfo = new MBeanParameterInfo(paramName, paramType, paramDescription, null);
        paramInfos.add(paramInfo);
        ++i;
    }
    final MBeanParameterInfo[] paramInfosArray = CollectionUtil.toArray(paramInfos, MBeanParameterInfo.class);
    final MBeanOperationInfo opInfo = new MBeanOperationInfo(name, description, paramInfosArray, type.getName(), impact, descriptor);
    return opInfo;
}
Also used : MBeanOperationInfo(javax.management.MBeanOperationInfo) ArrayList(java.util.ArrayList) Descriptor(javax.management.Descriptor) MBeanParameterInfo(javax.management.MBeanParameterInfo)

Example 42 with MBeanParameterInfo

use of javax.management.MBeanParameterInfo in project Payara by payara.

the class MBeanInterfaceGenerator method generateOperations.

protected String generateOperations(MBeanOperationInfo[] infos) {
    final StringBuffer buf = new StringBuffer();
    for (int i = 0; i < infos.length; ++i) {
        final MBeanOperationInfo info = infos[i];
        final String name = info.getName();
        final String returnType = info.getReturnType();
        final MBeanParameterInfo[] paramInfos = info.getSignature();
        final String[] paramTypes = new String[paramInfos.length];
        for (int p = 0; p < paramInfos.length; ++p) {
            paramTypes[p] = paramInfos[p].getType();
        }
        final String[] paramNames = getParamNames(info);
        if (mEmitComments) {
            final String comment = getOperationComment(info, paramNames);
            if (comment.length() != 0) {
                buf.append(NEWLINE + indent(comment) + NEWLINE);
            }
        }
        final String method = formMethod(returnType, name, paramTypes, paramNames);
        buf.append(indent(method) + NEWLINE);
    }
    return (buf.toString());
}
Also used : MBeanOperationInfo(javax.management.MBeanOperationInfo) MBeanParameterInfo(javax.management.MBeanParameterInfo)

Aggregations

MBeanParameterInfo (javax.management.MBeanParameterInfo)42 MBeanOperationInfo (javax.management.MBeanOperationInfo)25 MBeanAttributeInfo (javax.management.MBeanAttributeInfo)14 MBeanInfo (javax.management.MBeanInfo)12 Descriptor (javax.management.Descriptor)7 ArrayList (java.util.ArrayList)6 ObjectName (javax.management.ObjectName)6 Test (org.junit.Test)5 MBeanConstructorInfo (javax.management.MBeanConstructorInfo)4 ModelMBeanOperationInfo (javax.management.modelmbean.ModelMBeanOperationInfo)4 Annotation (java.lang.annotation.Annotation)3 Method (java.lang.reflect.Method)3 TreeMap (java.util.TreeMap)3 Attribute (javax.management.Attribute)3 MBeanNotificationInfo (javax.management.MBeanNotificationInfo)3 DescriptorSupport (javax.management.modelmbean.DescriptorSupport)3 ImmutableDescriptor (javax.management.ImmutableDescriptor)2 OpenMBeanOperationInfoSupport (javax.management.openmbean.OpenMBeanOperationInfoSupport)2 OpenMBeanParameterInfo (javax.management.openmbean.OpenMBeanParameterInfo)2 OpenType (javax.management.openmbean.OpenType)2