commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From craig...@apache.org
Subject cvs commit: jakarta-commons-sandbox/modeler/src/java/org/apache/commons/modeler package.html
Date Tue, 30 Apr 2002 04:13:05 GMT
craigmcc    02/04/29 21:13:05

  Modified:    modeler  build.xml
  Added:       modeler  RELEASE-NOTES.txt
               modeler/src/java/org/apache/commons/modeler package.html
  Log:
  Add package-level usage documentation in preparation for a release proposal.
  
  Revision  Changes    Path
  1.5       +6 -5      jakarta-commons-sandbox/modeler/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/modeler/build.xml,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- build.xml	16 Jan 2002 01:04:16 -0000	1.4
  +++ build.xml	30 Apr 2002 04:13:05 -0000	1.5
  @@ -3,7 +3,7 @@
   
   <!--
           "Modeler" component of the Jakarta Commons Subproject
  -        $Id: build.xml,v 1.4 2002/01/16 01:04:16 remm Exp $
  +        $Id: build.xml,v 1.5 2002/04/30 04:13:05 craigmcc Exp $
   -->
   
   
  @@ -37,7 +37,6 @@
     <property name="jaxp.parser.jar"         value="${jaxp.home}/crimson.jar"/>
     <property name="jaxp.xalan.jar"          value="${jaxp.home}/xalan.jar"/>
     <property name="jmx.jar"                 value="${jmx.home}/lib/jmxri.jar"/>
  -  <property name="jmxtools.jar"            value="${jmx.home}/lib/jmxtools.jar"/>
     <property name="junit.jar"               value="${junit.home}/junit.jar"/>
     <property name="commons-beanutils.jar"   value="${beanutils.home}/dist/commons-beanutils.jar"/>
     <property name="commons-collections.jar" value="${collections.home}/dist/commons-collections.jar"/>
  @@ -96,7 +95,6 @@
       <pathelement location="${commons-digester.jar}"/>
       <pathelement location="${commons-logging.jar}"/>
       <pathelement location="${jmx.jar}"/>
  -    <pathelement location="${jmxtools.jar}"/>
     </path>
   
   
  @@ -115,7 +113,6 @@
       <pathelement location="${commons-digester.jar}"/>
       <pathelement location="${commons-logging.jar}"/>
       <pathelement location="${jmx.jar}"/>
  -    <pathelement location="${jmxtools.jar}"/>
       <pathelement location="${junit.jar}"/>
     </path>
   
  @@ -194,7 +191,7 @@
                    author="true"
                   private="true"
                   version="true"
  -               doctitle="&lt;h1&gt;${component.title}&lt;/h1&gt;"
  +               doctitle="&lt;h1&gt;${component.title} (Version ${component.version})&lt;/h1&gt;"
               windowtitle="${component.title} (Version ${component.version})"
                    bottom="Copyright (c) 2001-2002 - Apache Software Foundation"
              classpathref="compile.classpath" />
  @@ -205,6 +202,10 @@
      description="Create binary distribution">
       <mkdir      dir="${dist.home}"/>
       <copy      file="../LICENSE"
  +              todir="${dist.home}"/>
  +    <copy      file="RELEASE-NOTES.txt"
  +              todir="${dist.home}"/>
  +    <copy      file="src/java/org/apache/commons/modeler/mbeans-descriptors.dtd"
                 todir="${dist.home}"/>
       <mkdir      dir="${build.home}/classes/META-INF"/>
       <copy      file="../LICENSE"
  
  
  
  1.1                  jakarta-commons-sandbox/modeler/RELEASE-NOTES.txt
  
  Index: RELEASE-NOTES.txt
  ===================================================================
  $Id: RELEASE-NOTES.txt,v 1.1 2002/04/30 04:13:05 craigmcc Exp $
  
                            Commons Modeler Package
                                  Version 1.0
                                 Release Notes
  
  
  INTRODUCTION:
  ============
  
  This document contains the release notes for this version of the Commons
  Modeler package, and highlights changes since the previous version.
  
  
  NEW FEATURES:
  ============
  
  This is the initial release of the Commons Modeler package, which supports
  the easy creation and management of Model MBeans that are compatible with
  the Java Management Extensions (JMX) 1.0 specification.  It has been tested
  in conjunction with two different JMX implementations:
  
  * The JMX Reference Implementation (version 1.0.1), available at:
    <http://java.sun.com/products/JavaManagement/download.html>
  
  * The MX4J Open Source Implementation of JMX (version 1.0-beta-3), from:
    <http://mx4j.sourceforge.net/>
  
  
  BUG REPORTS ADDRESSED:
  =====================
  
  No bug reports have been filed against Modeler.
  
  
  
  1.1                  jakarta-commons-sandbox/modeler/src/java/org/apache/commons/modeler/package.html
  
  Index: package.html
  ===================================================================
  <html>
  <head>
  <title>Package Documentation for COMMONS-MODELER</title>
  </head>
  <body bgcolor="white">
  <p>The <em>Modeler</em> component of the Jakarta Commons subproject
  offers convenient support for configuring and instantiating Model MBeans
  (management beans), as described in the JMX Specification.  It is typically
  used within a server-based application that wants to expose management
  features via JMX.  See the
  <a href="http://java.sun.com/products/JavaManagement/download.html">
  JMX Specification (Version 1.0)</a> for more information about Model MBeans
  and other JMX concepts.</p>
  
  <p>Model MBeans are very powerful - and the JMX specification includes a
  mechanism to use a standard JMX-provided base class to satisfy many of the
  requirements, without having to create custom Model MBean implementation
  classes yourself.  However, one of the requirements in creating such a
  Model MBean is to create the corresponding metadata information (i.e. an
  implementation of the
  <code>javax.management.modelmbean.ModelMBeanInfo</code> interface and its
  corresponding subordinate interfaces).  Creating this information can be
  tedious and error prone.  The <em>Modeler</em> package makes the process
  much simpler, because the required information is constructed dynamically
  from an easy-to-understand XML description of the metadata.  Once you have
  the metadata defined, and registered at runtime in the provided
  <a href="Registry.html">Registry</a>, <em>Modeler</em> also supports
  convenient factory methods to instantiate new Model MBean instances for you.
  </p>
  
  <p>The steps required to use Modeler in your server-based application are
  described in detail below.  You can find some simple usage code in the unit
  tests that come with Modeler (in the <code>src/test</code> subdirectory of the
  source distribution), and much more complex usage code in Tomcat 4.1 (in the
  <code>org.apache.catalina.mbeans</code> package).</p>
  
  
  <h3>1.  Acquire a JMX Implementation</h3>
  
  <p><em>Modeler</em> has been tested with two different JMX implementations:
  <ul>
  <li>JMX Reference Implementation (version 1.0.1 or later) -
      <a href="http://java.sun.com/products/JavaManagement/download.html">
      http://java.sun.com/products/JavaManagement/download.html</a></li>
  <li>MX4J (version 1.0-beta-3 or later) -
      <a href="http://mx4j.sourceforge.net/">http://mx4j.sourceforge.net</a></li>
  </ul>
  
  <p>After unpacking the release, you will need to ensure that the appropriate
  JAR file (<code>jmxri.jar</code> or <code>mx4j.jar</code>) is included
