JMC custom tags reference

This section describes the custom tags in the JMC custom tag library.

add

Description

Adds a new data source, service, cluster, or server. The add tag can also add a server to a cluster. You specify properties for the add tag using the parameter tag. For information on using the parameter tag, see parameter.

Attributes

Attribute
Description
datasource=X
[server=Y]
Creates data source X, with the properties specified in the parameter tag, on server Y. For a list of properties to set for a new data source, see the samples server's jrun-resources.xml file.
The add tag implicitly sets the dbname property to the value of the data source property.
Exclude the server attribute to create a data source on the current server.
parentService=X service=Y classname=Z
Creates service Y under parent service path X, with properties specified using the parameter tags, using classname Z. JRun stores the service definition in the jrun.xml file.
To specify a top-level service, set parentService to an empty string ("").
JRun converts parameters to Strings using the toString method.
cluster=X
server=Y
Adds server Y to cluster X. JRun stores the cluster's settings in the ClusterManager service definition in the jmc.xml file.
cluster=X
Registers cluster X in the jmc.xml file.
You can optionally add servers at the same time by specifying them using the parameter tag within the add tag.
server=X
Adds server X using the following parameters set in the parameter tag:
  • servername����(Optional.) Registers a JRun server under a different name than the server property. Only used for remote JRun servers.
  • host����Specify "localhost" or a remote machine or hostname.
  • port����Specify a JNDI port to access a remote JRun server. If you specify this port, you must register a remote JRun server and not a local JRun server.
  • serverdir����Specifies the directory under which JRun creates a new JRun server.
  • initializefiles����Set to true to have JRun create a directory structure including configuration files for the new JRun server. If you set this attribute to true and the JRun server directory already exists, JRun overwrites the existing configuration files.

When you create a JRun server, JRun assigns unused port numbers to avoid conflicts with other JRun servers. However, JRun does not detect whether the ports are used by other applications.
JRun finds open ports and assigns the following for each new JRun server:
  • JNDI port
  • External web server connector proxy
  • Internal web server

When JRun registers a remote JRun server, JRun does not return an error if the JRun server does not exist.

Example

The following example adds a new server called MrBlond:

...
<%
��String host = "localhost";
��String server = "MrBlond";
��String serverName = "MrBlond";
��String serverDir = "c:/jrun4/servers/MrBlond";
%>
<jmcmgmt:add server="<%= server %>" errorId="error">
��<jmcmgmt:parameter name="host" value="<%= host %>"/>
��<jmcmgmt:parameter name="servername" value="<%= serverName %>"/>
��<jmcmgmt:parameter name="serverdir" value="<%= serverDir %>"/>
��<jmcmgmt:parameter name="initializefiles" value="true"/>
</jmcmgmt:add>
<% if (error != null) {
��out.println("<B>Error Creating server:</B>");
��out.println(error);
} else {
��out.println("Server created.");
} %>
...

addOfflinePropertyValue

Description

Appends the name and value as a property to the specified service in the jrun.xml file. The addOfflinePropertyValue tag is similar to setOfflineProperty tag. This tag is often used when adding properties for the DeployerService.

Attributes

Attribute
Description
service
(Required.) The name of the service.
server
The name of the JRun server. Defaults to the server on which the JSP is invoked.
name
Required. Specifies the name of the service's property.
value
Required. Specifies the value of the service's attribute.

The service attribute is not required, but a value for the service path can be implied. The following table describes the meanings of the settings of the server and service attributes:
Attribute set
Description
none
The current server's JRunAdminService.
server=X
Server X's JRunServer service.
service=Y
The current server's Y service.
server=X service=Y
Server X's Y service.

Example

The following example adds the property nick with a value of danger to the LoggerService in the jrun.xml file:

<jmcmgmt:addOfflinePropertyValue name="nick" value="danger" service="LoggerService"/>

checkServer

Description

Detects whether the directory specified for the server (in servers.xml) exists, and returns a list of any read-only files in that directory. By default, the samples server contains no read-only files or directories. The JMC uses the checkServer tag before deleting a JRun server. JRun throws an exception if the server cannot be reached.

Attributes

Attribute
Description
server
(Required.) The name of the JRun server.
directoryExistsId
Specifies a Boolean variable that returns true if the server directory exists.
readOnlyFilesId
Specifies a variable that returns a java.util.List of filepaths under the server directory that are read-only.

