Java Code Examples for javax.management.MBeanOperationInfo#INFO

The following examples show how to use javax.management.MBeanOperationInfo#INFO . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PluggableMBeanServerImpl.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private boolean isOperationReadOnly(ObjectName name, String operationName, String[] signature) {
    MBeanInfo info;
    try {
        info = getMBeanInfo(name, false, true);
    } catch (Exception e) {
        //This should not happen, just in case say it is not RO
        return false;
    }
    if (info == null) {
        //Default to not RO
        return false;
    }
    for (MBeanOperationInfo op : info.getOperations()) {
        if (op.getName().equals(operationName)) {
            MBeanParameterInfo[] params = op.getSignature();
            if (params.length != signature.length) {
                continue;
            }
            boolean same = true;
            for (int i = 0 ; i < params.length ; i++) {
                if (!params[i].getType().equals(signature[i])) {
                    same = false;
                    break;
                }
            }
            if (same) {
                return op.getImpact() == MBeanOperationInfo.INFO;
            }
        }
    }
    //Default to not RO
    return false;
}
 
Example 2
Source File: MBeanInfoRenderer.java    From text-ui with GNU General Public License v3.0 4 votes vote down vote up
@Override
public LineRenderer renderer(Iterator<MBeanInfo> stream) {

  List<LineRenderer> renderers = new ArrayList<LineRenderer>();

  while (stream.hasNext()) {
    MBeanInfo info = stream.next();

    //
    TreeElement root = new TreeElement(info.getClassName());

    // Descriptor
    TableElement descriptor = new TableElement().
        overflow(Overflow.HIDDEN).
        rightCellPadding(1);
    Descriptor descriptorInfo = info.getDescriptor();
    if (descriptorInfo != null) {
      for (String fieldName : descriptorInfo.getFieldNames()) {
        String fieldValue = String.valueOf(descriptorInfo.getFieldValue(fieldName));
        descriptor.row(fieldName, fieldValue);
      }
    }

    // Attributes
    TableElement attributes = new TableElement().
        overflow(Overflow.HIDDEN).
        rightCellPadding(1).
        add(new RowElement().style(Decoration.bold.fg(Color.black).bg(Color.white)).add("NAME", "TYPE", "DESCRIPTION"));
    for (MBeanAttributeInfo attributeInfo : info.getAttributes()) {
      attributes.row(attributeInfo.getName(), attributeInfo.getType(), attributeInfo.getDescription());
    }

    // Operations
    TreeElement operations = new TreeElement("Operations");
    for (MBeanOperationInfo operationInfo : info.getOperations()) {
      TableElement signature = new TableElement().
          overflow(Overflow.HIDDEN).
          rightCellPadding(1);
      MBeanParameterInfo[] parameterInfos = operationInfo.getSignature();
      for (MBeanParameterInfo parameterInfo : parameterInfos) {
        signature.row(parameterInfo.getName(), parameterInfo.getType(), parameterInfo.getDescription());
      }
      TreeElement operation = new TreeElement(operationInfo.getName());
      String impact;
      switch (operationInfo.getImpact()) {
        case MBeanOperationInfo.ACTION:
          impact = "ACTION";
          break;
        case MBeanOperationInfo.INFO:
          impact = "INFO";
          break;
        case MBeanOperationInfo.ACTION_INFO:
          impact = "ACTION_INFO";
          break;
        default:
          impact = "UNKNOWN";
      }
      operation.addChild(new TableElement().
          add(
              new RowElement().add("Type: ", operationInfo.getReturnType()),
              new RowElement().add("Description: ", operationInfo.getDescription()),
              new RowElement().add("Impact: ", impact),
              new RowElement().add(new LabelElement("Signature: "), signature)
          )
      );

      operations.addChild(operation);
    }

    //
    root.addChild(
      new TableElement().leftCellPadding(1).overflow(Overflow.HIDDEN).
        row("ClassName", info.getClassName()).
        row("Description", info.getDescription()
      )
    );
    root.addChild(new TreeElement("Descriptor").addChild(descriptor));
    root.addChild(new TreeElement("Attributes").addChild(attributes));
    root.addChild(operations);

    //
    renderers.add(root.renderer());
  }




  return LineRenderer.vertical(renderers);
}
 
Example 3
Source File: ActiveMQServerControl.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
/**
 * Jon plugin doesn't recognize an Operation whose name is in
 * form getXXXX(), so add this one.
 */
@Operation(desc = "names of the diverts deployed on this server", impact = MBeanOperationInfo.INFO)
default String[] listDivertNames() {
   return getDivertNames();
}
 
