Strategies for working with the JMC custom tags

The JMC custom tags provide power and flexibility when working with JRun services and objects. This section describes some strategies for working with this custom tag library.

Finding services, classes, and methods

To find the possible attributes for services, look in the following places:

Using the service and server attributes

The service attribute specifies a JRun service on which to invoke the tag.

The service attribute does not refer only to a service name; it is a service path. A service path is a service that is specified in jrun.xml (or other XML configuration file) by its name and the names of its ancestors.

The service paths use the following syntax:

ParentService[.ChildService[.GrandChildService[...]]]

The following table shows several service paths:
Service path
Description
JRunServer
A top-level service.
JRunServer.ClusterManager
A service underneath a top-level service.
JRunTransactionService.PrivateJmsDomain
A service underneath a top-level service.

When you specify a service attribute in a JMC custom tag, you can also specify a server attribute.

The server attribute identifies the JRun server. The server attribute is usually used in combination with the service attribute, unless otherwise noted.

If you specify a service attribute but do not specify a server attribute, the tag defaults to the current JRun server on which the JSP is running.

Using the mbean attribute

The mbean attribute specifies a JRun service that has an MBean interface. JRun invokes the custom tag on this MBean. You can use the mbean attribute instead of the server and service attribute combination.

JRun services with MBean interfaces include the following:

The JRun API Javadocs describes these MBean interfaces. You can access these from the documentation homepage (/docs/dochome.htm) or from the jrun_root/docs/Javadocs directory. You can also access the JMC Javadocs from the sdk_root/docs/jmc-javadocs directory.

The mbean attribute in a JMC custom tag uses the following syntax:

mbean="domain:service=service_name"

In most cases, the domain is DefaultDomain; for example:

mbean="DefaultDomain:service=LoggerService"

You cannot specify an mbean attribute in a custom tag that is "Offline".

For information about offline properties, see the next section, "Understanding offline properties" .

Understanding offline properties

Some tags include the word Offline in the tag name. When a tag contains Offline in its name, the tag works directly with the JRun XML configuration file. The server does not have to be running in order for this tag to execute. If the server is running and you make a change with the offline tag, the change propagates the next time the server is restarted.

Offline custom tags can take the server and service attribute combination. If the server attribute is not specified, JRun invokes the tag on the JRun server on which the tag's JSP is running. You cannot use an mbean attribute in a custom tag that is Offline.

If the tag does not specify Offline in its name, the tag gets and sets the attribute using Java Management Extensions (JMX). The JRun server must be running and the change immediately takes place on the running server.

Some offline tags have non-offline (or online) counterparts. The following table lists offline tags and their online counterparts, if any:
Offline tag
Online counterpart
addOfflinePropertyValue
none
getOfflineProperty
getProperty
getOfflinePropertyValues
none
removeAllOfflinePropertyValues
none
setOfflineProperty
setProperty

Using the errorId attribute

The errorId attribute lets you handle exceptions within the JSP.

If you specify the errorId attribute and JRun throws an exception during the invocation of the tag, JRun stores the exception in a variable that is named by errorId. If the tag does not throw an exception, JRun sets the value of the variable that is named by errorId to null.

Using the type and id attributes

The id attribute names the return value of the JMC custom tags that get properties. The following example sets the id of the return value from the getProperty tag to port and then prints the value of port:

<jmcmgmt:getProperty service="WebService" name="Port" id="webPort" />
Port: <%= webPort %><BR>

By default, the id attribute specifies a variable of type String. If you specify a type attribute in combination with an id attribute, the variable specified by id is an instance of that class.

Most tags that have simple return values take an id attribute. Otherwise, they have special id attributes. These tags accept special attributes that end with Id. JRun sets the return value of the tag to an instance variable with the name that you specify. For example, if you specify directoryExistsId="exists", then you can use the variable named exists in your JSP page, as the following example shows:

...
<jmcmgmt:checkServer server="samples" directoryExistsId="exists"/>
<% if (exists.booleanValue()) %>
...

 

Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/jrun/4/JRun_SDK_Guide/custJMC3.htm