Example

The following example detects if the samples server exists and then lists any read-only files or directories in the samples directory:

...
<jmcmgmt:checkServer server="samples" directoryExistsId="exists"/>
<% if (exists.booleanValue()) %>
<% { %>
��<jmcmgmt:checkServer server="samples" readOnlyFilesId="read_only_files"/>
��<%= read_only_files %>
<% } %>
...

getConfiguration

Description

Retrieves an instance of the JMCConfiguration object and returns it as the variable specified by the id parameter.

The JMCConfiguration object is in the jrunx.jmc.management package. For more information on using the JMCConfiguration object, see the JRun API Javadocs in the SDK. You can access the JMC Javadocs from the sdk_root/docs/jmc-javadocs directory.

Attributes

Attribute
Description
id
(Required.) The variable name of the JMCConfiguration object.

Example

The following example gets the JMCConfiguration object and executes the getHosts method on it:

...
<%@ page import="java.util.*"%>
...
<jmcmgmt:getConfiguration id="configuration"/>
<% 
List validHosts = configuration.getHosts(); 
for (Iterator it = validHosts.iterator(); it.hasNext(); ) {
  String validHost = (String) it.next();
  out.println("validHost:" + validHost + "<BR>");
}
%>
...

getOfflineProperty

Description

Returns a property value of the specified service. The getOfflineProperty tag reads the property directly from a file, regardless of whether the server is running. The getOfflineProperty tag reads properties from jvm.config, jrun.xml, or jndi.properties files.

Attributes

Attribute
Description
service
Specifies the service path for the service.
server
The name of the JRun server. Defaults to the server on which the JSP is invoked.
name
(Required.) The name of the property.
id
(Required.) The variable name of the return value.
jvmProperty
Reads the property from the jvm.config file. The default is false.
jndiProperty
Reads the property from the jndi.properties file. The default is false.
default
Provides a default value if you do not define the jvmProperty or jndiProperty. Overrides the default of jrun.xml.

Usage

If you do not specify either the jvmProperty or jndiProperty attributes, the getOfflineProperty tag reads the property from the jrun.xml file. For details on how to specify a server and service path, see "Using the service and server attributes".

Example

The following example prints the values of the samples JRun server's Context.PROVIDER_URL and the web service's Port properties:

...
<%@ page import="java.io.*, java.util.*, javax.naming.Context"%>
...
<jmcmgmt:getOfflineProperty server="samples" jndiProperty="true" name="<%= Context.PROVIDER_URL %>" id="jndiURL" errorId="error1" />
<BR>
Context.PROVIDER_URL: <%= jndiURL %>
<BR>
<jmcmgmt:getOfflineProperty server="samples" service="WebService" name="Port" id="webPort" errorId="error2" />
Port: <%= webPort %>
<BR>
<% if (error1 != null) {
��out.println("<B>Error getting Port</B>");
��out.println(error2);
} else if (error2 != null) {
��out.println("<B>Error getting ProxyPort</B>");
��out.println(error3  );
} %>
...

getOfflinePropertyValues

Description

Returns a java.util.List of all the properties for the specified service's attributes in the jrun.xml file. For details on specifying a server and service path, see addOfflinePropertyValue.

Attributes

Attribute
Description
service
(Required.) The path of the service.
server
The name of the JRun server. Defaults to the server on which the JSP is invoked.
name
(Required.) The name of the property.
id
(Required.) The variable name of the return value.

Example

The following example gets the peers of the default JRun server in a cluster:

...
<jmcmgmt:getOfflinePropertyValues server="default" service="JRunServer.ClusterManager" name="unicastPeer" id="unicastPeerList"/>
...

getProperty

Description

Returns a JMX attribute as a String for the specified object. The getProperty tag returns a named attribute of an object, depending on which attribute you specify.

Attributes

Attribute
Description
name
(Required.) The name of the property.
id
The variable name of the returned attribute. If you do not specify the id attribute, JRun prints the value of the specified property.
defaultValue
Provides a default value if you do not specify an attribute. Overrides the JMCConfiguration object by default.
server
The name of the JRun server. Defaults to the server on which the JSP is invoked.

Usage