Example 4
Source File: ActiveMQServerControl.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
@Operation(desc = "Get roles (as a JSON string) for a specific address match", impact = MBeanOperationInfo.INFO)
String getRolesAsJSON(@Parameter(desc = "an address match", name = "addressMatch") String addressMatch) throws Exception;
 
Example 5
Source File: ActiveMQServerControl.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
@Operation(desc = "Get roles for a specific address match", impact = MBeanOperationInfo.INFO)
Object[] getRoles(@Parameter(desc = "an address match", name = "addressMatch") String addressMatch) throws Exception;
 
Example 6
Source File: ActiveMQServerControl.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
@Operation(desc = "Search for Consumers", impact = MBeanOperationInfo.INFO)
String listConsumers(@Parameter(name = "options", desc = "Options") String options,
                     @Parameter(name = "pageNumber", desc = "Page Number") int page,
                     @Parameter(name = "pageSize", desc = "Page Size") int pageSize) throws Exception;
 
Example 7
Source File: ActiveMQServerControl.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
@Operation(desc = "Get a list of bindings associated with an address", impact = MBeanOperationInfo.INFO)
String listBindingsForAddress(@Parameter(name = "address", desc = "The address") String address) throws Exception;
 
Example 8
Source File: ActiveMQServerControl.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
@Operation(desc = "Search for Addresses", impact = MBeanOperationInfo.INFO)
String listAddresses(@Parameter(name = "options", desc = "Options") String options,
                     @Parameter(name = "pageNumber", desc = "Page Number") int page,
                     @Parameter(name = "pageSize", desc = "Page Size") int pageSize) throws Exception;
 
Example 9
Source File: ActiveMQServerControl.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
/**
 * Closes the consumer with the given id.
 */
@Operation(desc = "Closes the consumer with the id", impact = MBeanOperationInfo.INFO)
boolean closeConsumerWithID(@Parameter(desc = "The session ID", name = "sessionID") String sessionID,
                            @Parameter(desc = "The consumer ID", name = "ID") String ID) throws Exception;
 
Example 10
Source File: QueueControl.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
@Operation(desc = "Returns the number of the messages in the queue", impact = MBeanOperationInfo.INFO)
long countMessages() throws Exception;
 
Example 11
Source File: KnowledgeBaseMonitoring.java    From kogito-runtimes with Apache License 2.0 4 votes vote down vote up
/**
 *  Initialize the open mbean metadata
 */
private void initOpenMBeanInfo() {
    OpenMBeanAttributeInfoSupport[] attributes = new OpenMBeanAttributeInfoSupport[4];
    OpenMBeanConstructorInfoSupport[] constructors = new OpenMBeanConstructorInfoSupport[1];
    OpenMBeanOperationInfoSupport[] operations = new OpenMBeanOperationInfoSupport[2];
    MBeanNotificationInfo[] notifications = new MBeanNotificationInfo[0];

    try {
        // Define the attributes 
        attributes[0] = new OpenMBeanAttributeInfoSupport(ATTR_ID,
                                                          "Knowledge Base Id",
                                                          SimpleType.STRING,
                                                          true,
                                                          false,
                                                          false);
        attributes[1] = new OpenMBeanAttributeInfoSupport(ATTR_SESSION_COUNT,
                                                          "Number of created sessions for this Knowledge Base",
                                                          SimpleType.LONG,
                                                          true,
                                                          false,
                                                          false);
        attributes[2] = new OpenMBeanAttributeInfoSupport(ATTR_GLOBALS,
                                                          "List of globals",
                                                           globalsTableType,
                                                           true,
                                                           false,
                                                           false );
        attributes[3] = new OpenMBeanAttributeInfoSupport( ATTR_PACKAGES,
                                                           "List of Packages",
                                                           new ArrayType( 1,
                                                                          SimpleType.STRING ),
                                                           true,
                                                           false,
                                                           false );
        //No arg constructor                
        constructors[0] = new OpenMBeanConstructorInfoSupport( "KnowledgeBaseMonitoringMXBean",
                                                               "Constructs a KnowledgeBaseMonitoringMXBean instance.",
                                                               new OpenMBeanParameterInfoSupport[0] );
        //Operations 
        OpenMBeanParameterInfo[] params = new OpenMBeanParameterInfoSupport[0];
        operations[0] = new OpenMBeanOperationInfoSupport( OP_START_INTERNAL_MBEANS,
                                                           "Creates, registers and starts all the dependent MBeans that allow monitor all the details in this KnowledgeBase.",
                                                           params,
                                                           SimpleType.VOID,
                                                           MBeanOperationInfo.INFO );
        operations[1] = new OpenMBeanOperationInfoSupport( OP_STOP_INTERNAL_MBEANS,
                                                           "Stops and disposes all the dependent MBeans that allow monitor all the details in this KnowledgeBase.",
                                                           params,
                                                           SimpleType.VOID,
                                                           MBeanOperationInfo.INFO );

        //Build the info 
        info = new OpenMBeanInfoSupport( this.getClass().getName(),
                                         "Knowledge Base Monitor MXBean",
                                         attributes,
                                         constructors,
                                         operations,
                                         notifications );
    } catch ( Exception e ) {
        e.printStackTrace();
    }
}
 
