JMX taglib ver. 2.8

    Custom JSP taglib. This taglib provides basic operations for management: list MBeans, get/set attributes for Mbeans, invoke methods, scan attributes and operations etc. As an input attribute you can provide your MBeanServer or MBeanServerConnection info.

For example:

Body tag forEachMBean executes own body for the each MBean on your server.


<%@ taglib uri="taglib.tld" prefix="jmx" %>

<!-- print all MBeans on default server -->
<jmx:forEachMBean id="A">
   Mbean:<%=A%> <br>
</jmx:forEachMBean>

<!-- print MBeans in the domain jboss.mq (Jboss 3.0) -->
<jmx:forEachMBean pattern="jboss.mq.*:*" id="B">
   Mbean:<%=B%> <br>
</jmx:forEachMBean>

You can read/change attributes for existing MBeans:


<%@ taglib uri="taglib.tld" prefix="jmx" %>

<!-- print version of JBoss for default server -->
<jmx:getAttribute mbean="jboss.system:type=Server" attribute="Version"/>

<!-- change memory for Message Cache (Jboss 3.0) -->
<jmx:setAttribute mbean="jboss.mq:service=MessageCache" attribute="MaxMemoryMark">550</jmx:setAttribute>

Tag MbeanToXML lets you print XML "map" (dump) for any Mbean. For example, this code prints dump for ServerInfo bean in Jboss 3.0:


<%@ taglib uri="taglib.tld" prefix="jmx" %>
<%@ page contentType="text/xml" %>

<jmx:MbeanToXML mbean="jboss.system:type=ServerInfo"/>

and you will get some like this:


<?xml version="1.0" ?>
 <Mbean name="jboss.system:type=ServerInfo">
  <attribute name="HostAddress" type="java.lang.String" read="true" write="false">127.0.0.1</attribute>
  <attribute name="JavaVMVersion" type="java.lang.String" read="true" write="false">1.3.1_01</attribute>
  <attribute name="JavaVersion" type="java.lang.String" read="true" write="false">1.3.1_01</attribute>
  <attribute name="FreeMemory" type="java.lang.Long" read="true" write="false">2932152</attribute>
  ...
 </Mbean>

So you will be able to use XSL taglib (or DOM taglib) for output processing. See XML-related taglibs in Coldtags suite for details.

Tag forEachAttribute lets you iterate over attributes. For example, this code prints all the attributes for ServerInfo bean in Jboss 3.0:


<%@ taglib uri="taglib.tld" prefix="jmx" %>

<jmx:forEachAttribute mbean="jboss.system:type=ServerInfo">
 <p>Name:<%=attributeName%>
 <br>Type:<%=attributeType%>
 <br>Value:<%=attributeValue%>
</jmx:forEachAttribute>

You can invoke methods. For example:


<!-- print threads for Jboss 3.0 -->
<jmx:invoke mbean="jboss.system:type=ServerInfo" method="listThreadDump"/>

tag setParameter lets you specify parameters for your call:


<!-- create JMS Queue (Jboss 3.0) -->
<jmx:invoke mbean="jboss.mq:service=DestinationManager" method="createQueue">
  <jmx:setParameter>newQueue</jmx:setParameter>
</jmx:invoke>

Tags are:

forEachMBean

Body tag lets you iterate over existing MBeans. Parameters are:

1) server Optional parameter. Describes your MBeanServer. By default tag will use default server.
2) connection Optional parameter. Describes your MBeanServerConnection.
3) pattern Optional parameter. Describes a search pattern for MBeans. By default tag will scan all existing MBeans.
4) id Optional parameter. Describes a name for page scope variable (type is java.lang.String). You can use this variable in tag's body as a reference to the current name.

getMBeanDescription

Prints or saves in the page scope variable a description for the given MBean. Parameters are:

1) server Optional parameter. Describes your MBeanServer. By default tag will use default server.
2) connection Optional parameter. Describes your MBeanServerConnection.
3) mbean Describes a name for your bean
4) id Optional parameter. Describes a name for page scope variable (type is java.lang.String). Data will be saved in this variable. Without this parameter tag just prints data.

countMBeans

Tag lets you count MBeans. Parameters are:

1) server Optional parameter. Describes your MBeanServer. By default tag will use default server.
2) connection Optional parameter. Describes your MBeanServerConnection.
3) pattern Optional parameter. Describes a search pattern for MBeans. By default tag will count all existing MBeans.
4) id Optional parameter. Describes a name for page scope variable (type is java.lang.Integer) with result. By default tag just prints data.

getAttribute

Reads attribute for the given Mbean. Parameters are:

