/* * @(#)MLetContent.java 1.20 03/12/19 * * Copyright 2004 Sun Microsystems, Inc. All rights reserved. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */ package javax.management.loading; // java import import java.net.URL; import java.net.MalformedURLException; import java.util.Map; /** * This class represents the contents of the MLET tag. *

* The MLET tag has the following syntax: *

* <MLET
* CODE = class | OBJECT = serfile
* ARCHIVE = "archiveList"
* [CODEBASE = codebaseURL]
* [NAME = mbeanname]
* [VERSION = version]
* >
* [arglist]
* </MLET> *

* where: *

*
CODE = class
*
* This attribute specifies the full Java class name, including package name, of the MBean to be obtained. * The compiled .class file of the MBean must be contained in one of the .jar files specified by the ARCHIVE * attribute. Either CODE or OBJECT must be present. *
*
OBJECT = serfile
*
* This attribute specifies the .ser file that contains a serialized representation of the MBean to be obtained. * This file must be contained in one of the .jar files specified by the ARCHIVE attribute. If the .jar file contains a directory hierarchy, specify the path of the file within this hierarchy. Otherwise a match will not be found. Either CODE or OBJECT must be present. *
*
ARCHIVE = "archiveList"
*
* This mandatory attribute specifies one or more .jar files * containing MBeans or other resources used by * the MBean to be obtained. One of the .jar files must contain the file specified by the CODE or OBJECT attribute. * 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 MBean to be obtained. It identifies 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 MLet text file. If this attribute is not specified, the base URL of the MLet text file is used. *
*
NAME = mbeanname
*
* This optional attribute specifies the object name to be assigned to the * MBean instance when the MLet service registers it. If * mbeanname starts with the colon character (:), the domain * part of the object name is the domain of the agent. The MLet service * invokes the getDomain() method of the Framework class to * obtain this information. *
*
PERSISTENT = true | false
*
* This optional attribute specifies the persistency or not persistency of the * MBean instance when the MLet service registers it. *
*
VERSION = version
*
* This optional attribute specifies the version number of the MBean and * associated .jar files to be obtained. This version number can * be used to specify that the .jar files are loaded from the * server to update those stored locally in the cache the next time the MLet * text file is loaded. version must be a series of non-negative * decimal integers each separated by a period from the one that precedes it. *
*
paramlist
*
* This optional attribute specifies a list of one or more parameters for the * MBean to be instantiated. Each parameter in paramlist corresponds to a modification in the * modification list. Use the following syntax to specify each item in * paramlist:
*
*

*

<PARAM NAME=propertyName VALUE=value>
*

*

where:
* *
*

The MLet service passes all the values in the modification list as * String objects. *

* *

Note - Multiple MLET tags with the same * code base URL share the same instance of the MLetClassLoader * class. * * @version 3.3 02/08/99 * @author Sun Microsystems, Inc * * @since 1.5 */ class MLetContent { /** * A hash table of the attributes of the MLET tag * and their values. * @serial */ private Map attributes; /** * The MLet text file's base URL. * @serial */ private URL documentURL; /** * The base URL. * @serial */ private URL baseURL; /** * Creates an MLet instance initialized with attributes read * from an MLET tag in an MLet text file. * * @param url The URL of the MLet text file containing the MLET tag. * @param attributes A list of the attributes of the MLET tag. */ public MLetContent(URL url, Map attributes) { this.documentURL = url; this.attributes = attributes; // Initialize baseURL // String att = (String)getParameter("codebase"); if (att != null) { if (!att.endsWith("/")) { att += "/"; } try { baseURL = new URL(documentURL, att); } catch (MalformedURLException e) { // OK : Move to next block as baseURL could not be initialized. } } if (baseURL == null) { String file = documentURL.getFile(); int i = file.lastIndexOf('/'); if (i > 0 && i < file.length() - 1) { try { baseURL = new URL(documentURL, file.substring(0, i + 1)); } catch (MalformedURLException e) { // OK : Move to next block as baseURL could not be initialized. } } } if (baseURL == null) baseURL = documentURL; } // GETTERS AND SETTERS //-------------------- /** * Gets the attributes of the MLET tag. * @return A hash table of the attributes of the MLET tag * and their values. */ public Map getAttributes() { return attributes; } /** * Gets the MLet text file's base URL. * @return The MLet text file's base URL. */ public URL getDocumentBase() { return documentURL; } /** * Gets the code base URL. * @return The code base URL. */ public URL getCodeBase() { return baseURL; } /** * Gets the list of .jar files specified by the ARCHIVE * attribute of the MLET tag. * @return A comma-separated list of .jar file names. */ public String getJarFiles() { return (String)getParameter("archive"); } /** * Gets the value of the CODE * attribute of the MLET tag. * @return The value of the CODE * attribute of the MLET tag. */ public String getCode() { return (String)getParameter("code"); } /** * Gets the value of the OBJECT * attribute of the MLET tag. * @return The value of the OBJECT * attribute of the MLET tag. */ public String getSerializedObject() { return (String)getParameter("object"); } /** * Gets the value of the NAME * attribute of the MLET tag. * @return The value of the NAME * attribute of the MLET tag. */ public String getName() { return (String)getParameter("name"); } /** * Gets the value of the VERSION * attribute of the MLET tag. * @return The value of the VERSION * attribute of the MLET tag. */ public String getVersion() { return (String)getParameter("version"); } /** * Gets the value of the specified * attribute of the MLET tag. * * @param name A string representing the name of the attribute. * @return The value of the specified * attribute of the MLET tag. */ public Object getParameter(String name) { return (Object) attributes.get(name.toLowerCase()); } }