com.sun.jaw.impl.agent.services.mlet
Class MLetSrv

java.lang.Object
  |
  +--com.sun.jaw.impl.agent.services.mlet.MLetSrv
Direct Known Subclasses:
MLetCacheVersionSrv

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

This class provides an implementation of the management applet or m-let service. The m-let service enables an agent to obtain m-beans remotely. The agent does this by loading a text file stored remotely that specifies information on the m-beans to be obtained. The location of the text file is specified by a URL. The information on each m-bean to be obtained is specified in a single instance of a tag, called the MLET tag. When a text file is loaded, each m-bean specified in the file is instantiated.

Registering an m-bean with the Core Management Framework

An m-bean instantiated by the m-let service is registered in one of the following ways:

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.mlet.library.dir property.
  2. The return value of getTmpDir() in class DefaultPaths.

See Also:
MLet, Serialized Form

Field Summary
protected  Framework cmf
          The reference to the core management framework.
protected  java.util.Vector mletList
          The list of instances of the MLet class found at the specified URL.
 
Constructor Summary
MLetSrv()
          Instantiates the m-let service.
 
Method Summary
protected  java.net.URL check(java.lang.String version, java.net.URL codebase, java.lang.String jarfile, MLet mlet)
          This method is to be overridden when extending this service to support caching and versioning.
 void deleteCmf()
          Removes all the MLetClassLoaders from the framework and deletes the m-let service.
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.
 void initCmf(Framework cmf, ObjectName name, boolean db, ModificationList list)
          Initializes the m-let service and registers it with the core management framework.
 java.net.URL performGetResource(java.lang.String codebase, java.lang.String resource)
          Gets the URL of a resource.
 java.net.URL performGetResource(java.net.URL codebase, java.lang.String resource)
          Gets the URL of a resource.
 java.io.InputStream performGetResourceAsStream(java.lang.String codebase, java.lang.String resource)
          Gets an input stream for a resource.
 java.io.InputStream performGetResourceAsStream(java.net.URL codebase, java.lang.String resource)
          Gets an input stream for a resource.
 void performLoadURL(java.lang.String url)
          Loads a text file containing MLET tags that define the m-beans to be added to the agent.
 void performLoadURL(java.net.URL url)
          Loads a text file containing MLET tags that define the m-beans to be added to the agent.
 java.util.Vector performLocalLoadURL(java.lang.String url)
          Loads a text file containing MLET tags that define the m-beans to be added to the agent.
 java.util.Vector performLocalLoadURL(java.net.URL url)
          Loads a text file containing MLET tags that define the m-beans to be added to the agent.
 java.util.Vector performRemoteLoadURL(java.lang.String url)
          Loads a text file containing MLET tags that define the m-beans to be added to the agent.
 java.util.Vector performRemoteLoadURL(java.net.URL url)
          Loads a text file containing MLET tags that define the m-beans to be added to the agent.
 void setLibraryDirectory(java.lang.String libdir)
          Sets the 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
 

Field Detail

cmf

protected Framework cmf
The reference to the core management framework.

mletList

protected java.util.Vector mletList
The list of instances of the MLet class found at the specified URL.
Constructor Detail

MLetSrv

public MLetSrv()
Instantiates the m-let service.
Method Detail

initCmf

public void initCmf(Framework cmf,
                    ObjectName name,
                    boolean db,
                    ModificationList list)
             throws InstanceAlreadyExistException
Initializes the m-let service and registers it with the core management framework.

This method is not intent to be called directly by the user.

Parameters:
cmf - The core management framework to register the service with.
name - The object name.
db - Indicates if persistent storage is required.
list - The modification list to use for setting up parameters.
Throws:
InstanceAlreadyExistException - The m-bean is already registered in the repository.

deleteCmf

public void deleteCmf()
Removes all the MLetClassLoaders from the framework and deletes the m-let service.

This method is not intent to be called directly by the user.


performLoadURL

public void performLoadURL(java.net.URL url)
                    throws ServiceNotFoundException
Loads a text file containing MLET tags that define the m-beans to be added to the agent. The location of the text file is specified by a URL.

This method is allowed in the code of an agent or a manager. It is similar to performLocalLoadURL (allowed only in agent code) or performRemoteLoadURL (allowed only in manager code) except that it does not return a value.

Parameters:
url - The URL of the text file to be loaded.
Throws:
ServiceNotFoundException - One of the following errors has occurred:
  • The m-let text file does not contain an MLET tag.
  • The m-let text file is not found.
  • A mandatory attribute of the MLET tag is not specified.
  • The value of url is null.

performLoadURL

public void performLoadURL(java.lang.String url)
                    throws ServiceNotFoundException
Loads a text file containing MLET tags that define the m-beans to be added to the agent. The location of the text file is specified by a string representation of its URL.

This method is allowed in the code of an agent or a manager. It is similar to performLocalLoadURL (allowed only in agent code) or performRemoteLoadURL (allowed only in manager code) except that it does not return a value.

Parameters:
url - A string representation of the URL of the text file to be loaded.
Throws:
ServiceNotFoundException - One of the following errors has occurred:
  • The m-let text file does not contain an MLET tag.
  • The m-let text file is not found.
  • A mandatory attribute of the MLET tag is not specified.
  • The value of url is null.