The following table describes the attributes you use to determine the target object:.
Attribute
Description
mbean
Returns the named property of the specified MBean.
dataSource
Returns the named property of the specified data source (the name of the resource in jrun-resources.xml).
service
Returns the named property of the specified service path.
rar
Returns the named property of the specified enterprise connector.
ear
Returns the named property of the specified enterprise application.
ejbJar
Returns the named property of the specified EJB JAR file.
webapp
Returns the named property of the specified web application.
cluster
Returns the named property of the specified cluster.
server
Returns the named property of the specified server.

Note:   If you do not specify any attributes, the getProperty tag returns the property for the JMCConfiguration object

Example

The following example gets the Port property of the WebService MBean on the current JRun server:

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

getServer

Description

Returns a jrunx.jmc.management.Server object.

Attributes

Attribute
Description
id
(Required.) The variable name of the returned Server object.
name
(Required.) The name of the server.

Example

The following example gets a Server object and executes several methods on it:

...
<%-- gets a jrunx.jmc.management.Server object based on the provided name --%>
<% String sname = "default";
���if (request.getParameter("serverName") != null) {
���sname = request.getParameter("serverName");
} %>
<jmcmgmt:getServer name="<%= sname %>" id="serverObj" />
Name: <%= serverObj.getServerName() %><BR>
Host: <%= serverObj.getHost() %><BR>
JNDI Port: <%= serverObj.getPort() %><BR>
Is Administratable?: <%= serverObj.isAdministratable() %><BR>
Is Local?: <%= serverObj.isLocal() %><BR>
<FORM METHOD="POST" ACTION="GetServer.jsp">
Enter Server Name:<BR><INPUT TYPE="text" NAME="serverName" value="<%= sname %>" SIZE=20>
<INPUT TYPE="Submit" VALUE="Submit"></FORM>
...

For more information on using the jrunx.jmc.management.Server object, see the JRun API Javadocs. You can access these from the sdk_root/docs/jmc-javadocs directory.

getServersOnHost

Description

Returns a java.util.List of server names on the specified host.

Attributes

Attribute
Description
active
Set to true to return only the names of servers that are currently running. The default is false.
id
(Required.) The variable name of the returned List object.
server
Returns a list of servers on the host on which the specified server is running.
For example, if your localhost is running the admin, samples, and default server, and you specify server="default", JRun returns admin and samples in a List.
You must specify either a server or a host attribute.
host
Returns a list of all servers on the specified host.
You must specify either a server or a host attribute.
oneOnly
Set to true to return only the name of the first server in the list. The default is false.

Example

The following example prints a List of servers on the specified host in a raw format:

...
<%@ page import="java.io.*, javax.naming.Context, java.util.*"%>
<% String host = "localhost"; %>
<jmcmgmt:getServersOnHost host="<%=host%>" id="servers"/>
<B><%= servers %></B>
...

For an example that iterates over the results of the getServersOnHost tag, see invoke.

invoke

Description

Invokes the method on the specified object. You can set parameters using the parameter tag, which must specify a value and, optionally, type. The parameter's name attribute is ignored.

<% String junk = ""; %>

Attributes

Attribute
Description
id
(Required.) The variable name of the returned object.
type
Specifies the class on which the method is invoked. Required if the method returns an object.
host
If only host is specified, then the JRunAdminService is accessed on the first running server detected on the host.
If host is specified and service is specified, then the service is accessed on the first running server detected on the host.
useAdminServer
Set to true in conjunction with specifying the server attribute to access the JRunAdminService on the first running server detected on the same host.
method
Specifies the method to invoke on the specified server or host.
server
If only server is specified and useAdminService is set to true, then the JRunAdminService is accessed on the next running server detected on the same host as the specified server (in other words, any other server).

Example

The following example prints a table of servers on the localhost and invokes the listServerPortsUsed method to get the ports that those servers use:

