This section describes the custom tags in the JMC custom tag library.
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.
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.");
} %>
...
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.
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. |
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"/>
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.
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 %>
<% } %>
...
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.
| Attribute |
Description |
|---|---|
| id |
(Required.) The variable name of the JMCConfiguration object. |
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>");
}
%>
...
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.
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".
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 );
} %>
...
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.
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"/> ...
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.
The following table describes the attributes you use to determine the target object:.
Note: If you do not specify any attributes, the getProperty tag returns the property for the JMCConfiguration object
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> ...
Returns a jrunx.jmc.management.Server object.
| Attribute |
Description |
|---|---|
| id |
(Required.) The variable name of the returned Server object. |
| name |
(Required.) The name of the server. |
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.
Returns a java.util.List of server names on the specified host.
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.
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 = ""; %>
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>
...
Detects if the server is remote; if it matches the specified value, then JRun executes the body of the tag.
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>
Returns an object or a collection of objects of the specified type.
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>
The following example returns a collection of EJBs:
<jmcmgmt:objects server="default" type="ejbjar" collectionId="ejbs"/>
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.
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.
Removes all the named properties for the specified service.
The following example removes the socketFactoryName attribute from the FastFreddy JRun server:
...
<jmcmgmt:removeAllOfflinePropertyValues server="FastFreddy" service="ProxyService" name="socketFactoryName" errorId="socketFactoryNameRemoveError"/> ...
Removes a server, cluster, or data source. The remove tag can also remove a server from a cluster.
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) { }
��}
%>
...
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.
Sets a runtime attribute for the specified MBean or service using JMX, and updates the jrun.xml file.
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>
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.
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 %> ...
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