1) server Optional parameter. Describes your MBeanServer. By default tag will use default server.
2) connection Optional parameter. Describes your MBeanServerConnection.
3) mbean Describes a name for your bean
4) attribute Describes a name for the requested attribute
5) id Optional parameter. Describes a name for page scope variable (default type is java.lang.Object). Data will be saved in this variable. Without this parameter tag just prints data.
6) type Optional parameter. Describes a type for page scope variable. Default value is java.lang.Object.

getAttributeDescription

Prints or saves in the page scope variable a description for the given attribute. Parameters are:

1) server Optional parameter. Describes your MBeanServer. By default tag will use default server.
2) connection Optional parameter. Describes your MBeanServerConnection.
3) mbean Describes a name for your bean
4) attribute Describes a name for the requested attribute
5) id Optional parameter. Describes a name for page scope variable (type is java.lang.String). Data will be saved in this variable. Without this parameter tag just prints data.

canWriteAttribute

Body tag executes own body if you can set a new value for attribute. Parameters are:

1) server Optional parameter. Describes your MBeanServer. By default tag will use default server.
2) connection Optional parameter. Describes your MBeanServerConnection.
3) mbean Describes a name for your bean
4) attribute Describes a name for the requested attribute

canReadAttribute

Body tag executes own body if attribute is readable. Parameters are:

1) server Optional parameter. Describes your MBeanServer. By default tag will use default server.
2) connection Optional parameter. Describes your MBeanServerConnection.
3) mbean Describes a name for your bean
4) attribute Describes a name for the requested attribute

setAttribute

Body tag. Changes attribute for the given Mbean. Tag's body describes a new value for attribute. Parameters are:

1) server Optional parameter. Describes your MBeanServer. By default tag will use default server.
2) connection Optional parameter. Describes your MBeanServerConnection.
3) mbean Describes a name for your bean
4) attribute Describes a name for the updated attribute

MbeanToXML

Prints (dumps) attributes from the given Mbean in XML format. Parameters are:

1) server Optional parameter. Describes your MBeanServer. By default tag will use default server.
2) connection Optional parameter. Describes your MBeanServerConnection.
3) mbean Describes a name for your bean
4) id Optional parameter. Describes a name for page scope variable (type is java.lang.String). Data will be saved in this variable. Without this parameter tag just prints data.

forEachAttribute

Body tag lets you iterate over attributes. Tag executes own body for the each attribute from the given MBean. Parameters are:

1) server Optional parameter. Describes your MBeanServer. By default tag will use default server.
2) connection Optional parameter. Describes your MBeanServerConnection.
3) mbean Describes a name for your bean
4) idName Optional parameter. Describes a name for the nested variable (type is java.lang.String). This variable will keep a name of attribute. Default value is attributeName.
5) idType Optional parameter. Describes a name for the nested variable (type is java.lang.String). This variable will keep a type of attribute. Default value is attributeType.
6) idDescription Optional parameter. Describes a name for the nested variable (type is java.lang.String). This variable will keep a description of attribute. Default value is attributeDescription.
7) idReadable Optional parameter. Describes a name for the nested variable (type is java.lang.Boolean). This variable will keep a boolean indicator for read access. Default value is isReadable.
8) idWritable Optional parameter. Describes a name for the nested variable (type is java.lang.Boolean). This variable will keep a boolean indicator for write access. Default value is isWritable.
9) idValue Optional parameter. Describes a name for the nested variable (type is java.lang.Object). This variable will keep a value of attribute. Default value is attributeValue.

countAttributes

Tag lets you count attributes for the given MBean. Parameters are:

1) server Optional parameter. Describes your MBeanServer. By default tag will use default server.
2) connection Optional parameter. Describes your MBeanServerConnection.
3) mbean Describes a name for your bean. You can omit this parameter if you are using this tag inside of forEachMBean tag.
4) id Optional parameter. Describes a name for the page scope variable (type is java.lang.Integer) with result. By default tag just prints data.

countOperations

Tag lets you count operations (methods) for the given MBean. Parameters are:

1) server Optional parameter. Describes your MBeanServer. By default tag will use default server.
2) connection Optional parameter. Describes your MBeanServerConnection.
3) mbean Describes a name for your bean. You can omit this parameter if you are using this tag inside of forEachMBean tag.
4) id Optional parameter. Describes a name for the page scope variable (type is java.lang.Integer) with result. By default tag just prints data.

forEachOperation

Body tag lets you iterate over methods for the given MBean. Tag executes own body for the each operation (method) from the given MBean. Parameters are:

