Java Dynamic Management Kit 3.2 Programming Guide
[ Previous ][ Fast Back ]Chapter 14. M-Let, Bootstrap and Launcher Services[ Fast Forward ][ Next ]

Launcher Service

The launcher service enables all the Java Dynamic Management applications running on a single machine to share the same base agent. It also enables you to load new applications into a base agent that is already running. The launcher service uses the m-let service for loading the m-beans and other resources that make up an application.

By sharing a single base agent among all the Java Dynamic Management applications that run on a single machine, conflicts over port allocations are avoided. This is because only one process is responsible for port allocations.

Using the launcher service involves:

Packaging of the Application Code

To use the launcher service, you have to create a .jar file containing all the code of your application. The launcher service does not impose any restrictions on where this file is located.

Adding the Launcher Service to an Agent

Before using the launcher service, you have to add it to an agent. Only one instance of the launcher service is allowed in a Java Dynamic Management agent. To add the launcher service, create an instance of the com.sun.jaw.impl.agent.services.mlet.LauncherSrv class.

Example 14-15 shows how to add the launcher service to an agent and register it with the repository.

Example 14-15. Adding the Launcher Service
//Set the name of the Java class to be used for the launcher service
launcherClassName = "com.sun.jaw.impl.agent.services.mlet.LauncherSrv";
...
//
// Add the launcher service and register it
//
String launcherName = domain +
                      ":com.sun.jaw.impl.agent.services.mlet.LauncherSrvMO";
Debug.println("Adding " + launcherClassName +
              " to CMF with name " + launcherName);
LauncherSrv launchSrv = (LauncherSrv)
	cmf.newObject(launcherClassName, launcherName, null);

Adding Code for Starting the Launcher Service

To start the launcher service, an agent must invoke the performLaunch() method of an instance of the launcher service, as shown in Example 14-16.

Example 14-16. Starting the Launcher Service
launchSrv.performLaunch();

Search Paths for MLET Text Files

Put the m-let text files used by the launcher service in the directory it searches when it is started. The launcher service requests the m-let service to load all the files it finds into the agent. A default search path is preset for the launcher service. If you want the launcher service to search in directories other than the defaults, you can specify the search path explicitly.

Default Search Path

The default search path depends on the operating environment:

Operating Environment

Directory

Solaris

installDir/SUNWconn/jaw/etc/launch

Windows NT

installDir\SUNWconn\jaw\etc\launch

Changing the Search Path

If you want the launcher service to search in directories other than the defaults, you can specify the search path by:

Example 14-17 shows how to use the setPath() method to change the search path. In this example, the launcher service will search for m-let text files in the /home/test/public_html directory.

Example 14-17. Using setPath() to Change the Launcher Service Search Path
launchSrv.setPath( "/home/test/public_html" );

To specify a path containing several directories, use the path separator for the operating environment in which your agent is running. To obtain the path separator, check the path.separator property.

Loading a Single M-Let Text File

To use the launcher service to load a single m-let text file, use the mletload command. To do this, type the command for your operating environment:

where mletfileURL is the URL of the m-let text file that you want the launcher service to load. There are no restrictions on where this file is located.

Example

Two applications, represented by the m-beans A.class and B.class are to be installed on the same machine. To enable them to share the same base agent, the code of the base agent includes code for instantiating and starting the launcher service. The code of each application is packaged as follows:

Application

Code Base URL

JAR Files

A.class

http://www.bar.com/jars/A

A1.jar, A2.jar

B.class

http://www.bar.com/jars/B

B1.jar, B2.jar

The m-let text files A.txt and B.txt are contained in the installDir/SUNWconn/jaw/etc/launch directory. They define the code to be obtained for each application when the launcher service is started. Their content is shown in Example 14-18 and Example 14-19.

Example 14-18. Content of the A.txt M-Let Text File
<MLET
   CODE=A.class
   ARCHIVE="A1.jar, A2.jar"
   CODEBASE=http://www.bar.com/jars/A
   NAME=:A.instance=1
>
</MLET>

Example 14-19. Content of the B.txt M-Let Text File
<MLET
   CODE=B.class
   ARCHIVE="B1.jar, B2.jar"
   CODEBASE=http://www.bar.com/jars/B
   NAME=:B.instance=1
>
</MLET>


[ Previous ][ Home ][ Next ]
Code Signing[ Up ]Event Handling, Alarm Clock, and Monitoring Services