...
<%@ page import="javax.naming.Context, java.util.*"%>
<% String host = "localhost"; %>
<jmcmgmt:getServersOnHost host="<%=host%>" id="servers"/>
<%-- returns a java.util.List of servers --%>
<TABLE border=1>
��<TR>
����<TH>Server Name</TH><TH>Ports Used</TH>
��<% for (int i=0; i<servers.size(); i++) { %>
����<TR>
������<TD valign=top>
��������<% String serverName = (String)servers.get(i); %><B><%= serverName %></B>
������</TD>
������<jmcmgmt:getServer name="<%= serverName %>" id="serverObj"/>
������<jmcmgmt:invoke host="localhost" method="listServerPortsUsed" id="svrPorts" errorId="error" type="int[]" useAdminServer="false" >
��������<jmcmgmt:parameter value="<%= serverName %>"/>
������</jmcmgmt:invoke>
������<TD>
��������<% if (error == null) {
����������for (int j = 0; j < svrPorts.length; j++) {
������������out.println(String.valueOf(svrPorts[j]) + "<BR>");
����������}
��������} else {
����������error.printStackTrace();
��������} // end if-else statement %>
������</TD>
����</TR>
��<% } // end outer for loop %>
</TABLE>
...

isRemoteServer

Description

Detects if the server is remote; if it matches the specified value, then JRun executes the body of the tag.

Attributes

Attribute
Description
name
(Required.) The name of the JRun server.
value
(Required.) Set to true to detect if the server is remote. Set to false to determine if the server is local. If the return value is true, JRun executes the body of the tag.

Example

The following example prints "The server is remote" if the server is remote:

<jmcmgmt:isRemoteServer name="default" value="true" >
��The server is remote.
</jmcmgmt:isRemoteServer>

objects

Description

Returns an object or a collection of objects of the specified type.

Attributes

Attribute
Description
server
The name of the JRun server.
id
(Required.) The variable name of the returned object.
type
Set to the object type you want the objects tag to return. You can set the type attribute to one of the following values:
  • cluster
  • server
  • mbean
  • ejbjar
  • webapp
  • rar
  • ear
  • data_source
nonClusteredOnly
Set to true to return a list of servers that are not registered in the JMC as part of a cluster. Use this attribute when you set the type attribute to server. Server clusters are defined in the jmc.xml file.
sorted
Set to true to alphabetically sort the return values. Defaults to true.
classname
Specify the class. The objects tag returns MBean object names that match the specified class.
Use this tag when you set the type attribute to mbean.
id
The variable name representing the requested object. Use this attribute to iterate over the objects.
collectionId
The variable name of the collection of objects. Use this attribute to return the objects as a Collection instance.

Example 1

The following example iterates over the returned id attribute:

<jmcmgmt:objects server="default" type="ejbjar" id="ejb">
��<jmcmgmt:getProperty server="default" id="<%= ejb %>" name="Name"/>
</jmcmgmt:objects>

Example 2

The following example returns a collection of EJBs:

<jmcmgmt:objects server="default" type="ejbjar" collectionId="ejbs"/>

parameter

Description

Defines a parameter with a name and value pair. You cannot use the parameter tag as a stand alone tag. It must be embedded within other tags.

Attributes

Attribute
Description
value
The value of the specified parameter.
name
The name of the parameter.
type
(Optional.) Declares a classname type for the value. By default, the type of the value is inferred from the value. If JRun cannot infer the type, JRun converts the object to a String using the toString method.

Example

The following example adds the value of the parameter as an argument to the addDeployDirectory method call:

...
<jmcmgmt:invoke server="default" mbean="DefaultDomain:service=DeployerService" method="addDeployDirectory" errorId="error">
��<jmcmgmt:parameter value="C:\temp\deploy"/>
</jmcmgmt:invoke>
...

When using the invoke tag, JRun ignores the name attribute and requires the type attribute.

removeAllOfflinePropertyValues

Description

Removes all the named properties for the specified service.

Attributes

Attribute
Description
name
(Required.) The name of the attribute to remove.
service
(Required.) The path of the service.
server
The name of the JRun server. Defaults to the server on which the JSP is invoked.

Example

The following example removes the socketFactoryName attribute from the FastFreddy JRun server:

...
<jmcmgmt:removeAllOfflinePropertyValues server="FastFreddy" service="ProxyService" name="socketFactoryName" errorId="socketFactoryNameRemoveError"/>
...

remove

Description

Removes a server, cluster, or data source. The remove tag can also remove a server from a cluster.

Attributes

Attribute
Description
removeRemoteServer
Set to true to remove the specified remote server from the servers.xml file on the remote machine. The default is false, which removes the server from the local machine.
removeDirectory
Set to true to remove the specified server's files and directories. Otherwise, the server service is disabled but the server's files and directories remain intact.
server=X
If the server is local, JRun removes the server from the servers.xml file.
If the server is remote, JRun removes the server from the jmc.xml file.
cluster=X server=Y
Removes the server X from the cluster Y.
cluster=X
Removes the cluster.
datasource=X server=Y
Removes the data source from the specified server. If the server attribute is not specified, JRun removes the data source from the current server.

