Search in sources :

Example 1 with MBean

use of org.infinispan.jmx.annotations.MBean in project infinispan by infinispan.

the class Generator method writeMBeanMetadata.

private void writeMBeanMetadata(PrintWriter writer, Model.AnnotatedType c) {
    CharSequence binaryName = c.binaryName;
    Model.MComponent m = c.mComponent;
    MBean mbean = m.mbean;
    CharSequence superMBeanName = stringLiteral(m.superBinaryName);
    List<Model.MAttribute> attributes = m.attributes;
    List<Model.MOperation> operations = m.operations;
    writer.printf("      builder.registerMBeanMetadata(\"%s\",%n", binaryName);
    int count = attributes.size() + operations.size();
    writer.printf("         MBeanMetadata.of(\"%s\", \"%s\", %s%s%n", mbean.objectName(), mbean.description(), superMBeanName, optionalComma(-1, count));
    int i = 0;
    for (Model.MAttribute attribute : attributes) {
        writeManagedAttribute(writer, attribute.name, attribute.attribute, attribute.useSetter, attribute.type, attribute.is, makeGetterFunction(c, attribute), makeSetterFunction(c, attribute), optionalComma(i++, count));
    }
    for (Model.MOperation method : operations) {
        ManagedOperation operation = method.operation;
        // OperationMetadata(String methodName, String operationName, String description, String returnType,
        // OperationParameterMetadata... methodParameters)
        List<Model.MParameter> parameters = method.parameters;
        writer.printf("            new OperationMetadata(\"%s\", \"%s\", \"%s\", \"%s\"%s%n", method.name, operation.name(), operation.description(), method.returnType, optionalComma(-1, parameters.size()));
        for (int j = 0; j < parameters.size(); j++) {
            Model.MParameter parameter = parameters.get(j);
            // OperationParameterMetadata(String name, String type, String description)
            writer.printf("               new OperationParameterMetadata(\"%s\", \"%s\", \"%s\")%s%n", parameter.name, parameter.type, parameter.description, optionalComma(j, parameters.size()));
        }
        writer.printf("            )%s%n", optionalComma(i++, count));
    }
    writer.printf("      ));%n");
}
Also used : MBean(org.infinispan.jmx.annotations.MBean) ManagedOperation(org.infinispan.jmx.annotations.ManagedOperation)

Aggregations

MBean (org.infinispan.jmx.annotations.MBean)1 ManagedOperation (org.infinispan.jmx.annotations.ManagedOperation)1