1) server Optional parameter. Describes your MBeanServer. By default tag will use default server.
2) connection Optional parameter. Describes your MBeanServerConnection.
3) mbean Describes a name for your bean
4) idName Optional parameter. Describes a name for the nested variable (type is java.lang.String). This variable will keep a name of method. Default value is operationName.
5) idType Optional parameter. Describes a name for the nested variable (type is java.lang.String). This variable will keep a return type of method. Default value is returnType.
6) idDescription Optional parameter. Describes a name for the nested variable (type is java.lang.String). This variable will keep a description for the current operation. Default value is operationDescription.

countParameters

Tag lets you count parameters for MBean's operations (methods). Parameters are:

1) server Optional parameter. Describes your MBeanServer. By default tag will use default server.
2) connection Optional parameter. Describes your MBeanServerConnection.
3) mbean Describes a name for your bean. You can omit this parameter if you are using this tag inside of forEachOperation tag.
4) method Describes a name for your method. You can omit this parameter if you are using this tag inside of forEachOperation tag. Otherwise tag counts parameters for the first method with the given name.
5) id Optional parameter. Describes a name for the page scope variable (type is java.lang.Integer) with result. By default tag just prints data.

forEachParameter

Body tag lets you iterate over parameters for MBean's method. Tag executes own body for the each parameter from the given method. Parameters are:

1) server Optional parameter. Describes your MBeanServer. By default tag will use default server.
2) connection Optional parameter. Describes your MBeanServerConnection.
3) mbean Describes a name for your bean. You can omit this parameter if you are using tag inside of forEachOperation.
4) method Describes a name for your method. You can omit this parameter if you are using this tag inside of forEachOperation tag. Otherwise tag counts parameters for the first method with the given name.
5) idName Optional parameter. Describes a name for the nested variable (type is java.lang.String). This variable will keep a name of parameter. Default value is parameterName.
6) idType Optional parameter. Describes a name for the nested variable (type is java.lang.String). This variable will keep a type of parameter. Default value is attributeType.
7) idDescription Optional parameter. Describes a name for the nested variable (type is java.lang.String). This variable will keep a description of parameter. Default value is attributeDescription.
8) idIndex Optional parameter. Describes a name for the nested variable (type is java.lang.Integer). This variable will keep an index (starting for 1) for the current parameter. Default value is parameterIndex.

isBasicParamTypes

Body tag tests a signature (list of parameters) for MBean's operation and executes own body if this list includes primitive types only. Primitive types are: boolean, char, short, int, long, float, double, String. So you can use this tag when you need to produce a form for input parameters. Parameters are:

1) server Optional parameter. Describes your MBeanServer. By default tag will use default server.
2) connection Optional parameter. Describes your MBeanServerConnection.
3) mbean Describes a name for your bean. You can omit this parameter if you are using tag inside of forEachOperation.
4) method Describes a name for your method. You can omit this parameter if you are using this tag inside of forEachOperation tag. Otherwise tag counts parameters for the first method with the given name.
5) id Optional parameter. Describes a name for the page scope variable (type is java.lang.Boolean). This variable will keep a result of testing.

invoke

Invokes method (function) from Mbean. Parameters are:

1) server Optional parameter. Describes your MBeanServer. By default tag will use default server.
2) connection Optional parameter. Describes your MBeanServerConnection.
3) mbean Describes a name for your bean
4) method Describes a name for your function
5) id Optional parameter. Describes a name for the page scope variable (default type is java.lang.Object). Result will be saved in this variable. Without this parameter tag just prints data.
6) type Optional parameter. Describes a type for page scope variable. Default value is java.lang.Object.

setParameter

Body tag. Tag's body describes a parameter for call. Parameters are:

1) type Optional parameter. Describes a type for parameter. Default value is java.lang.String.
1) value Optional parameter. Describes a value for the parameter. Tag's body will be ignored in this case..

isRegistered

Body tag, executes own body if the named MBean is registered. Parameters are:

1) server Optional parameter. Describes your MBeanServer. By default tag will use default server.
2) connection Optional parameter. Describes your MBeanServerConnection.
3) mbean Describes a name for your bean

isNotRegistered

Body tag, executes own body if the named MBean does not registered. Parameters are:

1) server Optional parameter. Describes your MBeanServer. By default tag will use default server.
2) connection Optional parameter. Describes your MBeanServerConnection.
3) mbean Describes a name for your bean

for downloading:

There are two versions of taglib. The first one is a generic and the second is tailored for Weblogic application server.

Library: jmxtag.jar  For Weblogic: jmxtag-wl.jar  Description: taglib.tld

© Coldbeans      Comments?

You can buy this component here

Also in Coldtags: