commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
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
  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}"/>
  @@ -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}"/>
  @@ -194,7 +191,7 @@
  -               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"
       <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
  This document contains the release notes for this version of the Commons
  Modeler package, and highlights changes since the previous version.
  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:
  * The MX4J Open Source Implementation of JMX (version 1.0-beta-3), from:
  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
  <title>Package Documentation for COMMONS-MODELER</title>
  <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="">
  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></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>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:
  <li>JMX Reference Implementation (version 1.0.1 or later) -
      <a href=""></a></li>
  <li>MX4J (version 1.0-beta-3 or later) -
      <a href=""></a></li>
  <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></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):
    &lt;?xml version="1.0"?&gt;
    &lt;!DOCTYPE mbeans-descriptors PUBLIC
     "-//Apache Software Foundation//DTD Model MBeans Configuration File"
      &lt;!-- ... other MBean definitions ... --&gt;
      &lt;mbean         name="Group"
              description="Group from a user database"
        &lt;attribute   name="description"
              description="Description of this group"
        &lt;attribute   name="groupname"
              description="Group name of this group"
        &lt;attribute   name="roles"
              description="MBean Names of roles for this group"
        &lt;attribute   name="users"
              description="MBean Names of user members of this group"
        &lt;operation   name="addRole"
              description="Add a new authorized role for this group"
          &lt;parameter name="role"
              description="Role to be added"
        &lt;operation   name="removeRole"
              description="Remove an old authorized role for this group"
          &lt;parameter name="role"
              description="Role to be removed"
        &lt;operation   name="removeRoles"
              description="Remove all authorized roles for this group"
      &lt;!-- ... other MBean definitions ... --&gt;
  <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
  <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:
      public void addRole(Role role);
  <p>is represented, in the MBean, by an <code>addRole</code> method that
  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:
      InputStream stream = this.getClass().getResourceAsStream
      Registry registry = Registry.getRegistry();
  <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
    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);
  <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>

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message