performLocalLoadURL

public java.util.Vector performLocalLoadURL(java.net.URL url)
                                     throws ServiceNotFoundException
Loads a text file containing MLET tags that define the m-beans to be added to the agent. The location of the text file is specified by a URL.

This method is allowed only in the code of an agent.

Parameters:
url - The URL of the text file to be loaded.
Returns:
A vector containing one entry per MLET tag in the m-let text file loaded. Each entry specifies either the reference of the m-bean instantiated, or a throwable object (that is, an error or an exception) if the m-bean could not be instantiated.
Throws:
ServiceNotFoundException - One of the following errors has occurred:
  • The m-let text file does not contain an MLET tag.
  • The m-let text file is not found.
  • A mandatory attribute of the MLET tag is not specified.
  • The value of url is null.

performLocalLoadURL

public java.util.Vector performLocalLoadURL(java.lang.String url)
                                     throws ServiceNotFoundException
Loads a text file containing MLET tags that define the m-beans to be added to the agent. The location of the text file is specified by a string representation of its URL.

This method is allowed only in the code of an agent.

Parameters:
url - A string representation of the URL of the text file to be loaded.
Returns:
A vector containing one entry per MLET tag in the m-let text file loaded. Each entry specifies either the reference of the m-bean instantiated, or a throwable object (that is, an error or an exception) if the m-bean could not be instantiated.
Throws:
ServiceNotFoundException - One of the following errors has occurred:
  • The m-let text file does not contain an MLET tag.
  • The m-let text file is not found.
  • A mandatory attribute of the MLET tag is not specified.
  • The value of url is null.

performRemoteLoadURL

public java.util.Vector performRemoteLoadURL(java.net.URL url)
                                      throws ServiceNotFoundException
Loads a text file containing MLET tags that define the m-beans to be added to the agent. The location of the text file is specified by a URL.

This method is allowed only in the code of a manager.

Parameters:
url - The URL of the text file to be loaded.
Returns:
A vector containing one entry per MLET tag in the m-let text file loaded. Each entry specifies either an instance of class MLet representing the parameters of the MLET tag for the m-bean instantiated, or a throwable object (that is, an error or an exception) if the m-bean could not be instantiated.
Throws:
ServiceNotFoundException - One of the following errors has occurred:
  • The m-let text file does not contain an MLET tag.
  • The m-let text file is not found.
  • A mandatory attribute of the MLET tag is not specified.
  • The value of url is null.

performRemoteLoadURL

public java.util.Vector performRemoteLoadURL(java.lang.String url)
                                      throws ServiceNotFoundException
Loads a text file containing MLET tags that define the m-beans to be added to the agent. The location of the text file is specified by a string representation of its URL.

This method is allowed only in the code of a manager.

Parameters:
url - A string representation of the URL of the text file to be loaded.
Returns:
A vector containing one entry per MLET tag in the m-let text file loaded. Each entry specifies either an instance of class MLet representing the parameters of the MLET tag for the m-bean instantiated, or a throwable object (that is, an error or an exception) if the m-bean could not be instantiated.
Throws:
ServiceNotFoundException - One of the following errors has occurred:
  • The m-let text file does not contain an MLET tag.
  • The m-let text file is not found.
  • A mandatory attribute of the MLET tag is not specified.
  • The value of url is null.

check

protected java.net.URL check(java.lang.String version,
                             java.net.URL codebase,
                             java.lang.String jarfile,
                             MLet mlet)
This method is to be overridden when extending this service to support caching and versioning.
Parameters:
version - The version number of the .jar file stored locally.
codebase - The base URL of the remote .jar file.
jarfile - The name of the .jar file to be loaded.
mlet - The MLet instance that represents the MLET tag.
Returns:
The URL where the .jar file is to be loaded from.

performGetResource

public java.net.URL performGetResource(java.net.URL codebase,
                                       java.lang.String resource)
Gets the URL of a resource.
Parameters:
codebase - A URL that identifies the code base of the m-let class loader to be used.
resource - The name of the resource.
Returns:
The URL of the resource or null if the resource could not be found.

performGetResource

public java.net.URL performGetResource(java.lang.String codebase,
                                       java.lang.String resource)
Gets the URL of a resource.
Parameters:
codebase - A string that identifies the code base of the m-let class loader to be used.
resource - The name of the resource.
Returns:
The URL of the resource or null if the resource could not be found.

performGetResourceAsStream

public java.io.InputStream performGetResourceAsStream(java.net.URL codebase,
                                                      java.lang.String resource)
Gets an input stream for a resource.
Parameters:
codebase - A URL that identifies the code base of the m-let class loader to be used.
resource - The name of the resource.
Returns:
An input stream for the resource or null if the resource could not be found.

performGetResourceAsStream

public java.io.InputStream performGetResourceAsStream(java.lang.String codebase,
                                                      java.lang.String resource)
Gets an input stream for a resource.
Parameters:
codebase - A string that identifies the code base of the m-let class loader to be used.
resource - The name of the resource.
Returns:
An input stream for the resource or null if the resource could not be found.

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 directory used by the library loader for storing native libraries before they are loaded into memory.
Parameters:
libdir - The directory used by the library loader.

getClassVersion

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