on your
  compilation classpath, and in the classpath of your server application when it
  is executed.</p>
  
  
  <h3>2.  Create a Modeler Configuration File</h3>
  
  <p><em>Modeler</em> requires that you construct a configuration file that
  describes the metadata ultimately need to construct the
  <code>javax.management.modelmbean.ModelMBeanInfo</code> structure that is
  required by JMX.  Your XML file must conform to the
  <a href="../../../../../../mbeans-descriptors.dtd">mbeans-descriptors.dtd</a>
  DTD that defines the acceptable structure.</p>
  
  <p>Fundamentally, you will be constructing an <code>&lt;mbean&gt;</code>
  element for each type of Model MBean that a registry will know how to create.
  Nested within this element will be other elements describing the constructors,
  attributes, operations, and notifications associated with this MBean.  See
  the comments in the DTD for detailed information about the valid attributes
  and their meanings.</p>
  
  <p>A simple example configuration file might include the following components
  (abstracted from the real definitions found in Tomcat 4.1's use of Modeler):
  </p>
  <pre>
  
    &lt;?xml version="1.0"?&gt;
    &lt;!DOCTYPE mbeans-descriptors PUBLIC
     "-//Apache Software Foundation//DTD Model MBeans Configuration File"
     "http://jakarta.apache.org/commons/dtds/mbeans-descriptors.dtd"&gt;
  
    &lt;mbeans-descriptors&gt;
  
      &lt;!-- ... other MBean definitions ... --&gt;
  
      &lt;mbean         name="Group"
                className="org.apache.catalina.mbeans.GroupMBean"
              description="Group from a user database"
                   domain="Users"
                    group="Group"
                     type="org.apache.catalina.Group"&gt;
  
        &lt;attribute   name="description"
              description="Description of this group"
                     type="java.lang.String"/&gt;
  
        &lt;attribute   name="groupname"
              description="Group name of this group"
                     type="java.lang.String"/&gt;
  
        &lt;attribute   name="roles"
              description="MBean Names of roles for this group"
                     type="java.lang.String[]"
                writeable="false"/&gt;
  
        &lt;attribute   name="users"
              description="MBean Names of user members of this group"
                     type="java.lang.String[]"
                writeable="false"/&gt;
  
        &lt;operation   name="addRole"
              description="Add a new authorized role for this group"
                   impact="ACTION"
               returnType="void"&gt;
          &lt;parameter name="role"
              description="Role to be added"
                     type="java.lang.String"/&gt;
        &lt;/operation&gt;
  
        &lt;operation   name="removeRole"
              description="Remove an old authorized role for this group"
                   impact="ACTION"
               returnType="void"&gt;
          &lt;parameter name="role"
              description="Role to be removed"
                     type="java.lang.String"/&gt;
        &lt;/operation&gt;
  
        &lt;operation   name="removeRoles"
              description="Remove all authorized roles for this group"
                   impact="ACTION"
               returnType="void"&gt;
        &lt;/operation&gt;
  
      &lt;/mbean&gt;
  
      &lt;!-- ... other MBean definitions ... --&gt;
  
    &lt;/mbeans-descriptors&gt;
  
  </pre>
  
  <p>This MBean represents an instance of <em>org.apache.catalina.Group</em>,
  which is an entity representing a group of users (with a shared set of security
  roles that all users in the group inherit) in a user database.  This MBean
  advertises support for four attributes (description, groupname, roles, and
  users) that roughly correspond to JavaBean properties.  By default, attributes
  are assumed to have read/write access.  For this particular MBean, the roles
  and users attributes are read-only (<code>writeable="false"</code>).  Finally,
  this MBean supports three operations (addRole, removeRole, and
  removeRoles) that roughly correspond to JavaBean methods on the underlying
  component.</p>
  
  <p>In general, <em>Modeler</em> provides a standard ModelMBean implementation
  that simply passes on JMX calls on attributes and operations directly through
  to the managed component that the ModelMBean is associated with.  For special
  case requirements, you can define a subclass of
  <a href="BaseModelMBean.html">BaseModelMBean</a> that provides override
  methods for one or more of these attributes (i.e. the property getter and/or
  setter methods) and operations (i.e. direct method calls).
  
  <p>For this particular MBean, a custom BaseModelMBean implementation subclass
  is described (<code>org.apache.catalina.mbeans.GroupMBean</code>) is
  configured.  It was necessary in this particular case because several of the
  underlying Catalina component's methods deal with internal objects or arrays of
  objects, rather than just the Strings and primitives that are supported by all
  JMX clients.  Thus, the following method on the <code>Group</code> interface:
  </p>
  <pre>
      public void addRole(Role role);
  </pre>
  <p>is represented, in the MBean, by an <code>addRole</code> method that
takes
  a String argument representing the role name of the required role.  The MBean's
  implementation class acts as an adapter, and looks up the required Role
  object (by name) before calling the <code>addRole</code> method on the
  underlying <code>Group</code> instance within the Server.</p>
  
  
  <h3>3.  Create Modeler Registry at Startup Time</h3>
  
  <p>The metadata information, and the corresponding Model MBean factory, is
  represented at runtime in an instance of <a href="Registry.html">Registry</a>
  whose contents are initialized from the configuration file prepared as was
  described above.  Typically, such a file will be included in the JAR file
  containing the MBean implementation classes themselves, and loaded as follows:
  </p>
  <pre>
      InputStream stream = this.getClass().getResourceAsStream
        ("/com/mycompany/mypackage/mbeans-descriptors.xml");
      Registry.loadRegistry(stream);
      stream.close();
      Registry registry = Registry.getRegistry();
  </pre>
  
  <p>Besides using the configuration file, it is possible to configure the
  registry metadata by hand, using the <code>addManagedBean()</code> and
  <code>removeManagedBean()</code> methods.  However, most users will find
  the standard support for loading a configuration file to be convenient
  and sufficient.</p>
  
  
  <h3>4.  Instantiate Model MBeans As Needed</h3>
  
  <p>When your server application needs to instantiate a new MBean and register
  it with the corresponding <code>MBeanServer</code>, it can execute code like
  this:</p>
  <pre>
    Group group = ... managed component instance ...;
    MBeanServer mserver = registry.getServer();
    ManagedBean managed = registry.findManagedBean("Group");
    String domain = managed.getDomain();
    if (domain == null) {
      domain = mserver.getDefaultDomain();
    }
    ModelMBean mbean = managed.createMBean(group);
    ObjectName oname = ... object name for this mbean ...;
    mserver.registerMBean(mbean, oname);
  </pre>
  
  <p>After the Model MBean has been created and registered, it is accessible to
  JMX clients through the standard JMX client APIs.  A comprehensive example
  that illustrates these techniques is the administrative web application that
  manages a Tomcat 4.1 server, including the ability to save an updated copy of
  the <code>conf/server.xml</code> file that represents the current configuration
  of all Tomcat components.</p>
  
  </body>
  </html>
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message