com.sun.jaw.impl.agent.services.bootstrap
Class BootstrapSrv

java.lang.Object
  |
  +--com.sun.jaw.impl.agent.services.bootstrap.BootstrapSrv

public class BootstrapSrv
extends java.lang.Object
implements java.io.Serializable

This class implements the Bootstrap Service.

The Bootstrap Service must be run as a standalone application and enables the loading and instantiation of an agent/manager located in a remote server by specifying a URL that contains an m-let document file.

Use of the MLet tag

This service makes a restricted use of the MLET tag, the parameters used by this service are the following:

<MLET
CODE = agent/manager classfile
ARCHIVE = archiveList
[CODEBASE = codebaseURL]
>
</MLET>

where:

CODE = agent/manager classfile
This attribute specifies the full Java class name, including package name, of the agent/manager to be instantiated. The compiled .class file of the agent/manager must be contained in one of the .jar files specified by the ARCHIVE attribute.
ARCHIVE = "archivelist"
This mandatory attribute specifies one or more .jar files containing the agent/manager itself and m-beans or other Java classes to be used by the agent/manager to be instantiated. One of the .jar files must contain the file specified by the CODE parameter. If archivelist contains more than one file: All .jar files in archivelist must be stored in the directory specified by the code base URL.
CODEBASE = codebaseURL
This optional attribute specifies the code base URL of the agent/manager to be instantiated. It is the directory that contains the .jar files specified by the ARCHIVE attribute. Specify this attribute only if the .jar files are not in the same directory as the m-let document file. If this attribute is not specified, the base URL of the m-let document file is used.

Implementing the java.lang.Runnable interface

In order to be able to run the agent/manager after loading it from the remote server, the agent/manager itself needs to implement the java.lang.Runnable interface, therefore, the Bootstrap Service can load the class, create one instance of the class and invoke the run() method provided by the interface. The method run() will be responsible for instantiating the framework and adding the adaptor servers and services required by the agent being loaded or instantiating the adaptor clients required by the manager being loaded.

Setting the class loader

Besides implementing the java.lang.Runnable interface, other thing required by a bootstrapped agent is setting the Core Management Framework classloader to the classloader that has loaded the agent, i.e.

      ...
      // Create an instance of Framework
      Framework cmf = new Framework((MoRepSrvIf)rep, null);
 

// Set classloader for Framework cmf.setClassLoader(this.getClass().getClassLoader()); ...

Besides implementing the java.lang.Runnable interface, other thing required by a bootstrapped manager is setting the adaptor client classloader to the classloader that has loaded the manager, i.e.

      ...
      // Create an instance of AdaptorClient
      AdaptorClient adaptor = new AdaptorClient();
 

// Set classloader for AdaptorClient adaptor.setClassLoader(this.getClass().getClassLoader()); ...

Bootstrapping an Agent and Java DMK

Another interesting feature of this service is that it is possible to load Java DMK, contained in a jar file, at the same time that we load and run an agent. In order to do that specify the jar file containing Java DMK as one of the jar files in the MLet tag. If we want to do this the only files needed in the machine that invokes this service are the ones contained in these packages:

and if we want to use the RMI adaptor the files contained in the following packages are also required:

NOTE: None of the files specified above can be part of the jar file containing Java Dynamic Management Kit. Remove all of them before creating the corresponding jar file for Java Dynamic Management Kit. Also note that we cannot use the persistent repository with the bootstrap service.

Running the application

To invoke this standalone application enter the following command in your command-line:

      java com.sun.jaw.impl.agent.services.bootstrap.BootstrapSrv secure agent-URL [local-libdir]
 

where secure is a flag that specifies if this service is to be run in secure (true) or unsecure (false) mode, agent-URL specifies the URL location of the m-let document file containing the information for loading the agent and local-libdir specifies the local directory for storing native libraries before they are loaded into memory.

Security Mode

The security mode is not taken into account if the agent/application is run with JDK 1.2, this is due to the fact that when using JDK 1.2 the way security is specified is different according to the new JDK 1.2 Security Model and the tools provided with it.

This has been kept here just for source code backwards compatibility issues.

Remote Library Loading

The library loader uses the local file system to copy the libraries coming from the remote server before they are loaded into memory.

The default value for the library directory is specified in the following order:

  1. The value of the jaw.bootstrap.library.dir property.
  2. The return value of getTmpDir() in class DefaultPaths.

See Also:
Serialized Form

Constructor Summary
BootstrapSrv(java.lang.Boolean secure)
          Creates a BootstrapSrv object.
 
Method Summary
static java.lang.String getClassVersion()
          Gets the version of this class.
 java.lang.String getLibraryDirectory()
          Gets the current directory used by the library loader for storing native libraries before they are loaded into memory.
static void main(java.lang.String[] args)
           
 void performLoadURL(java.lang.String url)
          Loads all the classes contained in the jar files and instantiate and run the agent/manager identified by the class specified in the CODE parameter of the MLet tag.
 void setLibraryDirectory(java.lang.String libdir)
          Sets the current directory used by the library loader for storing native libraries before they are loaded into memory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BootstrapSrv

public BootstrapSrv(java.lang.Boolean secure)
Creates a BootstrapSrv object.
Parameters:
secure - Specifies if this service is to be run in secure (true) or unsecure (false) mode.
Method Detail

main

public static void main(java.lang.String[] args)

performLoadURL

public void performLoadURL(java.lang.String url)
Loads all the classes contained in the jar files and instantiate and run the agent/manager identified by the class specified in the CODE parameter of the MLet tag.
Parameters:
url - A string representation of the URL of the text file to be loaded.

getClassVersion

public static java.lang.String getClassVersion()
Gets the version of this class.
Returns:
The version of this class.

getLibraryDirectory

public java.lang.String getLibraryDirectory()
Gets the current directory used by the library loader for storing native libraries before they are loaded into memory.
Returns:
The current directory used by the library loader.

setLibraryDirectory

public void setLibraryDirectory(java.lang.String libdir)
Sets the current directory used by the library loader for storing native libraries before they are loaded into memory.
Parameters:
libdir - The directory to use.