Example

The following example gets a list of available servers on the localhost and lets you delete one by selecting it from a drop-down list and clicking the Remove button:

...
<%@ page import="javax.naming.Context, java.util.*"%>
<jmcmgmt:getServersOnHost host="localhost" id="servers"/>
<FORM METHOD="POST" ACTION="Remove.jsp">
��<SELECT name="servers">
��<% for (int i=0; i<servers.size(); i++) { %>
����<% String serverName = (String)servers.get(i); %>
����<OPTION VALUE="<%= serverName %>"><%= serverName %></OPTION>
��<% } %>
</FORM>
<INPUT TYPE="Submit" VALUE="Remove">
<% 
��String server_to_remove = request.getParameter("servers");
��String removeRemote = "true";
��String removeDir = "false";
��if (server_to_remove != null) {
����try {
������if (removeRemote.equals("false")) { %>
��������<jmcmgmt:remove server="<%= server_to_remove %>" removeRemoteServer="false" removeDirectory="false"/>
������<% } else if (removeDir.equals("false")) { %>
����������<jmcmgmt:remove server="<%= server_to_remove %>" removeRemoteServer="true" removeDirectory="false"/>
������<% } else { %>
����������<jmcmgmt:remove server="<%= server_to_remove %>" removeRemoteServer="true" removeDirectory="true"/>
������<% } 
����} catch (Exception e) { } 
��}
%>
...

setOfflineProperty

Description

Sets an attribute for the specified MBean or service. The setOfflineProperty tag writes the property directly to a file, regardless of whether the server is running. The setOfflineProperty tag writes properties to the jvm.config, jrun.xml, or jndi.properties files.

Attributes

Attribute
Description
mbean
The name of the MBean.
service
The path of the service.
name
(Required.) The name of the property.
value
(Required.) The value of the property.
server
The name of the JRun server.
jvmProperty
Writes the property to the jvm.config file. The default is false.
jndiProperty
Writes the property to the jndi.properties file. The default is false.

setProperty

Description

Sets a runtime attribute for the specified MBean or service using JMX, and updates the jrun.xml file.

Attributes

Attribute
Description
name
(Required.) The name of the attribute.
value
(Required.) The value of the attribute.
mbean
The name of the JRun MBean.
server
The name of the JRun server.
service
The path of the JRun service.

Example

The following example gets LoggerService's format on the default JRun server and lets the user change it:

...

<jmcmgmt:getProperty server="default" mbean="DefaultDomain:service=LoggerService" name="Format" id="curLog" />
<BR>Current logging format:<BR><B><%= curLog %></B>
<% String newLog = request.getParameter("newLog");
 if (newLog != null) { %>
 <jmcmgmt:setProperty server="default" mbean="DefaultDomain:service=LoggerService" name="Format" value="<%= newLog %>"/>
 <% } %>
<FORM METHOD="POST" ACTION="SetLogFormat.jsp">
Change Logging Format:<BR><INPUT TYPE="text" NAME="newLog" value="<%= curLog %>" SIZE=60>
<INPUT TYPE="Submit" VALUE="Submit"></FORM>

...

status

Description

Indicates whether the specified server is running. Returns true if the specified server is running, or false if it is not, and conditionally executes the body of the tag.

Attributes

Attribute
Description
server
(Required.) The name of the server.
availableId
Set this attribute to store the return value of the status tag.
available
Set to true to execute if the server is running. Set to false to determine if the server is not running. If the return value is true, JRun executes the body of the tag.

Example 1

The following example gets the status of the default and samples servers and prints the results to the body of the page:

...
<jmcmgmt:status server="default" availableId="stat1" />
<jmcmgmt:status server="samples" availableId="stat2" />
Status of default server: <%= stat1 %><BR>
Status of samples server: <%= stat2 %>
...

Example 2

The following example executes the body of the status tag if the default server is running:

...
<% boolean running = false; %>
<jmcmgmt:status server="default" available="true">
��<% running = true; %>
</jmcmgmt:status>
<BR>Status of the default server: <%= running %>
...

 

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/custJMC4.htm