You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by jy...@apache.org on 2004/03/10 02:02:36 UTC

cvs commit: jakarta-jetspeed-2/cornerstone/src/java/org/apache/cornerstone/framework/jmx IModelMBeanDescriptorBuilder.java ModelMBeanInfoBuilderFactory.java IModelMBeanInfoBuilder.java ModelMBeanDescriptorBuilder.java ModelMBeanInfoBuilder.java MBeanManager.java BaseModelMBean.java JMXManager.java ModelMBeanDescriptorBuilderFactory.java

jyang       2004/03/09 17:02:36

  Added:       cornerstone/src/java/org/apache/cornerstone/framework/jmx
                        IModelMBeanDescriptorBuilder.java
                        ModelMBeanInfoBuilderFactory.java
                        IModelMBeanInfoBuilder.java
                        ModelMBeanDescriptorBuilder.java
                        ModelMBeanInfoBuilder.java MBeanManager.java
                        BaseModelMBean.java JMXManager.java
                        ModelMBeanDescriptorBuilderFactory.java
  Log:
  renamed from sysman; added JMXManager
  PR:
  Obtained from:
  Submitted by:	
  Reviewed by:	
  CVS: ----------------------------------------------------------------------
  CVS: PR:
  CVS:   If this change addresses a PR in the problem report tracking
  CVS:   database, then enter the PR number(s) here.
  CVS: Obtained from:
  CVS:   If this change has been taken from another system, such as NCSA,
  CVS:   then name the system in this line, otherwise delete it.
  CVS: Submitted by:
  CVS:   If this code has been contributed to Apache by someone else; i.e.,
  CVS:   they sent us a patch or a new module, then include their name/email
  CVS:   address here. If this is your work then delete this line.
  CVS: Reviewed by:
  CVS:   If we are doing pre-commit code reviews and someone else has
  CVS:   reviewed your changes, include their name(s) here.
  CVS:   If you have not had it reviewed then delete this line.
  
  Revision  Changes    Path
  1.1                  jakarta-jetspeed-2/cornerstone/src/java/org/apache/cornerstone/framework/jmx/IModelMBeanDescriptorBuilder.java
  
  Index: IModelMBeanDescriptorBuilder.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Jetspeed" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Jetspeed", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.cornerstone.framework.jmx;
  
  import javax.management.Descriptor;
  
  /**
   * This is the main interface for building JMX "On the fly" Model Mbeans
   * Descriptors.
   *
   */
  public interface IModelMBeanDescriptorBuilder
  {
      /**
       * This method returns the attribute description for the
       * specified attribute name, type, etc.
       *  
       * @param name this is the name of the attribute
       * @param displayName the name used to display the attribute
       * @param persistPolicy the persist policy @see ModelMBeanDescriptorBuilder
       * @param persistPeriod the period of persistance @see ModelMBeanDescriptorBuilder
       * @param defaultValue
       * @param getter the name of the getter method for this attribute
       * @param setter the name of the setter method for this attribute
       * @param currency @see ModelMBeanDescriptorBuilder
       * @return the attribute descriptor.
       */
      public Descriptor buildAttributeDescriptor(
          String name, 
          String displayName, 
          String persistPolicy, 
          String persistPeriod, 
          Object defaultValue, 
          String getter, 
          String setter, 
          String currency
      );
  
      /**
       * This builds a descriptor for methods on an object.
       * 
       * @param name the name of the mbean
       * @param displayName
       * 
       * @param role the role of this operation, 
       * ie is it a "getter", "setter", "operation"
       * or "constructor"
       * 
       * @param targetObject object on which to execute this operation
       * @param targetType possible values are : "ObjectReference"
       * 
       * @param ownerClass
       * @param currency
       * @return
       */                                                
      public Descriptor buildOperationDescriptor(
          String name, 
          String displayName, 
          String role, 
          Object targetObject, 
          Object targetType, 
          String ownerClass, 
          String currency
      );
  
      /**
       * Builds a descriptor for the Model MBean
       * 
       * @param name the name of the model mbean
       * @param displayName the display name for the model mbean
       * @param persistPolicy @see ModelMBeanDescriptorBuilder
       * @param persistPeriod @see ModelMBeanDescriptorBuilder
       * @param persistLocation where you want to persist the mbean
       * @param persistName the filename of the persistant state
       * @param log can take two values t - log all notifications
       * f - logs none @see ModelMBeanDescriptorBuilder
       * @param logFile the fully qualified path for a log file
       * 
       * @return the mbean descriptor
       * 
       */                                            
      public Descriptor buildMBeanDescriptor(
          String name, 
          String displayName, 
          String persistPolicy, 
          String persistPeriod, 
          String persistLocation, 
          String persistName, 
          String log, 
          String logFile
      );
  }
  
  
  1.1                  jakarta-jetspeed-2/cornerstone/src/java/org/apache/cornerstone/framework/jmx/ModelMBeanInfoBuilderFactory.java
  
  Index: ModelMBeanInfoBuilderFactory.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Jetspeed" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Jetspeed", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.cornerstone.framework.jmx;
  
  import org.apache.cornerstone.framework.factory.BaseFactory;
  import org.apache.log4j.Logger;
  
  /**
   * This creates an instance of the ModelMBeanInfoBuilder
   * 
   */
  
  public class ModelMBeanInfoBuilderFactory extends BaseFactory
  {
      public static final String REVISION = "$Revision: 1.1 $";
  
      /**
      * Returns a singleton instance of ModelMBeanInfoBuilderFactory
      * @return ModelMBeanInfoBuilderFactory singleton
      */
      public static ModelMBeanInfoBuilderFactory getSingleton()
      {
          return _Singleton;
      }
  
      /**
      * Creates an instance of the ModelMBeanInfoBuilder
      * @return ModelMBeanInfoBuilder Singleton instance
      */
      public Object createInstance()
      {
          IModelMBeanInfoBuilder modelMBeanInfoBuilder = new ModelMBeanInfoBuilder(); 
          
          //TODO: remove this...(IModelMBeanInfoBuilder)SingletonManager.getSingleton("com.cisco.salesit.framework.sysmgmt.ModelMBeanInfoBuilder");
      
          if ( modelMBeanInfoBuilder != null )
          {
              _Logger.info("created modelMBeanInfoBuilder");
          }else
          {
              _Logger.error("couldn't create modelMBeanInfoBuilder");
          }
              
          return (IModelMBeanInfoBuilder)modelMBeanInfoBuilder;
      }
  
      private static Logger _Logger = Logger.getLogger(ModelMBeanInfoBuilderFactory.class);
      private static ModelMBeanInfoBuilderFactory _Singleton = new ModelMBeanInfoBuilderFactory();
  }
  
  
  1.1                  jakarta-jetspeed-2/cornerstone/src/java/org/apache/cornerstone/framework/jmx/IModelMBeanInfoBuilder.java
  
  Index: IModelMBeanInfoBuilder.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Jetspeed" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Jetspeed", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.cornerstone.framework.jmx;
  
  import java.lang.reflect.Constructor;
  import java.lang.reflect.Method;
  
  import javax.management.Descriptor;
  import javax.management.modelmbean.ModelMBeanInfo;
  
  /**
   * The main interface for adding model mbean information on
   * Methods, attributes, notifications, constructors.
   * The models are added as needed basis, and then the MBEanInof
   * final model is obtained from the ModelMBeanInfo buildModelMBeanInfo
   * method.  Note the usage of the add methods is based on "add-as-needed" basis. 
   *
   */
  
  public interface IModelMBeanInfoBuilder
  {
      /**
       * This method adds a mbean model to the model builder
       * this method assumes a default descripotor for the 
       * method.
       * 
       * @param name
       * @param description
       * @param method
       */
      public void addModelMBeanMethod(
          String name, 
          String description, 
          Method method
      );
  
      /**
       * 
       * This method adds a method model to the model mbean
       * This method require a descriptor to be built using the
       * IModelMBeanDescriptorBuilder, @see IModelMBeanDescriptorBuilder
       * 
       * @param name the name of the method
       * @param paramTypes the parameters types of the 
       * @param paramNames the parameter names
       * @param paramDescs the paramtere descriptions
       * @param description description of the method
       * @param rtype the type of the return
       * @param type @see MBeanOperationInfo.INFO
       * @param desc the manually buildt descriptor using
       * ModelMBeanDescriptorBuilder @see ModelMBeanDescriptorBuilder
       * 
       */
  
      public void addModelMBeanMethod(
          String name, 
          String[] paramTypes, 
          String[] paramNames, 
          String[] paramDescs, 
          String description, 
          String rtype, 
          int type, 
          Descriptor desc
      );
  
      /**
       * This is method allows the addition of a Notificaiton model to the Builder
       * 
       * @param type
       * @param className
       * @param description
       * @param desc
       */                                        
  
      public void addModelMBeanNotification(
          String[] type, 
          String className, 
          String description, 
          Descriptor desc
      );
  
      /**
       * This is method allows the addition of a Notificaiton model to the Builder
       * It assumes a default descriptor.
       * 
       * @param types
       * @param name
       * @param description
       */
  
      public void addModelMBeanNotification(
          String[] types, 
          String name, 
          String description
      );
  
      /**
       * Adds an attribute Model to the Model Builder witha  manually created
       * Attribute Descriptor Object.  @see ModelMBeanDescriptorBuilder for building
       * Descriptors.
       * 
       * @param fname
       * @param ftype
       * @param read
       * @param write
       * @param is
       * @param description
       * @param desc
       */                                                                                        
  
      public void addModelMBeanAttribute(
          String fname,
          String ftype, 
          boolean read, 
          boolean write, 
          boolean is, 
          String description, 
          Descriptor desc
      );
  
      /**
       * This adds a constructor model to the Model Builder.
       * @see the ModelMBeanDescriptorBuilder for information on how
       * to build a descriptor that needs to be passed into this method.
       * 
       * @param c
       * @param description
       * @param desc
       */                                    
  
      public void addModelMBeanConstructor(
          Constructor c, 
          String description, 
          Descriptor desc
      );
  
      /**
       * This adds a constructor model to the Model Builder.
       * This method assumes a default Descripor for the constructor.
       *  
       * @param description
       * @param constructorMethod
       * 
       */
  
      public void addModelMBeanConstructor(
          String description, 
          Constructor constructorMethod
      );
  
      /**
       * This builds the main model for the model mbean.
       * @see ModelMBeanDescriptorBuilder on how to build a
       * descriptor for the MBean.
       * 
       * @param desc
       * @param className
       * @param description
       * @return
       * @throws Exception
       */                                                
  
      public ModelMBeanInfo buildModelMBeanInfo(
          Descriptor desc, 
          String className, 
          String description
      ) throws Exception;    
  }
  
  
  1.1                  jakarta-jetspeed-2/cornerstone/src/java/org/apache/cornerstone/framework/jmx/ModelMBeanDescriptorBuilder.java
  
  Index: ModelMBeanDescriptorBuilder.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Jetspeed" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Jetspeed", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.cornerstone.framework.jmx;
  
  import javax.management.Descriptor;
  import javax.management.modelmbean.DescriptorSupport;
  import org.apache.cornerstone.framework.core.BaseObject;
  import org.apache.log4j.Logger;
  
  /**
   * The Main builder for creating various desriptor objects for
   * Operations, attricutes, notifcation, and mbeans of a particular
   * Object that wishes to be modelled as an Model MBean.
   *
   */
  
  public class ModelMBeanDescriptorBuilder extends BaseObject implements IModelMBeanDescriptorBuilder
  {
      public static final String REVISION = "$Revision: 1.1 $";
      
      // Model MBean Descriptor fields
      //
      //
      public static final String NAME = "name";
      public static final String DESCRIPTOR_TYPE = "descriptorType";
      public static final String DESCRIPTOR_TYPE_ATTRIBUTE = "attribute";
      public static final String DESCRIPTOR_TYPE_OPERATION = "operation";
      public static final String DESCRIPTOR_TYPE_MBEAN = "mbean";
      public static final String DESCRIPTOR_TYPE_NOTIFICATION = "notification";
      public static final String DISPLAY_NAME = "displayName";
      public static final String PERSIST_POLICY = "persistPolicy";
      public static final String PERSIST_POLICY_ON_UPDATE = "OnUpdate";
      public static final String PERSIST_POLICY_ON_TIMER = "OnTimer";
      public static final String PERSIST_POLICY_NO_MORE_OFTEN_THAN = "NoMoreOftenThan";
      public static final String PERSIST_POLICY_DEFAULT_AS_NEVER = "Never";
      public static final String PERSIST_POLICY_AS_ALWAYS = "Always";
      public static final String PERSIST_PERIOD = "persistPeriod";
      public static final String PERSIST_PERIOD_IN_SECONDS = "10";
      public static final String PERSIST_LOCATION = "persistLocation";
      public static final String PERSIST_LOCATION_DEFAULT_DIR = ".";
      public static final String LOG = "log";
      public static final String LOG_ALL = "t";
      public static final String LOG_NONE = "f";
      public static final String LOG_FILE = "logFile";
      public static final String PERSIST_NAME = "persist_name";
      
      // Model MBean Attribute level desriptor
      //
      //
      public static final String GET_METHOD = "getMethod";
      public static final String SET_METHOD = "setMethod";
      public static final String CURRENCY_TIME_LIMIT = "currencyTimeLimit";
      public static final String CURRENCY_TIME_LIMIT_NEVER = "-1";
      public static final String CURRENCY_TIME_LIMIT_ALWAYS = "0";
      public static final String CURRENCY_TIME_LIMIT_10 = "10";
      
      // Model MBean Operations fields
      //
      //
      public static final String ROLE = "role";
      public static final String ROLE_GETTER = "getter";
      public static final String ROLE_SETTER = "setter";
      public static final String ROLE_OPERATION = "operation";
      public static final String ROLE_CONSTRUCTOR = "constructor";
      public static final String TARGET_OBJECT = "targetObject";
      public static final String TARGET_TYPE = "targetType";
      public static final String TARGET_TYPE_OBJECT_REFERENCE = "ObjectReference";
      public static final String CLASS = "class";
      public static final String DEFAULT = "default";
      
      /**
      * Returns a Singleton instance of ModelMBeanInfoBuilder
      * 
      * @return ModelMBeanInfoBuilder singleton
      */
      public static ModelMBeanDescriptorBuilder getSingleton()
      {
          return _singleton;
      }
      
      /**
       * This method returns the attribute description for the
       * specified attribute name, type, etc.
       *  
       * @param name this is the name of the attribute
       * @param displayName the name used to display the attribute
       * @param persistPolicy the persist policy @see ModelMBeanDescriptorBuilder
       * @param persistPeriod the period of persistance @see ModelMBeanDescriptorBuilder
       * @param defaultValue
       * @param getter the name of the getter method for this attribute
       * @param setter the name of the setter method for this attribute
       * @param currency @see ModelMBeanDescriptorBuilder
       * @return the attribute descriptor.
       */    
      public Descriptor buildAttributeDescriptor(
          String name, 
          String displayName, 
          String persistPolicy, 
          String persistPeriod, 
          Object defaultValue, 
          String getter, 
          String setter, 
          String currency
      )
      {
          Descriptor desc = new DescriptorSupport();
  
          if( name != null ) desc.setField(NAME,name );
          desc.setField(DESCRIPTOR_TYPE,DESCRIPTOR_TYPE_ATTRIBUTE);
          if( displayName != null ) desc.setField(DISPLAY_NAME, displayName );
          if( getter != null ) desc.setField(GET_METHOD, getter );
          if( setter != null ) desc.setField(SET_METHOD, setter );
          if( currency != null ) desc.setField(CURRENCY_TIME_LIMIT, currency );
          if( persistPolicy != null ) desc.setField(PERSIST_POLICY, persistPolicy );
          if( persistPeriod != null ) desc.setField(PERSIST_PERIOD, persistPeriod );
          if( defaultValue != null ) desc.setField(DEFAULT, defaultValue );
  
          return desc;
      }
  
      /**
       * This builds a descriptor for methods on an object.
       * 
       * @param name the name of the mbean
       * @param displayName
       * 
       * @param role the role of this operation, 
       * ie is it a "getter", "setter", "operation"
       * or "constructor"
       * 
       * @param targetObject object on which to execute this operation
       * @param targetType possible values are : "ObjectReference"
       * 
       * @param ownerClass
       * @param currency
       * @return
       */            
  
      public Descriptor buildOperationDescriptor(
          String name, 
          String displayName, 
          String role, 
          Object targetObject, 
          Object targetType, 
          String ownerClass, 
          String currency
      )
      {
          Descriptor desc = new DescriptorSupport();
  
          if( name != null ) desc.setField(NAME,name );
          desc.setField(DESCRIPTOR_TYPE,DESCRIPTOR_TYPE_OPERATION);
          if( displayName != null ) desc.setField(DISPLAY_NAME, displayName );
          if( role != null ) desc.setField(ROLE, role );
          if( targetObject != null ) desc.setField(TARGET_OBJECT, targetObject );
          if( targetType != null ) desc.setField(TARGET_TYPE, targetType );
          if( ownerClass != null ) desc.setField(CLASS, ownerClass );
          if( currency != null ) desc.setField(CURRENCY_TIME_LIMIT, currency );
  
          return desc;
      }
  
      /**
       * Builds a descriptor for the Model MBean
       * 
       * @param name the name of the model mbean
       * @param displayName the display name for the model mbean
       * @param persistPolicy @see ModelMBeanDescriptorBuilder
       * @param persistPeriod @see ModelMBeanDescriptorBuilder
       * @param persistLocation where you want to persist the mbean
       * @param persistName the filename of the persistant state
       * @param log can take two values t - log all notifications
       * f - logs none @see ModelMBeanDescriptorBuilder
       * @param logFile the fully qualified path for a log file
       * 
       * @return the mbean descriptor
       * 
       */                                            
  
      public Descriptor buildMBeanDescriptor(
          String name, 
          String displayName, 
          String persistPolicy, 
          String persistPeriod, 
          String persistLocation, 
          String persistName, 
          String log, 
          String logFile
      )
      {
          Descriptor desc = new DescriptorSupport();
  
          if( name != null ) desc.setField(NAME,name );
          desc.setField(DESCRIPTOR_TYPE,DESCRIPTOR_TYPE_MBEAN);
          if( displayName != null ) desc.setField(DISPLAY_NAME, displayName );
          if( persistLocation != null ) desc.setField(PERSIST_LOCATION, persistLocation );
          if( persistName != null ) desc.setField(PERSIST_NAME, persistName );
          if( log != null ) desc.setField(LOG, log );
          if( persistPolicy != null ) desc.setField(PERSIST_POLICY, persistPolicy );
          if( persistPeriod != null ) desc.setField(PERSIST_PERIOD, persistPeriod );
          if( logFile != null ) desc.setField(LOG_FILE, logFile );
  
          return desc;
      }
  
      private static Logger _Logger = Logger.getLogger(ModelMBeanDescriptorBuilder.class);
      private static ModelMBeanDescriptorBuilder _singleton = new ModelMBeanDescriptorBuilder();
  }
  
  
  1.1                  jakarta-jetspeed-2/cornerstone/src/java/org/apache/cornerstone/framework/jmx/ModelMBeanInfoBuilder.java
  
  Index: ModelMBeanInfoBuilder.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Jetspeed" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Jetspeed", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.cornerstone.framework.jmx;
  
  import java.lang.reflect.Constructor;
  import java.lang.reflect.Method;
  import java.util.Collection;
  import java.util.HashMap;
  import java.util.Iterator;
  import java.util.Map;
  import javax.management.Descriptor;
  import javax.management.MBeanFeatureInfo;
  import javax.management.MBeanParameterInfo;
  import javax.management.modelmbean.ModelMBeanAttributeInfo;
  import javax.management.modelmbean.ModelMBeanConstructorInfo;
  import javax.management.modelmbean.ModelMBeanInfo;
  import javax.management.modelmbean.ModelMBeanInfoSupport;
  import javax.management.modelmbean.ModelMBeanNotificationInfo;
  import javax.management.modelmbean.ModelMBeanOperationInfo;
  import org.apache.log4j.Logger;
  
  public class ModelMBeanInfoBuilder implements IModelMBeanInfoBuilder
  {
      public static final String REVISION = "$Revision: 1.1 $";
  
      public static final String JAVAX_MODELBEAN_INFO = "javax.management.modelmbean.ModelMBeanInfo";
      public static final String DESCRIPTION = "description";
  
      public static final String MODEL_MBEAN_ATTRIBUTE_INFO = "ModelMBeanAttributeInfo";
      public static final String MODEL_MBEAN_OPERATION_INFO = "ModelMBeanOperationInfo";
      public static final String MODEL_MBEAN_CONSTRUCTOR_INFO = "ModelMBeanConstructorInfo";
      public static final String MODEL_MBEAN_NOTIFICATION_INFO = "ModelMBeanNotificationInfo";
  
      public ModelMBeanInfoBuilder()
      {
      }
      
      /**
       * This method adds a method model to the model mbean
       * This method require a descriptor to be built using the
       * IModelMBeanDescriptorBuilder, @see IModelMBeanDescriptorBuilder
       * 
       * @param name the name of the method
       * @param paramTypes the parameters types of the 
       * @param paramNames the parameter names
       * @param paramDescs the paramtere descriptions
       * @param description description of the method
       * @param rtype the type of the return
       * @param type @see MBeanOperationInfo.INFO
       * @param desc the manually buildt descriptor using
       * ModelMBeanDescriptorBuilder @see ModelMBeanDescriptorBuilder
       * 
       */
  
      public void addModelMBeanMethod(
          String name, 
          String[] paramTypes, 
          String[] paramNames, 
          String[] paramDescs, 
          String description, 
          String rtype, 
          int type, 
          Descriptor desc
      )
      {
          MBeanParameterInfo[] params = null;
  
          if( paramTypes != null )
          {
              params = new MBeanParameterInfo[ paramTypes.length ];
              for( int i = 0; i < paramTypes.length; i++ )
              {
                  params[i] = new MBeanParameterInfo(paramNames[i], paramTypes[i], paramDescs[i]);
              }
          }
  
          _operations.put(name, new ModelMBeanOperationInfo(name, description, params, rtype, type, desc));
      }
  
      /**
       * This method adds a mbean model to the model builder
       * this method assumes a default descripotor for the 
       * method.
       * 
       * @param name
       * @param description
       * @param method
       */
  
      public void addModelMBeanMethod(String name, String description, Method method)
      {
          ModelMBeanOperationInfo mBeanOperationInfo = new ModelMBeanOperationInfo(description,method);
          _operations.put(name,mBeanOperationInfo);
      }
  
      /**
       * This is method allows the addition of a Notificaiton model to the Builder
       * 
       * @param type
       * @param className
       * @param description
       * @param desc
       */    
  
      public void addModelMBeanNotification(String[] type, String className, String description, Descriptor desc)
      {
          ModelMBeanNotificationInfo modelMBenaNotificationInfo = new ModelMBeanNotificationInfo(
              type, className, description, desc
          );
   
          _notifications.put( className,  modelMBenaNotificationInfo );
      }
      
      /**
       * This is method allows the addition of a Notificaiton model to the Builder
       * It assumes a default descriptor.
       * 
       * @param types
       * @param name
       * @param description
       */
  
      public void addModelMBeanNotification(String[] types, String name, String description)
      {
          ModelMBeanNotificationInfo modelMBeanNotificationInfo = new    ModelMBeanNotificationInfo(
              types, name, description
          );
          _notifications.put(name, modelMBeanNotificationInfo);
      }
  
      /**
       * Adds an attribute Model to the Model Builder witha  manually created
       * Attribute Descriptor Object.  @see ModelMBeanDescriptorBuilder for building
       * Descriptors.
       * 
       * @param fname
       * @param ftype
       * @param read
       * @param write
       * @param is
       * @param description
       * @param desc
       */    
  
      public void addModelMBeanAttribute(
          String fname,
          String ftype, 
          boolean read, 
          boolean write, 
          boolean is, 
          String description, 
          Descriptor desc
      )
      {
          ModelMBeanAttributeInfo modelMBeanAttributeInfo = new ModelMBeanAttributeInfo(
              fname, ftype, description, read, write, is,    desc
          );  
                                      
          _attributes.put( fname, modelMBeanAttributeInfo);
      }
  
      /**
       * This adds a constructor model to the Model Builder.
       * @see the ModelMBeanDescriptorBuilder for information on how
       * to build a descriptor that needs to be passed into this method.
       * 
       * @param c
       * @param description
       * @param desc
       */    
  
      public void addModelMBeanConstructor(Constructor c, String description, Descriptor desc)
      {
          ModelMBeanConstructorInfo modelMBeanConstructorInfo = new ModelMBeanConstructorInfo(description, c, desc);  
          _constructors.put(c, modelMBeanConstructorInfo);
      }
  
      /**
       * This adds a constructor model to the Model Builder.
       * This method assumes a default Descripor for the constructor.
       *  
       * @param description
       * @param constructorMethod
       * 
       */
  
      public void addModelMBeanConstructor(String description, Constructor constructorMethod)
      {
          ModelMBeanConstructorInfo modelMBeanConstructorInfo = new ModelMBeanConstructorInfo(description, constructorMethod);
          _constructors.put(constructorMethod,modelMBeanConstructorInfo);    
      }
  
      /**
       * This builds the main model for the model mbean.
       * @see ModelMBeanDescriptorBuilder on how to build a
       * descriptor for the MBean.
       * 
       * @param desc
       * @param className
       * @param description
       * @return
       * @throws Exception
       */    
  
      public ModelMBeanInfo buildModelMBeanInfo(Descriptor desc, String className, String description) throws Exception
      {
          ModelMBeanOperationInfo[] ops = new ModelMBeanOperationInfo[_operations.size()];
          ops = convertMapToModelMBeanOperationInfoArray(_operations);
  
          ModelMBeanAttributeInfo[] atts = new ModelMBeanAttributeInfo[_attributes.size()];
          atts = convertMapToModelMBeanAttributeInfoArray(_attributes);
  
          ModelMBeanConstructorInfo[] cons = new ModelMBeanConstructorInfo[_constructors.size()];
          cons = convertMapToModelMBeanConstructorInfoArray(_constructors);
  
          ModelMBeanNotificationInfo[] notifs = new ModelMBeanNotificationInfo[_notifications.size()];
          notifs = convertMapToModelMBeanNotificationInfoArray(_notifications);
  
          return new ModelMBeanInfoSupport(
              JAVAX_MODELBEAN_INFO, //className, 
              description, 
              atts,
              cons, 
              ops, 
              notifs, 
              desc
          );
      }
  
      protected MBeanFeatureInfo[] convertMapToMBeanFeatureInfoArray(Map table , String castType)
      {
          MBeanFeatureInfo[] mBeanFeatureInfoArray = null;
          ModelMBeanAttributeInfo[] modelMBeanAttributeInfoArray = null;
          Collection collection = table.values();
          Iterator iterator = collection.iterator();
  
          int currentArrayIndex = 0;
      
          while( iterator.hasNext())
          {
              if (castType.equals(MODEL_MBEAN_ATTRIBUTE_INFO))
              {
                  modelMBeanAttributeInfoArray[currentArrayIndex] = (ModelMBeanAttributeInfo) iterator.next();
              }
              else if (castType.equals(MODEL_MBEAN_OPERATION_INFO))
              {
                  mBeanFeatureInfoArray[currentArrayIndex] = (ModelMBeanOperationInfo) iterator.next();
              }
              else if (castType.equals(MODEL_MBEAN_NOTIFICATION_INFO))
              {
                  mBeanFeatureInfoArray[currentArrayIndex] = (ModelMBeanOperationInfo) iterator.next();
              }
              else if (castType.equals(MODEL_MBEAN_CONSTRUCTOR_INFO))
              {
                  mBeanFeatureInfoArray[currentArrayIndex] = (ModelMBeanConstructorInfo) iterator.next();
              }
  
              currentArrayIndex++;
          }
  
          return mBeanFeatureInfoArray;
      }
  
      protected ModelMBeanAttributeInfo[] convertMapToModelMBeanAttributeInfoArray(Map table)
      {
          ModelMBeanAttributeInfo[] modelMBeanAttributeInfoArray = new ModelMBeanAttributeInfo[table.size()];
          Collection collection = table.values();
          Iterator iterator = collection.iterator();
          
          int currentArrayIndex = 0;
          
          while( iterator.hasNext())
          {
              modelMBeanAttributeInfoArray[currentArrayIndex] = (ModelMBeanAttributeInfo) iterator.next();
              currentArrayIndex++;
          }
  
          return modelMBeanAttributeInfoArray;
      }
  
      protected ModelMBeanOperationInfo[] convertMapToModelMBeanOperationInfoArray(Map table)
      {
          ModelMBeanOperationInfo[] modelMBeanOperationInfoArray = new ModelMBeanOperationInfo[table.size()];
          Collection collection = table.values();
          Iterator iterator = collection.iterator();
  
          int currentArrayIndex = 0;
  
          while(iterator.hasNext())
          {
              modelMBeanOperationInfoArray[currentArrayIndex] = (ModelMBeanOperationInfo) iterator.next();
              currentArrayIndex++;
          }
  
          return modelMBeanOperationInfoArray;
      }
  
      protected ModelMBeanConstructorInfo[] convertMapToModelMBeanConstructorInfoArray(Map table)
      {
          ModelMBeanConstructorInfo[] modelMBeanConstructorInfoArray = new ModelMBeanConstructorInfo[table.size()];
          Collection collection = table.values();
          Iterator iterator = collection.iterator();
  
          int currentArrayIndex = 0;
  
          while( iterator.hasNext())
          {
              modelMBeanConstructorInfoArray[currentArrayIndex] = (ModelMBeanConstructorInfo) iterator.next();
              currentArrayIndex++;
          }
  
          return modelMBeanConstructorInfoArray;
      }
  
      protected ModelMBeanNotificationInfo[] convertMapToModelMBeanNotificationInfoArray(Map table)
      {
          ModelMBeanNotificationInfo[] modelMBeanNotificationInfoArray = new ModelMBeanNotificationInfo[table.size()];
          Collection collection = table.values();
          Iterator iterator = collection.iterator();
  
          int currentArrayIndex = 0;
  
          while( iterator.hasNext())
          {
              modelMBeanNotificationInfoArray[currentArrayIndex] = (ModelMBeanNotificationInfo)iterator.next();
              currentArrayIndex++;
          }
  
          return modelMBeanNotificationInfoArray;
      }
  
      private static Logger _Logger = Logger.getLogger(ModelMBeanInfoBuilder.class);    
      protected Map _attributes = new HashMap();
      protected Map _notifications = new HashMap();
      protected Map _constructors = new HashMap();
      protected Map _operations = new HashMap();
  }
  
  
  1.1                  jakarta-jetspeed-2/cornerstone/src/java/org/apache/cornerstone/framework/jmx/MBeanManager.java
  
  Index: MBeanManager.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Jetspeed" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Jetspeed", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.cornerstone.framework.jmx;
  
  /**
   * This is the Main class in the framework's implemntation of JMX.
   * This class is called by the framework at initialisation time.
   * @see the com.cisco.salesit.framework.portal.controller.EsalesPortalInitServlet
   * This MbeanManager is responsible for starting up the JMX server.
   * This MBeanManager is responsible for Starting the HttpAdaptor, that
   * is used to view the monitored Modelled MBean objects.
   * Also facilitates the receiption of the all objects published for monitoring
   * via the pubsub mechanism.  Once an object is recived automatic
   * registration of the received objects is coplaced with the main JMX server.
   * 
   */
  
  import java.lang.reflect.Method;
  import javax.management.MBeanServer;
  import javax.management.MBeanServerFactory;
  import javax.management.ObjectName;
  import org.apache.cornerstone.framework.api.pubsub.ISubscriber;
  import org.apache.cornerstone.framework.constant.Constant;
  import org.apache.cornerstone.framework.core.BaseObject;
  import org.apache.cornerstone.framework.pubsub.BasePubSubManager;
  import org.apache.log4j.Logger;
  import com.sun.jdmk.comm.HtmlAdaptorServer;
  
  public class MBeanManager extends BaseObject implements ISubscriber
  {
      public static final String MBEAN_MGR_NAME = "MBeanManager";
      
      public static final String HTML_ADAPTOR_PORT = "jmx.httpAdapter.port";
      public static String HTML_ADAPTOR_OBJECT_NAME = MBEAN_MGR_NAME + ":name=htmladaptor";
      public static String JMX_HTTP_ADAPTER_ENABLED = "jmx.httpAdapter.enabled";
   
      public static MBeanManager getSingleton()
      {
          return _Singleton;    
      }
      
      /**
       * Constrcutor.
       * Starts-up an JMX Server
       * Starts-up a HttpAdaptor server.
       *
       */                                    
          
      public MBeanManager()
      {
          super();
          _mbeanServer = MBeanServerFactory.createMBeanServer(MBEAN_MGR_NAME);
  
          String jmxHttpAdapterEnabledString = "true";    // TODO
          if (jmxHttpAdapterEnabledString != null && jmxHttpAdapterEnabledString.trim().equalsIgnoreCase("true"))
          {
              HtmlAdaptorServer htmlAdaptorServer = new HtmlAdaptorServer();
              try
              {
                  ObjectName adapterName = new ObjectName(HTML_ADAPTOR_OBJECT_NAME);
  
                  String httpAdaptorPortStr = getConfigProperty(HTML_ADAPTOR_PORT);
                  Integer httpAdaptorPortInteger = new Integer(httpAdaptorPortStr);
                  htmlAdaptorServer.setPort(httpAdaptorPortInteger.intValue());
                  _mbeanServer.registerMBean(htmlAdaptorServer, adapterName);
                    
                  htmlAdaptorServer.start();
                  
                  BasePubSubManager.getSingleton().subscribe(Constant.JMX_MANAGED, this);
               }
               catch(Exception e)
               {
                   _Logger.error("failed to initialize MBeanManager", e);
               }
          }
      }
      
      /**
       * Receives the monitored object and registeres it with the
       * JMX Server.
       * @param monitorObj the object to be monitred as an mbean.
       * 
       */
  
      public void receive(Object monitoredObject)
      {
          BaseModelMBean baseModelMBean = new BaseModelMBean(monitoredObject);
          String modelMBeanName = MBeanManager.MBEAN_MGR_NAME + ":" + "name=" + callGetName(monitoredObject);
          ObjectName monitoredObjectName = null;
          try
          {
              monitoredObjectName = new ObjectName(modelMBeanName);
          }
          catch (Exception e)
          {
              _Logger.error("failed to create object name '" + modelMBeanName + "'", e);
          }
          
          try
          {
              _mbeanServer.registerMBean(    baseModelMBean.getRequiredModelMBean(),    monitoredObjectName);
          }
          catch(Exception e)
          {
              _Logger.error("failed to register MBean '" + modelMBeanName + "'", e);
          }
      }
  
      protected String callGetName(Object monitoredObject)
      {
          try
          {
              Method getNameMethod = monitoredObject.getClass().getMethod("getName", null);
              return (String) getNameMethod.invoke(monitoredObject, null);
          }
          catch (Exception e)
          {
              _Logger.info("failed to call getName()", e);
              return null;
          }
      }
  
      private static Logger _Logger = Logger.getLogger(MBeanManager.class);
      private static MBeanManager _Singleton = new MBeanManager();                                                                    
      protected MBeanServer _mbeanServer = null;
  }
  
  
  1.1                  jakarta-jetspeed-2/cornerstone/src/java/org/apache/cornerstone/framework/jmx/BaseModelMBean.java
  
  Index: BaseModelMBean.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Jetspeed" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Jetspeed", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.cornerstone.framework.jmx;
  
  import java.beans.PropertyDescriptor;
  import java.lang.reflect.Constructor;
  import java.lang.reflect.Method;
  import javax.management.Descriptor;
  import javax.management.modelmbean.ModelMBeanInfo;
  import javax.management.modelmbean.RequiredModelMBean;
  import org.apache.commons.beanutils.PropertyUtils;
  import org.apache.cornerstone.framework.core.BaseObject;
  import org.apache.log4j.Logger;
  
  /**
   * This wrapper-object is the Main object used for converting a regular java.lang.Object
   * into JMX Model MBean object.  The user of this class passes in a java.lang.Object, and
   * then in turn this wrapper object converts it into a Model MBean.  This Model Mbean can
   * using the getRequireModelMBean method. 
   *
   */
  
  public class BaseModelMBean extends BaseObject
  {
      public static final String REVISION = "$Revision: 1.1 $";
  
      public static final String CLASS = "class";
      public static final String CONFIG_PERSIST_POLICY = "persistPolicy";
      public static final String CONFIG_PERSIST_PERIOD_IN_SECONDS = "persisPeriodInSeconds";
      public static final String CONFIG_PERSIST_LOCATION_DEFAULT_DIR ="persistLocationDefaultDir";
      public static final String CONFIG_CURRENCY_TIME_LIMIT = "currencyTimeLimit";
      public static final String CONFIG_DEFAULT_NOTIFICATION = "defaultNotification";
      public static final String NOTIFICATION_TYPE = "default";
      public static final String CONFIG_DEFAULT_NOTIFICATION_DESCRITPTION = "defaultNotificationDescription";
      public static final String GET_METHOD_PREFIX = "get";
      public static final String SET_METHOD_PREFIX = "set";
      public static final String DEFAULT_METHOD_PARAMETER_NAME = "par";
      public static final String READ_METHOD_DESCRITPION = "This is a read ";
      public static final String WRITE_METHOD_DESCRITPION = "This is a write ";
      public static final String MAIN_METHOD = "main";
      public static final String OBJECT_REFERENCE = "ObjectReference";
       
      /**
       * Constructor for converting a java.lang.Object into Required model MBean.
       * 
       * @param objToBeModelledMBean
       */
      public BaseModelMBean(Object objToBeModelledMBean)
      {
          _modelMBeanInfoBuilder = (IModelMBeanInfoBuilder) ModelMBeanInfoBuilderFactory.getSingleton().createInstance();
          _modelMBeanDescriptorBuilder = (IModelMBeanDescriptorBuilder) ModelMBeanDescriptorBuilderFactory.getSingleton().createInstance();
                  
          // obtain all the attributes on the object
          //
          //
          Class cls = objToBeModelledMBean.getClass();
          String className = cls.getName();
          
          PropertyDescriptor[] propDescriptors = PropertyUtils.getPropertyDescriptors(cls);
  
          for (int i= 0; i < propDescriptors.length; i++)
          {
              Descriptor attributeDescriptor = null;
              
              String currentProperty = propDescriptors[i].getName();
              
              boolean isReadableProperty = false; 
              boolean isWriteableProperty = false;
              
              // ignore the property if it is of type
              if ( currentProperty.equals(CLASS)) continue;
              
              String currentPropertyType = propDescriptors[i].getPropertyType().getName();
              
              Method readMethod = propDescriptors[i].getReadMethod();
              String readMethodReturnType = null;
              String readMethodName = null;
              if ( readMethod != null )
              {
                  readMethodReturnType = readMethod.getReturnType().getName();
                  readMethodName = readMethod.getName();
                  isReadableProperty =true;
              }
  
              Method writeMethod = propDescriptors[i].getWriteMethod();
              String writeMethodName = null;
              if ( writeMethod != null )
              {
                  writeMethodName = writeMethod.getName();
                  isWriteableProperty = true;
              }
  
              // TODO: remove this code
              //Class[] clsParameters = writeMethod.getParameterTypes();
              //String[] writeMethodParameters = convertClassArrayToStringArrayOfClassNames(clsParameters);            
              //String[] defaultMethodParameterNames = generateDefaultNamesForMethodParameters(clsParameters);
  
              attributeDescriptor = _modelMBeanDescriptorBuilder.buildAttributeDescriptor(     
                  currentProperty, 
                  currentProperty, 
                  getConfigProperty(CONFIG_PERSIST_POLICY), 
                  getConfigProperty(CONFIG_PERSIST_PERIOD_IN_SECONDS), 
                  null, 
                  readMethodName, 
                  writeMethodName, 
                  getConfigProperty(CONFIG_CURRENCY_TIME_LIMIT)
              );
  
              // add the descriptor of the attribute to the model of the MBean
              _modelMBeanInfoBuilder.addModelMBeanAttribute(
                  currentProperty,
                  currentPropertyType,
                  isReadableProperty,
                  isWriteableProperty,
                  false,
                  currentProperty,
                  attributeDescriptor
              );
          }
  
          // Determine the operations that exist on the objToBeModelledMBean
          Method[] methods = cls.getDeclaredMethods();
          
          // build operations attributes
          for (int i= 0; i < methods.length; i++)
          {
              String currentMethodName = methods[i].getName();
              
              // ignore main method
              if ( currentMethodName.equals(MAIN_METHOD)) continue;
              
              _modelMBeanInfoBuilder.addModelMBeanMethod(
                  currentMethodName,
                  currentMethodName,
                  methods[i]
              );
          }
  
          // build ctor attributes
          Constructor[] constructors = cls.getDeclaredConstructors();
          
          for ( int i = 0; i < constructors.length; i++ )
          {
              String constructorName = constructors[i].getName();
              _modelMBeanInfoBuilder.addModelMBeanConstructor(constructorName,constructors[i]);
          }
  
          String[] notificationTypes = {NOTIFICATION_TYPE};
          _modelMBeanInfoBuilder.addModelMBeanNotification(
              notificationTypes,
              getConfigProperty(CONFIG_DEFAULT_NOTIFICATION),
              getConfigProperty(CONFIG_DEFAULT_NOTIFICATION_DESCRITPTION)                        
          );
  
          // build the mbean
          Descriptor mbeanDescriptor = null;
  
          mbeanDescriptor = _modelMBeanDescriptorBuilder.buildMBeanDescriptor(
              className,
              className,
              getConfigProperty(CONFIG_PERSIST_POLICY),
              getConfigProperty(CONFIG_PERSIST_PERIOD_IN_SECONDS),
              getConfigProperty(CONFIG_PERSIST_LOCATION_DEFAULT_DIR),
              className,
              null,
              null
          );
  
          ModelMBeanInfo modelMBeanInfo = null;
          try
          {
              modelMBeanInfo = _modelMBeanInfoBuilder.buildModelMBeanInfo(
                  mbeanDescriptor, 
                  className, 
                  className
              );
                                              
              _requiredModelMBean = new RequiredModelMBean();        
              _requiredModelMBean.setManagedResource(objToBeModelledMBean,OBJECT_REFERENCE);
              _requiredModelMBean.setModelMBeanInfo(modelMBeanInfo);
          }
          catch(Exception e)
          {
              _Logger.error("An error occured in ModeMBean Constuction", e);
          }
      }
  
      /**
       * This method returns the Model MBean as required by the JMX "On the Fly"
       * specification.
       * 
       * @return
       */
  
      public RequiredModelMBean getRequiredModelMBean()
      {
          return _requiredModelMBean;
      }
      
      /**
       * Sets the RequiredModelMbean
       * 
       * @param requiredModelMBean
       */
  
      public void setRequiredModelMBean(RequiredModelMBean requiredModelMBean)
      {
          _requiredModelMBean = requiredModelMBean;
      }
  
      protected String[] convertClassArrayToStringArrayOfClassNames(Class[] clsArray)
      {
          String[] strArrayOfClassNames = new String[clsArray.length];
          for ( int i = 0; i < clsArray.length; i++ )
          {
              strArrayOfClassNames[i] = clsArray[i].getName();            
          }
          return     strArrayOfClassNames;
      }
  
      protected String[] generateDefaultNamesForMethodParameters(Class[] clsArray)
      {
          String[] strArrayOfDefaultparameterNames = new String[clsArray.length];
          for ( int i = 0; i < clsArray.length; i++ )
          {
              strArrayOfDefaultparameterNames[i] = DEFAULT_METHOD_PARAMETER_NAME + i;            
          }
          return     strArrayOfDefaultparameterNames;
      }
  
      protected String buildMethodNameWithPrefix(String fieldName,String prefix)
      {
          String absoluteMethodName = "";
          
          String firstCharOfField = fieldName.substring(0,1);
          String restOfFieldName = fieldName.substring(1,fieldName.length());
          absoluteMethodName = prefix + firstCharOfField.toUpperCase() + restOfFieldName;    
          return absoluteMethodName;        
      }
  
      private static Logger _Logger = Logger.getLogger(BaseModelMBean.class);
      protected IModelMBeanInfoBuilder _modelMBeanInfoBuilder = null;
      protected IModelMBeanDescriptorBuilder _modelMBeanDescriptorBuilder = null;
      protected RequiredModelMBean _requiredModelMBean = null;    
  }
  
  
  1.1                  jakarta-jetspeed-2/cornerstone/src/java/org/apache/cornerstone/framework/jmx/JMXManager.java
  
  Index: JMXManager.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Jetspeed" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Jetspeed", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.cornerstone.framework.jmx;
  
  import org.apache.cornerstone.framework.api.jmx.IJMXManager;
  
  public class JMXManager implements IJMXManager
  {
  	public static final String REVISION = "$Revision: 1.1 $";
  
  	public void manage(Object managedObject)
  	{
  		MBeanManager.getSingleton().receive(managedObject);
  	}
  }
  
  
  1.1                  jakarta-jetspeed-2/cornerstone/src/java/org/apache/cornerstone/framework/jmx/ModelMBeanDescriptorBuilderFactory.java
  
  Index: ModelMBeanDescriptorBuilderFactory.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Jetspeed" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Jetspeed", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.cornerstone.framework.jmx;
  
  import org.apache.cornerstone.framework.factory.BaseFactory;
  import org.apache.cornerstone.framework.init.Cornerstone;
  import org.apache.log4j.Logger;
  
  /**
   * Factory for creating the ModelMBeanDescriptorBuilder
   *
   */
  
  public class ModelMBeanDescriptorBuilderFactory extends BaseFactory
  {
      public static final String REVISION = "$Revision: 1.1 $";
  
      /**
      * Returns a singleton instance of ModelMBeanInfoBuilderFactory
      * @return ModelMBeanInfoBuilderFactory singleton
      */
      public static ModelMBeanDescriptorBuilderFactory getSingleton()
      {
          return _singleton;
      }
      
      /**
      * Creates an instance of the ModelMBeanInfoBuilder
      * @return ModelMBeanInfoBuilder Singleton instance
      */
      public Object createInstance()
      {
          ModelMBeanDescriptorBuilder modelMBeanDescriptorBuilder = (ModelMBeanDescriptorBuilder) Cornerstone.getSingletonManager().getSingleton("com.cisco.salesit.framework.sysmgmt.ModelMBeanDescriptorBuilder");
  
          if ( modelMBeanDescriptorBuilder != null )
          {
              _Logger.info("created modelMBeanDescriptorBuilder");
          }
          else
          {
              _Logger.error("couldn't create modelMBeanDescriptorBuilder");
          }
          
          return (IModelMBeanDescriptorBuilder)modelMBeanDescriptorBuilder;
      }
  
      private static Logger _Logger = Logger.getLogger(ModelMBeanDescriptorBuilderFactory.class);
      private static ModelMBeanDescriptorBuilderFactory _singleton = new ModelMBeanDescriptorBuilderFactory();
  }
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-dev-help@jakarta.apache.org