Example 12
Source File: QueueControl.java    From activemq-artemis with Apache License 2.0 2 votes vote down vote up
/**
 * Lists the message counter for this queue.
 */
@Operation(desc = "List the message counters", impact = MBeanOperationInfo.INFO)
String listMessageCounter() throws Exception;
 
Example 13
Source File: QueueControl.java    From activemq-artemis with Apache License 2.0 2 votes vote down vote up
/**
 * Lists the message counter for this queue as a HTML table.
 */
@Operation(desc = "List the message counters as HTML", impact = MBeanOperationInfo.INFO)
String listMessageCounterAsHTML() throws Exception;
 
Example 14
Source File: Supervisor.java    From sis with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the operations impact, which is {@code INFO}.
 *
 * @return {@code INFO}.
 */
@Override
protected int getImpact(final MBeanOperationInfo info) {
    return MBeanOperationInfo.INFO;
}
 
Example 15
Source File: ActiveMQServerControl.java    From activemq-artemis with Apache License 2.0 2 votes vote down vote up
/**
 * Lists details about all sessions.
 * The returned String is a JSON string containing details about each and every session, e.g.:
 * <pre>
 * [
 *   {
 *     "sessionID":"e71d61d7-2176-11e8-9057-a0afbd82eaba",
 *     "creationTime":1520365520212,
 *     "consumerCount":1,
 *     "principal":"myUser"
 *   },
 *   {
 *     "sessionID":"e718a6e6-2176-11e8-9057-a0afbd82eaba",
 *     "creationTime":1520365520191,
 *     "consumerCount":0,
 *     "principal":"guest"
 *   }
 * ]
 * </pre>
 */
@Operation(desc = "List all sessions as a JSON string", impact = MBeanOperationInfo.INFO)
String listAllSessionsAsJSON() throws Exception;
 
Example 16
Source File: ActiveMQServerControl.java    From activemq-artemis with Apache License 2.0 2 votes vote down vote up
/**
 * Closes all the connections of clients connected to this server which matches the specified IP address.
 */
@Operation(desc = "Closes all the consumer connections for the given messaging address", impact = MBeanOperationInfo.INFO)
boolean closeConsumerConnectionsForAddress(@Parameter(desc = "a messaging address", name = "address") String address) throws Exception;
 
Example 17
Source File: ActiveMQServerControl.java    From activemq-artemis with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the names of the cluster-connections deployed on this server.
 */
@Operation(desc = "Names of the cluster-connections deployed on this server", impact = MBeanOperationInfo.INFO)
String[] getClusterConnectionNames();
 
Example 18
Source File: ActiveMQServerControl.java    From activemq-artemis with Apache License 2.0 2 votes vote down vote up
/**
 * Lists the addresses of the clients connected to this address which matches the specified IP address.
 */
@Operation(desc = "List the client addresses which match the given IP Address", impact = MBeanOperationInfo.INFO)
String[] listRemoteAddresses(@Parameter(desc = "an IP address", name = "ipAddress") String ipAddress) throws Exception;
 
Example 19
Source File: ActiveMQServerControl.java    From activemq-artemis with Apache License 2.0 2 votes vote down vote up
/**
 * Lists the addresses of all the clients connected to this address.
 */
@Operation(desc = "List the client addresses", impact = MBeanOperationInfo.INFO)
String[] listRemoteAddresses() throws Exception;
 
Example 20
Source File: QueueControl.java    From activemq-artemis with Apache License 2.0 2 votes vote down vote up
/**
 * Counts the number of messages in this queue matching the specified filter, grouped by the given property field.
 * In case of null property will be grouped in "null"
 * <br>
 * Using {@code null} or an empty filter will count <em>all</em> messages from this queue.
 */
@Operation(desc = "Returns the number of the messages in the queue matching the given filter, grouped by the given property field", impact = MBeanOperationInfo.INFO)
String countMessages(@Parameter(name = "filter", desc = "This filter separate account messages") String filter, @Parameter(name = "groupByProperty", desc = "This property to group by") String groupByProperty) throws Exception;