You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by co...@apache.org on 2006/06/20 23:31:44 UTC

svn commit: r415811 [1/2] - in /tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/modeler: ./ modules/

Author: costin
Date: Tue Jun 20 14:31:42 2006
New Revision: 415811

URL: http://svn.apache.org/viewvc?rev=415811&view=rev
Log:
Update the modeler with the sandbox version, using dynamic mbeans instead of model mbeans.


Removed:
    tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/modeler/BaseNotification.java
    tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/modeler/FieldInfo.java
    tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/modeler/JndiJmx.java
    tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/modeler/modules/MbeansDescriptorsDynamicMBeanSource.java
Modified:
    tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/modeler/AttributeInfo.java
    tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/modeler/BaseModelMBean.java
    tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/modeler/ConstructorInfo.java
    tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/modeler/FeatureInfo.java
    tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/modeler/ManagedBean.java
    tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/modeler/NotificationInfo.java
    tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/modeler/OperationInfo.java
    tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/modeler/ParameterInfo.java
    tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/modeler/Registry.java
    tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/modeler/modules/MbeansDescriptorsDOMSource.java
    tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/modeler/modules/MbeansDescriptorsDigesterSource.java
    tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/modeler/modules/MbeansDescriptorsIntrospectionSource.java

Modified: tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/modeler/AttributeInfo.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/modeler/AttributeInfo.java?rev=415811&r1=415810&r2=415811&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/modeler/AttributeInfo.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/modeler/AttributeInfo.java Tue Jun 20 14:31:42 2006
@@ -19,10 +19,8 @@
 
 
 import java.io.Serializable;
-import java.lang.reflect.Method;
 
-import javax.management.Descriptor;
-import javax.management.modelmbean.ModelMBeanAttributeInfo;
+import javax.management.MBeanAttributeInfo;
 
 
 /**
@@ -30,58 +28,22 @@
  * descriptor.</p>
  *
  * @author Craig R. McClanahan
- * @version $Revision: 155428 $ $Date: 2005-02-26 14:12:25 +0100 (sam., 26 févr. 2005) $
  */
-
 public class AttributeInfo extends FeatureInfo implements Serializable {
     static final long serialVersionUID = -2511626862303972143L;
 
     // ----------------------------------------------------- Instance Variables
-
-
-    /**
-     * The <code>ModelMBeanAttributeInfo</code> object that corresponds
-     * to this <code>AttributeInfo</code> instance.
-     */
-    protected transient ModelMBeanAttributeInfo info = null;
     protected String displayName = null;
+
+    // Information about the method to use
     protected String getMethod = null;
     protected String setMethod = null;
-
-    protected transient Method getMethodObj = null;
-    protected transient Method setMethodObj = null;
-
     protected boolean readable = true;
     protected boolean writeable = true;
-
     protected boolean is = false;
-    protected String type = null;
-
-    protected String persist;
-    protected String defaultStringValue;
+    
     // ------------------------------------------------------------- Properties
 
-
-    /**
-     * Override the <code>description</code> property setter.
-     *
-     * @param description The new description
-     */
-    public void setDescription(String description) {
-        super.setDescription(description);
-        this.info = null;
-    }
-
-    /**
-     * Override the <code>name</code> property setter.
-     *
-     * @param name The new name
-     */
-    public void setName(String name) {
-        super.setName(name);
-        this.info = null;
-    }
-
     /**
      * The display name of this attribute.
      */
@@ -97,28 +59,13 @@
      * The name of the property getter method, if non-standard.
      */
     public String getGetMethod() {
+        if(getMethod == null) 
+            getMethod = getMethodName(getName(), true, isIs());
         return (this.getMethod);
     }
 
     public void setGetMethod(String getMethod) {
         this.getMethod = getMethod;
-        this.info = null;
-    }
-
-    public Method getGetMethodObj() {
-        return getMethodObj;
-    }
-
-    public void setGetMethodObj(Method getMethodObj) {
-        this.getMethodObj = getMethodObj;
-    }
-
-    public Method getSetMethodObj() {
-        return setMethodObj;
-    }
-
-    public void setSetMethodObj(Method setMethodObj) {
-        this.setMethodObj = setMethodObj;
     }
 
     /**
@@ -130,7 +77,6 @@
 
     public void setIs(boolean is) {
         this.is = is;
-        this.info = null;
     }
 
 
@@ -143,7 +89,6 @@
 
     public void setReadable(boolean readable) {
         this.readable = readable;
-        this.info = null;
     }
 
 
@@ -151,28 +96,15 @@
      * The name of the property setter method, if non-standard.
      */
     public String getSetMethod() {
+        if( setMethod == null )
+            setMethod = getMethodName(getName(), false, false);
         return (this.setMethod);
     }
 
     public void setSetMethod(String setMethod) {
         this.setMethod = setMethod;
-        this.info = null;
-    }
-
-
-    /**
-     * The fully qualified Java class name of this attribute.
-     */
-    public String getType() {
-        return (this.type);
-    }
-
-    public void setType(String type) {
-        this.type = type;
-        this.info = null;
     }
 
-
     /**
      * Is this attribute writeable by management applications?
      */
@@ -182,35 +114,8 @@
 
     public void setWriteable(boolean writeable) {
         this.writeable = writeable;
-        this.info = null;
-    }
-
-    /** Persistence policy.
-     * All persistent attributes should have this attribute set.
-     * Valid values:
-     *   ???
-     */
-    public String getPersist() {
-        return persist;
-    }
-
-    public void setPersist(String persist) {
-        this.persist = persist;
-    }
-
-    /** Default value. If set, it can provide info to the user and
-     * it can be used by persistence mechanism to generate a more compact
-     * representation ( a value may not be saved if it's default )
-     */
-    public String getDefault() {
-        return defaultStringValue;
-    }
-
-    public void setDefault(String defaultStringValue) {
-        this.defaultStringValue = defaultStringValue;
     }
 
-
     // --------------------------------------------------------- Public Methods
 
 
@@ -218,73 +123,14 @@
      * Create and return a <code>ModelMBeanAttributeInfo</code> object that
      * corresponds to the attribute described by this instance.
      */
-    public ModelMBeanAttributeInfo createAttributeInfo() {
+    MBeanAttributeInfo createAttributeInfo() {
         // Return our cached information (if any)
-        if (info != null)
-            return (info);
-        if((getMethodObj != null) || (setMethodObj != null) ) {
-            try {
-                info=new ModelMBeanAttributeInfo(getName(), getDescription(),
-                                        getMethodObj,  setMethodObj);
-                return info;
-            } catch( Exception ex) {
-                ex.printStackTrace();
-            }
-        }
-
-        // Create and return a new information object
-        info = new ModelMBeanAttributeInfo
-            (getName(), getType(), getDescription(),
-             isReadable(), isWriteable(), false);
-        Descriptor descriptor = info.getDescriptor();
-        if (getDisplayName() != null)
-            descriptor.setField("displayName", getDisplayName());
-        if (isReadable()) {
-            if (getGetMethod() != null)
-                descriptor.setField("getMethod", getGetMethod());
-            else
-                descriptor.setField("getMethod",
-                                    getMethodName(getName(), true, isIs()));
-        }
-        if (isWriteable()) {
-            if (getSetMethod() != null)
-                descriptor.setField("setMethod", getSetMethod());
-            else
-                descriptor.setField("setMethod",
-                                    getMethodName(getName(), false, false));
+        if (info == null) {
+            info = new MBeanAttributeInfo(getName(), getType(), getDescription(),
+                            isReadable(), isWriteable(), false);
         }
-        addFields(descriptor);
-        info.setDescriptor(descriptor);
-        return (info);
-
+        return (MBeanAttributeInfo)info;
     }
-
-
-    /**
-     * Return a string representation of this attribute descriptor.
-     */
-    public String toString() {
-
-        StringBuffer sb = new StringBuffer("AttributeInfo[");
-        sb.append("name=");
-        sb.append(name);
-        sb.append(", description=");
-        sb.append(description);
-        if (!readable) {
-            sb.append(", readable=");
-            sb.append(readable);
-        }
-        sb.append(", type=");
-        sb.append(type);
-        if (!writeable) {
-            sb.append(", writeable=");
-            sb.append(writeable);
-        }
-        sb.append("]");
-        return (sb.toString());
-
-    }
-
 
     // -------------------------------------------------------- Private Methods
 

Modified: tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/modeler/BaseModelMBean.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/modeler/BaseModelMBean.java?rev=415811&r1=415810&r2=415811&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/modeler/BaseModelMBean.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/modeler/BaseModelMBean.java Tue Jun 20 14:31:42 2006
@@ -20,15 +20,12 @@
 
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
-import java.util.HashMap;
-import java.util.Hashtable;
 import java.util.Iterator;
 
 import javax.management.Attribute;
 import javax.management.AttributeChangeNotification;
 import javax.management.AttributeList;
 import javax.management.AttributeNotFoundException;
-import javax.management.Descriptor;
 import javax.management.DynamicMBean;
 import javax.management.InstanceNotFoundException;
 import javax.management.InvalidAttributeValueException;
@@ -45,30 +42,40 @@
 import javax.management.ReflectionException;
 import javax.management.RuntimeErrorException;
 import javax.management.RuntimeOperationsException;
-import javax.management.ServiceNotFoundException;
-import javax.management.modelmbean.DescriptorSupport;
 import javax.management.modelmbean.InvalidTargetObjectTypeException;
-import javax.management.modelmbean.ModelMBean;
-import javax.management.modelmbean.ModelMBeanAttributeInfo;
-import javax.management.modelmbean.ModelMBeanInfo;
-import javax.management.modelmbean.ModelMBeanInfoSupport;
-import javax.management.modelmbean.ModelMBeanNotificationInfo;
-import javax.management.modelmbean.ModelMBeanOperationInfo;
+import javax.management.modelmbean.ModelMBeanNotificationBroadcaster;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.tomcat.util.modeler.modules.ModelerSource;
 
-// TODO: enable ant-like substitutions ? ( or at least discuss it )
+/*
+ * Changes from commons.modeler:
+ * 
+ *  - use DynamicMBean
+ *  - remove methods not used in tomcat and redundant/not very generic
+ *  - must be created from the ManagedBean - I don't think there were any direct
+ *    uses, but now it is required.
+ *  - some of the gratuituous flexibility removed - instead this is more predictive and
+ *    strict with the use cases.
+ *  - all Method and metadata is stored in ManagedBean. BaseModelBMean and ManagedBean act
+ *    like Object and Class. 
+ *  - setModelMBean is no longer called on resources ( not used in tomcat )
+ *  - no caching of Methods for now - operations and setters are not called repeatedly in most 
+ *  management use cases. Getters should't be called very frequently either - and even if they
+ *  are, the overhead of getting the method should be small compared with other JMX costs ( RMI, etc ).
+ *  We can add getter cache if needed.
+ *  - removed unused constructor, fields
+ *  
+ *  TODO:
+ *   - clean up catalina.mbeans, stop using weird inheritance
+ */
 
 /**
- * <p>Basic implementation of the <code>ModelMBean</code> interface, which
+ * <p>Basic implementation of the <code>DynamicMBean</code> interface, which
  * supports the minimal requirements of the interface contract.</p>
  *
  * <p>This can be used directly to wrap an existing java bean, or inside
- * an mlet or anywhere an MBean would be used. The String parameter
- * passed to the constructor will be used to construct an instance of the
- * real object that we wrap.
+ * an mlet or anywhere an MBean would be used. 
  *
  * Limitations:
  * <ul>
@@ -76,7 +83,6 @@
  *     supportd.</li>
  * <li>Caching of attribute values and operation results is not supported.
  *     All calls to <code>invoke()</code> are immediately executed.</li>
- * <li>Logging (under control of descriptors) is not supported.</li>
  * <li>Persistence of MBean attributes and operations is not supported.</li>
  * <li>All classes referenced as attribute types, operation parameters, or
  *     operation return values must be one of the following:
@@ -92,10 +98,8 @@
  *
  * @author Craig R. McClanahan
  * @author Costin Manolache
- * @version $Revision: 383269 $ $Date: 2006-03-05 03:22:41 +0100 (dim., 05 mars 2006) $
  */
-
-public class BaseModelMBean implements ModelMBean, MBeanRegistration {
+public class BaseModelMBean implements DynamicMBean, MBeanRegistration, ModelMBeanNotificationBroadcaster {
     private static Log log = LogFactory.getLog(BaseModelMBean.class);
 
     // ----------------------------------------------------------- Constructors
@@ -109,119 +113,42 @@
      * @exception RuntimeOperationsException if an IllegalArgumentException
      *  occurs
      */
-    public BaseModelMBean() throws MBeanException, RuntimeOperationsException {
-
-        super();
-        if( log.isDebugEnabled()) log.debug("default constructor");
-        setModelMBeanInfo(createDefaultModelMBeanInfo());
-    }
-
-
-    /**
-     * Construct a <code>ModelMBean</code> associated with the specified
-     * <code>ModelMBeanInfo</code> information.
-     *
-     * @param info ModelMBeanInfo for this MBean
-     *
-     * @exception MBeanException if the initializer of an object
-     *  throws an exception
-     * @exception RuntimeOperationsException if an IllegalArgumentException
-     *  occurs
-     */
-    public BaseModelMBean(ModelMBeanInfo info)
-        throws MBeanException, RuntimeOperationsException {
-        // XXX should be deprecated - just call setInfo
+    protected BaseModelMBean() throws MBeanException, RuntimeOperationsException {
         super();
-        setModelMBeanInfo(info);
-        if( log.isDebugEnabled()) log.debug("ModelMBeanInfo constructor");
-    }
-
-    /** Construct a ModelMBean of a specified type.
-     *  The type can be a class name or the key used in one of the descriptors.
-     *
-     * If no descriptor is available, we'll first try to locate one in
-     * the same package with the class, then use introspection.
-     *
-     * The mbean resource will be created.
-     *
-     * @param type Class name or the type key used in the descriptor.
-     * @throws MBeanException
-     * @throws RuntimeOperationsException
-     */
-    public BaseModelMBean( String type )
-        throws MBeanException, RuntimeOperationsException
-    {
-        try {
-            // This constructor is used from <mlet>, it should create
-            // the resource
-            setModeledType(type);
-        } catch( Throwable ex ) {
-            log.error( "Error creating mbean ", ex);
-        }
-    }
-
-    public BaseModelMBean( String type, ModelerSource source )
-        throws MBeanException, RuntimeOperationsException
-    {
-        try {
-            setModeledType(type);
-        } catch( Throwable ex ) {
-            log.error( "Error creating mbean ", ex);
-        }
-        this.source=source;
     }
 
     // ----------------------------------------------------- Instance Variables
 
+    protected ObjectName oname=null;
 
     /**
      * Notification broadcaster for attribute changes.
      */
     protected BaseNotificationBroadcaster attributeBroadcaster = null;
 
-    /** Registry we are associated with
-     */
-    protected Registry registry=null;
-
     /**
      * Notification broadcaster for general notifications.
      */
     protected BaseNotificationBroadcaster generalBroadcaster = null;
-
-    protected ObjectName oname=null;
-
-    /**
-     * The <code>ModelMBeanInfo</code> object that controls our activity.
+    
+    /** Metadata for the mbean instance.
      */
-    protected ModelMBeanInfo info = null;
-
+    protected ManagedBean managedBean = null;
 
     /**
      * The managed resource this MBean is associated with (if any).
      */
     protected Object resource = null;
-    protected String resourceType = null;
-
-    /** Source object used to read this mbean. Can be used to
-     * persist the mbean
-     */
-    protected ModelerSource source=null;
-
-    /** Attribute values. XXX That can be stored in the value Field
-     */
-    protected HashMap attributes=new HashMap();
 
     // --------------------------------------------------- DynamicMBean Methods
+    // TODO: move to ManagedBean
     static final Object[] NO_ARGS_PARAM=new Object[0];
     static final Class[] NO_ARGS_PARAM_SIG=new Class[0];
-    // key: attribute val: getter method
-    private Hashtable getAttMap=new Hashtable();
-
-    // key: attribute val: setter method
-    private Hashtable setAttMap=new Hashtable();
+    
+    protected String resourceType = null;
 
     // key: operation val: invoke method
-    private Hashtable invokeAttMap=new Hashtable();
+    //private Hashtable invokeAttMap=new Hashtable();
 
     /**
      * Obtain and return the value of a specific attribute of this MBean.
@@ -249,45 +176,7 @@
             return ((DynamicMBean)resource).getAttribute(name);
         }
         
-        // Extract the method from cache
-        Method m=(Method)getAttMap.get( name );
-
-        if( m==null ) {
-            // Look up the actual operation to be used
-            ModelMBeanAttributeInfo attrInfo = info.getAttribute(name);
-            if (attrInfo == null)
-                throw new AttributeNotFoundException(" Cannot find attribute " + name);
-            Descriptor attrDesc = attrInfo.getDescriptor();
-            if (attrDesc == null)
-                throw new AttributeNotFoundException("Cannot find attribute " + name + " descriptor");
-            String getMethod = (String) attrDesc.getFieldValue("getMethod");
-
-            if (getMethod == null)
-                throw new AttributeNotFoundException("Cannot find attribute " + name + " get method name");
-
-            Object object = null;
-            NoSuchMethodException exception = null;
-            try {
-                object = this;
-                m = object.getClass().getMethod(getMethod, NO_ARGS_PARAM_SIG);
-            } catch (NoSuchMethodException e) {
-                exception = e;;
-            }
-            if( m== null && resource != null ) {
-                try {
-                    object = resource;
-                    m = object.getClass().getMethod(getMethod, NO_ARGS_PARAM_SIG);
-                    exception=null;
-                } catch (NoSuchMethodException e) {
-                    exception = e;
-                }
-            }
-            if( exception != null )
-                throw new ReflectionException(exception,
-                                              "Cannot find getter method " + getMethod);
-            getAttMap.put( name, m );
-        }
-
+        Method m=managedBean.getGetter(name, this, resource);
         Object result = null;
         try {
             Class declaring=m.getDeclaringClass();
@@ -349,14 +238,15 @@
 
     }
 
+    public void setManagedBean(ManagedBean managedBean) {
+        this.managedBean = managedBean;
+    }
 
     /**
      * Return the <code>MBeanInfo</code> object for this MBean.
      */
     public MBeanInfo getMBeanInfo() {
-        // XXX Why do we have to clone ?
-        if( info== null ) return null;
-        return ((MBeanInfo) info.clone());
+        return managedBean.getMBeanInfo();
     }
 
 
@@ -395,59 +285,8 @@
 
         if( log.isDebugEnabled()) log.debug("Invoke " + name);
 	MethodKey mkey = new MethodKey(name, signature);
-        Method method=(Method)invokeAttMap.get(mkey);
-        if( method==null ) {
-            if (params == null)
-                params = new Object[0];
-            if (signature == null)
-                signature = new String[0];
-            if (params.length != signature.length)
-                throw new RuntimeOperationsException
-                    (new IllegalArgumentException("Inconsistent arguments and signature"),
-                     "Inconsistent arguments and signature");
-
-            // Acquire the ModelMBeanOperationInfo information for
-            // the requested operation
-            ModelMBeanOperationInfo opInfo = info.getOperation(name);
-            if (opInfo == null)
-                throw new MBeanException
-                    (new ServiceNotFoundException("Cannot find operation " + name),
-                     "Cannot find operation " + name);
-
-            // Prepare the signature required by Java reflection APIs
-            // FIXME - should we use the signature from opInfo?
-            Class types[] = new Class[signature.length];
-            for (int i = 0; i < signature.length; i++) {
-                types[i]=getAttributeClass( signature[i] );
-            }
-
-            // Locate the method to be invoked, either in this MBean itself
-            // or in the corresponding managed resource
-            // FIXME - Accessible methods in superinterfaces?
-            Object object = null;
-            Exception exception = null;
-            try {
-                object = this;
-                method = object.getClass().getMethod(name, types);
-            } catch (NoSuchMethodException e) {
-                exception = e;;
-            }
-            try {
-                if ((method == null) && (resource != null)) {
-                    object = resource;
-                    method = object.getClass().getMethod(name, types);
-                }
-            } catch (NoSuchMethodException e) {
-                exception = e;
-            }
-            if (method == null) {
-                throw new ReflectionException(exception,
-                                              "Cannot find method " + name +
-                                              " with this signature");
-            }
-            invokeAttMap.put( mkey, method );
-        }
-
+        Method method= managedBean.getInvoke(name, params, signature, this, resource);
+        
         // Invoke the selected method on the appropriate object
         Object result = null;
         try {
@@ -482,7 +321,7 @@
 
     }
 
-    private Class getAttributeClass(String signature)
+    static Class getAttributeClass(String signature)
         throws ReflectionException
     {
         if (signature.equals(Boolean.TYPE.getName()))
@@ -561,64 +400,17 @@
                 (new IllegalArgumentException("Attribute name is null"),
                  "Attribute name is null");
 
-        ModelMBeanAttributeInfo attrInfo=info.getAttribute(name);
-        if (attrInfo == null)
-            throw new AttributeNotFoundException("Cannot find attribute " + name);
-
-        Descriptor attrDesc=attrInfo.getDescriptor();
-        if (attrDesc == null)
-            throw new AttributeNotFoundException("Cannot find attribute " + name + " descriptor");
-
         Object oldValue=null;
-        if( getAttMap.get(name) != null )
-            oldValue=getAttribute( name );
-
-
-        // Extract the method from cache
-        Method m=(Method)setAttMap.get( name );
-
-        if( m==null ) {
-            // Look up the actual operation to be used
-            String setMethod = (String) attrDesc.getFieldValue("setMethod");
-            if (setMethod == null)
-                throw new AttributeNotFoundException("Cannot find attribute " + name + " set method name");
-
-            String argType=attrInfo.getType();
+        //if( getAttMap.get(name) != null )
+        //    oldValue=getAttribute( name );
 
-            Class signature[] = new Class[] { getAttributeClass( argType ) };
+        Method m=managedBean.getSetter(name,this,resource);
 
-            Object object = null;
-            NoSuchMethodException exception = null;
-            try {
-                object = this;
-                m = object.getClass().getMethod(setMethod, signature);
-            } catch (NoSuchMethodException e) {
-                exception = e;;
-            }
-            if( m== null && resource != null ) {
-                try {
-                    object = resource;
-                    m = object.getClass().getMethod(setMethod, signature);
-                    exception=null;
-                } catch (NoSuchMethodException e) {
-                    if( log.isDebugEnabled())
-                        log.debug("Method not found in resource " +resource);
-                    exception = e;
-                }
-            }
-            if( exception != null )
-                throw new ReflectionException(exception,
-                                              "Cannot find setter method " + setMethod +
-                        " " + resource);
-            setAttMap.put( name, m );
-        }
-
-        Object result = null;
         try {
             if( m.getDeclaringClass().isAssignableFrom( this.getClass()) ) {
-                result = m.invoke(this, new Object[] { value });
+                m.invoke(this, new Object[] { value });
             } else {
-                result = m.invoke(resource, new Object[] { value });
+                m.invoke(resource, new Object[] { value });
             }
         } catch (InvocationTargetException e) {
             Throwable t = e.getTargetException();
@@ -644,11 +436,11 @@
         } catch(Exception ex) {
             log.error("Error sending notification " + name, ex);
         }
-        attributes.put( name, value );
-        if( source != null ) {
-            // this mbean is asscoiated with a source - maybe we want to persist
-            source.updateField(oname, name, value);
-        }
+        //attributes.put( name, value );
+//        if( source != null ) {
+//            // this mbean is asscoiated with a source - maybe we want to persist
+//            source.updateField(oname, name, value);
+//        }
     }
 
     public String toString() {
@@ -665,15 +457,13 @@
      * @return The list of attributes that were set and their new values
      */
     public AttributeList setAttributes(AttributeList attributes) {
+        AttributeList response = new AttributeList();
 
         // Validate the input parameters
         if (attributes == null)
-            throw new RuntimeOperationsException
-                (new IllegalArgumentException("Attributes list is null"),
-                 "Attributes list is null");
-
+            return response;
+        
         // Prepare and return our response, eating all exceptions
-        AttributeList response = new AttributeList();
         String names[] = new String[attributes.size()];
         int n = 0;
         Iterator items = attributes.iterator();
@@ -724,10 +514,12 @@
      * Set the instance handle of the object against which we will execute
      * all methods in this ModelMBean management interface.
      *
-     * This method will detect and call "setModelMbean" method. A resource
+     * <strike>This method will detect and call "setModelMbean" method. A resource
      * can implement this method to get a reference to the model mbean.
      * The reference can be used to send notification and access the
      * registry.
+     * </strike> The caller can provide the mbean instance or the object name to
+     * the resource, if needed.
      *
      * @param resource The resource object to be managed
      * @param type The type of reference for the managed resource
@@ -744,7 +536,7 @@
      *  resource type is <code>null</code> or invalid
      */
     public void setManagedResource(Object resource, String type)
-        throws InstanceNotFoundException, InvalidTargetObjectTypeException,
+        throws InstanceNotFoundException, 
         MBeanException, RuntimeOperationsException
     {
         if (resource == null)
@@ -752,58 +544,24 @@
                 (new IllegalArgumentException("Managed resource is null"),
                  "Managed resource is null");
 
-        if (!"objectreference".equalsIgnoreCase(type))
-            throw new InvalidTargetObjectTypeException(type);
+//        if (!"objectreference".equalsIgnoreCase(type))
+//            throw new InvalidTargetObjectTypeException(type);
 
         this.resource = resource;
         this.resourceType = resource.getClass().getName();
         
-        // Make the resource aware of the model mbean.
-        try {
-            Method m=resource.getClass().getMethod("setModelMBean",
-                    new Class[] {ModelMBean.class});
-            if( m!= null ) {
-                m.invoke(resource, new Object[] {this});
-            }
-        } catch( NoSuchMethodException t ) {
-            // ignore
-        } catch( Throwable t ) {
-            log.error( "Can't set model mbean ", t );
-        }
-    }
-
-
-    /**
-     * Initialize the <code>ModelMBeanInfo</code> associated with this
-     * <code>ModelMBean</code>.  After the information and associated
-     * descriptors have been customized, the <code>ModelMBean</code> should
-     * be registered with the associated <code>MBeanServer</code>.
-     *
-     * Currently the model can be set after registration. This behavior is
-     * deprecated and won't be supported in future versions.
-     *
-     * @param info The ModelMBeanInfo object to be used by this ModelMBean
-     *
-     * @exception MBeanException If an exception occurs recording this
-     *  ModelMBeanInfo information
-     * @exception RuntimeOperations if the specified parameter is
-     *  <code>null</code> or invalid
-     */
-    public void setModelMBeanInfo(ModelMBeanInfo info)
-        throws MBeanException, RuntimeOperationsException {
-
-        if (info == null)
-            throw new RuntimeOperationsException
-                (new IllegalArgumentException("ModelMBeanInfo is null"),
-                 "ModelMBeanInfo is null");
-
-        if (!isModelMBeanInfoValid(info))
-            throw new RuntimeOperationsException
-                (new IllegalArgumentException("ModelMBeanInfo is invalid"),
-                 "ModelMBeanInfo is invalid");
-
-        this.info = (ModelMBeanInfo) info.clone();
-
+//        // Make the resource aware of the model mbean.
+//        try {
+//            Method m=resource.getClass().getMethod("setModelMBean",
+//                    new Class[] {ModelMBean.class});
+//            if( m!= null ) {
+//                m.invoke(resource, new Object[] {this});
+//            }
+//        } catch( NoSuchMethodException t ) {
+//            // ignore
+//        } catch( Throwable t ) {
+//            log.error( "Can't set model mbean ", t );
+//        }
     }
 
 
@@ -1058,38 +816,38 @@
     public MBeanNotificationInfo[] getNotificationInfo() {
 
         // Acquire the set of application notifications
-        MBeanNotificationInfo current[] = info.getNotifications();
+        MBeanNotificationInfo current[] = getMBeanInfo().getNotifications();
         if (current == null)
             current = new MBeanNotificationInfo[0];
         MBeanNotificationInfo response[] =
             new MBeanNotificationInfo[current.length + 2];
-        Descriptor descriptor = null;
+ //       Descriptor descriptor = null;
 
         // Fill in entry for general notifications
-        descriptor = new DescriptorSupport
-            (new String[] { "name=GENERIC",
-                            "descriptorType=notification",
-                            "log=T",
-                            "severity=5",
-                            "displayName=jmx.modelmbean.generic" });
-        response[0] = new ModelMBeanNotificationInfo
+//        descriptor = new DescriptorSupport
+//            (new String[] { "name=GENERIC",
+//                            "descriptorType=notification",
+//                            "log=T",
+//                            "severity=5",
+//                            "displayName=jmx.modelmbean.generic" });
+        response[0] = new MBeanNotificationInfo
             (new String[] { "jmx.modelmbean.generic" },
              "GENERIC",
-             "Text message notification from the managed resource",
-             descriptor);
+             "Text message notification from the managed resource");
+             //descriptor);
 
         // Fill in entry for attribute change notifications
-        descriptor = new DescriptorSupport
-            (new String[] { "name=ATTRIBUTE_CHANGE",
-                            "descriptorType=notification",
-                            "log=T",
-                            "severity=5",
-                            "displayName=jmx.attribute.change" });
-        response[1] = new ModelMBeanNotificationInfo
+//        descriptor = new DescriptorSupport
+//            (new String[] { "name=ATTRIBUTE_CHANGE",
+//                            "descriptorType=notification",
+//                            "log=T",
+//                            "severity=5",
+//                            "displayName=jmx.attribute.change" });
+        response[1] = new MBeanNotificationInfo
             (new String[] { "jmx.attribute.change" },
              "ATTRIBUTE_CHANGE",
-             "Observed MBean attribute value has changed",
-             descriptor);
+             "Observed MBean attribute value has changed");
+             //descriptor);
 
         // Copy remaining notifications as reported by the application
         System.arraycopy(current, 0, response, 2, current.length);
@@ -1183,14 +941,14 @@
      * @exception RuntimeOperationsException if an exception is reported
      *  by the persistence mechanism
      */
-    public void load() throws InstanceNotFoundException,
-        MBeanException, RuntimeOperationsException {
-        // XXX If a context was set, use it to load the data
-        throw new MBeanException
-            (new IllegalStateException("Persistence is not supported"),
-             "Persistence is not supported");
-
-    }
+//    public void load() throws InstanceNotFoundException,
+//        MBeanException, RuntimeOperationsException {
+//        // XXX If a context was set, use it to load the data
+//        throw new MBeanException
+//            (new IllegalStateException("Persistence is not supported"),
+//             "Persistence is not supported");
+//
+//    }
 
 
     /**
@@ -1209,15 +967,15 @@
      * @exception RuntimeOperationsException if an exception is reported
      *  by the persistence mechanism
      */
-    public void store() throws InstanceNotFoundException,
-        MBeanException, RuntimeOperationsException {
-
-        // XXX if a context was set, use it to store the data
-        throw new MBeanException
-            (new IllegalStateException("Persistence is not supported"),
-             "Persistence is not supported");
-
-    }
+//    public void store() throws InstanceNotFoundException,
+//        MBeanException, RuntimeOperationsException {
+//
+//        // XXX if a context was set, use it to store the data
+//        throw new MBeanException
+//            (new IllegalStateException("Persistence is not supported"),
+//             "Persistence is not supported");
+//
+//    }
 
     // --------------------  BaseModelMBean methods --------------------
 
@@ -1226,62 +984,62 @@
      *
      * @param type the type of classname of the modeled object
      */
-    public void setModeledType( String type ) {
-        initModelInfo(type);
-        createResource();
-    }
+//    void setModeledType( String type ) {
+//        initModelInfo(type);
+//        createResource();
+//    }
     /** Set the type of the mbean. This is used as a key to locate
      * the description in the Registry.
      *
      * @param type the type of classname of the modeled object
      */
-    protected void initModelInfo( String type ) {
-        try {
-            if( log.isDebugEnabled())
-                log.debug("setModeledType " + type);
-
-            log.debug( "Set model Info " + type);
-            if(type==null) {
-                return;
-            }
-            resourceType=type;
-            //Thread.currentThread().setContextClassLoader(BaseModelMBean.class.getClassLoader());
-            Class c=null;
-            try {
-                c=Class.forName( type);
-            } catch( Throwable t ) {
-                log.debug( "Error creating class " + t);
-            }
-
-            // The class c doesn't need to exist
-            ManagedBean descriptor=getRegistry().findManagedBean(c, type);
-            if( descriptor==null ) 
-                return;
-            this.setModelMBeanInfo(descriptor.createMBeanInfo());
-        } catch( Throwable ex) {
-            log.error( "TCL: " + Thread.currentThread().getContextClassLoader(),
-                    ex);
-        }
-    }
+//    void initModelInfo( String type ) {
+//        try {
+//            if( log.isDebugEnabled())
+//                log.debug("setModeledType " + type);
+//
+//            log.debug( "Set model Info " + type);
+//            if(type==null) {
+//                return;
+//            }
+//            resourceType=type;
+//            //Thread.currentThread().setContextClassLoader(BaseModelMBean.class.getClassLoader());
+//            Class c=null;
+//            try {
+//                c=Class.forName( type);
+//            } catch( Throwable t ) {
+//                log.debug( "Error creating class " + t);
+//            }
+//
+//            // The class c doesn't need to exist
+//            ManagedBean descriptor=getRegistry().findManagedBean(c, type);
+//            if( descriptor==null ) 
+//                return;
+//            this.setModelMBeanInfo(descriptor.createMBeanInfo());
+//        } catch( Throwable ex) {
+//            log.error( "TCL: " + Thread.currentThread().getContextClassLoader(),
+//                    ex);
+//        }
+//    }
 
     /** Set the type of the mbean. This is used as a key to locate
      * the description in the Registry.
      */
-    protected void createResource() {
-        try {
-            //Thread.currentThread().setContextClassLoader(BaseModelMBean.class.getClassLoader());
-            Class c=null;
-            try {
-                c=Class.forName( resourceType );
-                resource = c.newInstance();
-            } catch( Throwable t ) {
-                log.error( "Error creating class " + t);
-            }
-        } catch( Throwable ex) {
-            log.error( "TCL: " + Thread.currentThread().getContextClassLoader(),
-                    ex);
-        }
-    }
+//    protected void createResource() {
+//        try {
+//            //Thread.currentThread().setContextClassLoader(BaseModelMBean.class.getClassLoader());
+//            Class c=null;
+//            try {
+//                c=Class.forName( resourceType );
+//                resource = c.newInstance();
+//            } catch( Throwable t ) {
+//                log.error( "Error creating class " + t);
+//            }
+//        } catch( Throwable ex) {
+//            log.error( "TCL: " + Thread.currentThread().getContextClassLoader(),
+//                    ex);
+//        }
+//    }
 
 
     public String getModelerType() {
@@ -1304,17 +1062,17 @@
         }
     }
 
-    public void setRegistry(Registry registry) {
-        this.registry = registry;
-    }
-
-    public Registry getRegistry() {
-        // XXX Need a better solution - to avoid the static
-        if( registry == null )
-            registry=Registry.getRegistry();
-
-        return registry;
-    }
+//    public void setRegistry(Registry registry) {
+//        this.registry = registry;
+//    }
+//
+//    public Registry getRegistry() {
+//        // XXX Need a better solution - to avoid the static
+//        if( registry == null )
+//            registry=Registry.getRegistry();
+//
+//        return registry;
+//    }
 
     // ------------------------------------------------------ Protected Methods
 
@@ -1322,13 +1080,13 @@
     /**
      * Create and return a default <code>ModelMBeanInfo</code> object.
      */
-    protected ModelMBeanInfo createDefaultModelMBeanInfo() {
-
-        return (new ModelMBeanInfoSupport(this.getClass().getName(),
-                                          "Default ModelMBean",
-                                          null, null, null, null));
-
-    }
+//    protected ModelMBeanInfo createDefaultModelMBeanInfo() {
+//
+//        return (new ModelMBeanInfoSupport(this.getClass().getName(),
+//                                          "Default ModelMBean",
+//                                          null, null, null, null));
+//
+//    }
 
     /**
      * Is the specified <code>ModelMBeanInfo</code> instance valid?
@@ -1339,9 +1097,9 @@
      *
      * @param info The <code>ModelMBeanInfo object to check
      */
-    protected boolean isModelMBeanInfoValid(ModelMBeanInfo info) {
-        return (true);
-    }
+//    protected boolean isModelMBeanInfoValid(ModelMBeanInfo info) {
+//        return (true);
+//    }
 
     // -------------------- Registration  --------------------
     // XXX We can add some method patterns here- like setName() and

Modified: tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/modeler/ConstructorInfo.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/modeler/ConstructorInfo.java?rev=415811&r1=415810&r2=415811&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/modeler/ConstructorInfo.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/modeler/ConstructorInfo.java Tue Jun 20 14:31:42 2006
@@ -20,9 +20,7 @@
 
 import java.io.Serializable;
 
-import javax.management.Descriptor;
-import javax.management.MBeanParameterInfo;
-import javax.management.modelmbean.ModelMBeanConstructorInfo;
+import javax.management.MBeanConstructorInfo;
 
 
 /**
@@ -30,135 +28,28 @@
  * descriptor.</p>
  *
  * @author Craig R. McClanahan
- * @version $Revision: 155428 $ $Date: 2005-02-26 14:12:25 +0100 (sam., 26 févr. 2005) $
  */
-
-public class ConstructorInfo extends FeatureInfo implements Serializable {
+public class ConstructorInfo extends OperationInfo implements Serializable {
     static final long serialVersionUID = -5735336213417238238L;
-
-    // ----------------------------------------------------- Instance Variables
-
-
-    /**
-     * The <code>ModelMBeanConstructorInfo</code> object that corresponds
-     * to this <code>ConstructorInfo</code> instance.
-     */
-    transient ModelMBeanConstructorInfo info = null;
-    protected String displayName = null;
-    protected ParameterInfo parameters[] = new ParameterInfo[0];
-
-
     // ------------------------------------------------------------- Properties
 
-
-    /**
-     * Override the <code>description</code> property setter.
-     *
-     * @param description The new description
-     */
-    public void setDescription(String description) {
-        super.setDescription(description);
-        this.info = null;
+    public ConstructorInfo() {
     }
 
-
-    /**
-     * Override the <code>name</code> property setter.
-     *
-     * @param name The new name
-     */
-    public void setName(String name) {
-        super.setName(name);
-        this.info = null;
-    }
-
-
-    /**
-     * The display name of this attribute.
-     */
-    public String getDisplayName() {
-        return (this.displayName);
-    }
-
-    public void setDisplayName(String displayName) {
-        this.displayName = displayName;
-    }
-
-
-    /**
-     * The set of parameters for this constructor.
-     */
-    public ParameterInfo[] getSignature() {
-        return (this.parameters);
-    }
-
-
     // --------------------------------------------------------- Public Methods
 
 
     /**
-     * Add a new parameter to the set of parameters for this constructor.
-     *
-     * @param parameter The new parameter descriptor
-     */
-    public void addParameter(ParameterInfo parameter) {
-
-        synchronized (parameters) {
-            ParameterInfo results[] = new ParameterInfo[parameters.length + 1];
-            System.arraycopy(parameters, 0, results, 0, parameters.length);
-            results[parameters.length] = parameter;
-            parameters = results;
-            this.info = null;
-        }
-
-    }
-
-
-    /**
      * Create and return a <code>ModelMBeanConstructorInfo</code> object that
      * corresponds to the attribute described by this instance.
      */
-    public ModelMBeanConstructorInfo createConstructorInfo() {
-
+    public MBeanConstructorInfo createConstructorInfo() {
         // Return our cached information (if any)
-        if (info != null)
-            return (info);
-
-        // Create and return a new information object
-        ParameterInfo params[] = getSignature();
-        MBeanParameterInfo parameters[] =
-            new MBeanParameterInfo[params.length];
-        for (int i = 0; i < params.length; i++)
-            parameters[i] = params[i].createParameterInfo();
-        info = new ModelMBeanConstructorInfo
-            (getName(), getDescription(), parameters);
-        Descriptor descriptor = info.getDescriptor();
-        descriptor.removeField("class");
-        if (getDisplayName() != null)
-            descriptor.setField("displayName", getDisplayName());
-        addFields(descriptor);
-        info.setDescriptor(descriptor);
-        return (info);
-
-    }
-
-
-    /**
-     * Return a string representation of this constructor descriptor.
-     */
-    public String toString() {
-
-        StringBuffer sb = new StringBuffer("ConstructorInfo[");
-        sb.append("name=");
-        sb.append(name);
-        sb.append(", description=");
-        sb.append(description);
-        sb.append(", parameters=");
-        sb.append(parameters.length);
-        sb.append("]");
-        return (sb.toString());
-
+        if (info == null) {
+            info = new MBeanConstructorInfo(getName(), getDescription(), 
+                    getMBeanParameterInfo());
+        }
+        return (MBeanConstructorInfo)info;
     }
-
 
 }

Modified: tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/modeler/FeatureInfo.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/modeler/FeatureInfo.java?rev=415811&r1=415810&r2=415811&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/modeler/FeatureInfo.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/modeler/FeatureInfo.java Tue Jun 20 14:31:42 2006
@@ -19,11 +19,8 @@
 
 
 import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
 
-import javax.management.Descriptor;
+import javax.management.MBeanFeatureInfo;
 
 
 /**
@@ -38,13 +35,17 @@
 
 public class FeatureInfo implements Serializable {
     static final long serialVersionUID = -911529176124712296L;
+    
     protected String description = null;
-    protected List fields = new ArrayList();
     protected String name = null;
+    protected MBeanFeatureInfo info = null;
+    
+    // all have type except Constructor
+    protected String type = null;
 
+    
     // ------------------------------------------------------------- Properties
 
-
     /**
      * The human-readable description of this feature.
      */
@@ -58,14 +59,6 @@
 
 
     /**
-     * The field information for this feature.
-     */
-    public List getFields() {
-        return (fields);
-    }
-
-
-    /**
      * The name of this feature, which must be unique among features in the
      * same collection.
      */
@@ -77,38 +70,15 @@
         this.name = name;
     }
 
-
-    // --------------------------------------------------------- Public Methods
-
-
     /**
-     * <p>Add a new field to the fields associated with the
-     * Descriptor that will be created from this metadata.</p>
-     *
-     * @param field The field to be added
+     * The fully qualified Java class name of this element.
      */
-    public void addField(FieldInfo field) {
-        fields.add(field);
+    public String getType() {
+        return (this.type);
     }
 
-
-    // ------------------------------------------------------ Protected Methods
-
-
-    /**
-     * <p>Add the name/value fields that have been stored into the
-     * specified <code>Descriptor</code> instance.</p>
-     *
-     * @param descriptor The <code>Descriptor</code> to add fields to
-     */
-    protected void addFields(Descriptor descriptor) {
-
-        Iterator items = getFields().iterator();
-        while (items.hasNext()) {
-            FieldInfo item = (FieldInfo) items.next();
-            descriptor.setField(item.getName(), item.getValue());
-        }
-
+    public void setType(String type) {
+        this.type = type;
     }
 
 

Modified: tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/modeler/ManagedBean.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/modeler/ManagedBean.java?rev=415811&r1=415810&r2=415811&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/modeler/ManagedBean.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/modeler/ManagedBean.java Tue Jun 20 14:31:42 2006
@@ -18,22 +18,23 @@
 package org.apache.tomcat.util.modeler;
 
 
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
 
-import javax.management.Descriptor;
+import javax.management.AttributeNotFoundException;
+import javax.management.DynamicMBean;
 import javax.management.InstanceNotFoundException;
+import javax.management.MBeanAttributeInfo;
+import javax.management.MBeanConstructorInfo;
 import javax.management.MBeanException;
+import javax.management.MBeanInfo;
+import javax.management.MBeanNotificationInfo;
+import javax.management.MBeanOperationInfo;
+import javax.management.ReflectionException;
 import javax.management.RuntimeOperationsException;
-import javax.management.modelmbean.InvalidTargetObjectTypeException;
-import javax.management.modelmbean.ModelMBean;
-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 javax.management.ServiceNotFoundException;
+//import javax.management.modelmbean.InvalidTargetObjectTypeException;
 
 
 /**
@@ -46,26 +47,31 @@
 
 public class ManagedBean implements java.io.Serializable
 {
+    private static final String BASE_MBEAN = "org.apache.tomcat.util.modeler.BaseModelMBean";
     // ----------------------------------------------------- Instance Variables
+    static final Object[] NO_ARGS_PARAM=new Object[0];
+    static final Class[] NO_ARGS_PARAM_SIG=new Class[0];
 
 
     /**
      * The <code>ModelMBeanInfo</code> object that corresponds
      * to this <code>ManagedBean</code> instance.
      */
-    transient ModelMBeanInfo info = null;
-    protected AttributeInfo attributes[] = new AttributeInfo[0];
-    protected String className =
-            "org.apache.tomcat.util.modeler.BaseModelMBean";
-    protected ConstructorInfo constructors[] = new ConstructorInfo[0];
+    transient MBeanInfo info = null;
+    // Map<AttributeInfo>
+    private Map attributes = new HashMap();
+    //Map<OperationInfo>
+    private Map operations = new HashMap();
+    
+    protected String className = BASE_MBEAN;
+    //protected ConstructorInfo constructors[] = new ConstructorInfo[0];
     protected String description = null;
     protected String domain = null;
     protected String group = null;
     protected String name = null;
 
-    protected List fields = new ArrayList();
+    //protected List fields = new ArrayList();
     protected NotificationInfo notifications[] = new NotificationInfo[0];
-    protected OperationInfo operations[] = new OperationInfo[0];
     protected String type = null;
 
     /** Constructor. Will add default attributes. 
@@ -87,7 +93,9 @@
      * The collection of attributes for this MBean.
      */
     public AttributeInfo[] getAttributes() {
-        return (this.attributes);
+        AttributeInfo result[] = new AttributeInfo[attributes.size()];
+        attributes.values().toArray(result);
+        return result;
     }
 
 
@@ -107,12 +115,12 @@
     }
 
 
-    /**
-     * The collection of constructors for this MBean.
-     */
-    public ConstructorInfo[] getConstructors() {
-        return (this.constructors);
-    }
+//    /**
+//     * The collection of constructors for this MBean.
+//     */
+//    public ConstructorInfo[] getConstructors() {
+//        return (this.constructors);
+//    }
 
 
     /**
@@ -146,10 +154,10 @@
      * the name/value pairs that should be
      * added to the Descriptor created from this metadata.</p>
      */
-    public List getFields() {
-        return (this.fields);
-    }
-
+//    public List getFields() {
+//        return (this.fields);
+//    }
+//
 
     /**
      * The (optional) group to which this MBean belongs.
@@ -189,7 +197,9 @@
      * The collection of operations for this MBean.
      */
     public OperationInfo[] getOperations() {
-        return (this.operations);
+        OperationInfo[] result = new OperationInfo[operations.size()];
+        operations.values().toArray(result);
+        return result;
     }
 
 
@@ -217,16 +227,7 @@
      * @param attribute The new attribute descriptor
      */
     public void addAttribute(AttributeInfo attribute) {
-
-        synchronized (attributes) {
-            AttributeInfo results[] =
-                new AttributeInfo[attributes.length + 1];
-            System.arraycopy(attributes, 0, results, 0, attributes.length);
-            results[attributes.length] = attribute;
-            attributes = results;
-            this.info = null;
-        }
-
+        attributes.put(attribute.getName(), attribute);
     }
 
 
@@ -235,18 +236,18 @@
      *
      * @param constructor The new constructor descriptor
      */
-    public void addConstructor(ConstructorInfo constructor) {
-
-        synchronized (constructors) {
-            ConstructorInfo results[] =
-                new ConstructorInfo[constructors.length + 1];
-            System.arraycopy(constructors, 0, results, 0, constructors.length);
-            results[constructors.length] = constructor;
-            constructors = results;
-            this.info = null;
-        }
-
-    }
+//    public void addConstructor(ConstructorInfo constructor) {
+//
+//        synchronized (constructors) {
+//            ConstructorInfo results[] =
+//                new ConstructorInfo[constructors.length + 1];
+//            System.arraycopy(constructors, 0, results, 0, constructors.length);
+//            results[constructors.length] = constructor;
+//            constructors = results;
+//            this.info = null;
+//        }
+//
+//    }
 
 
     /**
@@ -255,9 +256,9 @@
      *
      * @param field The field to be added
      */
-    public void addField(FieldInfo field) {
-        fields.add(field);
-    }
+//    public void addField(FieldInfo field) {
+//        fields.add(field);
+//    }
 
 
     /**
@@ -286,15 +287,7 @@
      * @param operation The new operation descriptor
      */
     public void addOperation(OperationInfo operation) {
-        synchronized (operations) {
-            OperationInfo results[] =
-                new OperationInfo[operations.length + 1];
-            System.arraycopy(operations, 0, results, 0, operations.length);
-            results[operations.length] = operation;
-            operations = results;
-            this.info = null;
-        }
-
+        operations.put(operation.getName(), operation);
     }
 
 
@@ -314,9 +307,8 @@
      *  <code>ModelMBean</code> instance
      * @exception RuntimeOperationsException if a JMX runtime error occurs
      */
-    public ModelMBean createMBean()
+    public DynamicMBean createMBean()
         throws InstanceNotFoundException,
-        InvalidTargetObjectTypeException,
         MBeanException, RuntimeOperationsException {
 
         return (createMBean(null));
@@ -343,57 +335,58 @@
      *  <code>ModelMBean</code> instance
      * @exception RuntimeOperationsException if a JMX runtime error occurs
      */
-    public ModelMBean createMBean(Object instance)
+    public DynamicMBean createMBean(Object instance)
         throws InstanceNotFoundException,
-        InvalidTargetObjectTypeException,
         MBeanException, RuntimeOperationsException {
 
+        BaseModelMBean mbean = null;
+
         // Load the ModelMBean implementation class
-        Class clazz = null;
-        Exception ex = null;
-        try {
-            clazz = Class.forName(getClassName());
-        } catch (Exception e) {
-        }
-      
-        if( clazz==null ) {  
+        if(getClassName().equals(BASE_MBEAN)) {
+            // Skip introspection
+            mbean = new BaseModelMBean();
+        } else {
+            Class clazz = null;
+            Exception ex = null;
             try {
-                ClassLoader cl= Thread.currentThread().getContextClassLoader();
-                if ( cl != null)
-                    clazz= cl.loadClass(getClassName());
+                clazz = Class.forName(getClassName());
             } catch (Exception e) {
-                ex=e;
+            }
+          
+            if( clazz==null ) {  
+                try {
+                    ClassLoader cl= Thread.currentThread().getContextClassLoader();
+                    if ( cl != null)
+                        clazz= cl.loadClass(getClassName());
+                } catch (Exception e) {
+                    ex=e;
+                }
+            }
+    
+            if( clazz==null) { 
+                throw new MBeanException
+                    (ex, "Cannot load ModelMBean class " + getClassName());
+            }
+            try {
+                // Stupid - this will set the default minfo first....
+                mbean = (BaseModelMBean) clazz.newInstance();
+            } catch (RuntimeOperationsException e) {
+                throw e;
+            } catch (Exception e) {
+                throw new MBeanException
+                    (e, "Cannot instantiate ModelMBean of class " +
+                     getClassName());
             }
         }
-
-        if( clazz==null) { 
-            throw new MBeanException
-                (ex, "Cannot load ModelMBean class " + getClassName());
-        }
-
-        // Create a new ModelMBean instance
-        ModelMBean mbean = null;
-        try {
-            mbean = (ModelMBean) clazz.newInstance();
-            mbean.setModelMBeanInfo(createMBeanInfo());
-        } catch (MBeanException e) {
-            throw e;
-        } catch (RuntimeOperationsException e) {
-            throw e;
-        } catch (Exception e) {
-            throw new MBeanException
-                (e, "Cannot instantiate ModelMBean of class " +
-                 getClassName());
-        }
-
+        
+        mbean.setManagedBean(this);
+        
         // Set the managed resource (if any)
         try {
             if (instance != null)
                 mbean.setManagedResource(instance, "ObjectReference");
         } catch (InstanceNotFoundException e) {
             throw e;
-        } catch (InvalidTargetObjectTypeException e) {
-            throw e;
         }
         return (mbean);
 
@@ -404,7 +397,7 @@
      * Create and return a <code>ModelMBeanInfo</code> object that
      * describes this entire managed bean.
      */
-    public ModelMBeanInfo createMBeanInfo() {
+    MBeanInfo getMBeanInfo() {
 
         // Return our cached information (if any)
         if (info != null)
@@ -412,69 +405,49 @@
 
         // Create subordinate information descriptors as required
         AttributeInfo attrs[] = getAttributes();
-        ModelMBeanAttributeInfo attributes[] =
-            new ModelMBeanAttributeInfo[attrs.length];
+        MBeanAttributeInfo attributes[] =
+            new MBeanAttributeInfo[attrs.length];
         for (int i = 0; i < attrs.length; i++)
             attributes[i] = attrs[i].createAttributeInfo();
+
+        OperationInfo opers[] = getOperations();
+        MBeanOperationInfo operations[] =
+            new MBeanOperationInfo[opers.length];
+        for (int i = 0; i < opers.length; i++)
+            operations[i] = opers[i].createOperationInfo();
+
+
+//        ConstructorInfo consts[] = getConstructors();
+//        ModelMBeanConstructorInfo constructors[] =
+//            new ModelMBeanConstructorInfo[consts.length];
+//        for (int i = 0; i < consts.length; i++)
+//            constructors[i] = consts[i].createConstructorInfo();
         
-        ConstructorInfo consts[] = getConstructors();
-        ModelMBeanConstructorInfo constructors[] =
-            new ModelMBeanConstructorInfo[consts.length];
-        for (int i = 0; i < consts.length; i++)
-            constructors[i] = consts[i].createConstructorInfo();
         NotificationInfo notifs[] = getNotifications();
-        ModelMBeanNotificationInfo notifications[] =
-            new ModelMBeanNotificationInfo[notifs.length];
+        MBeanNotificationInfo notifications[] =
+            new MBeanNotificationInfo[notifs.length];
         for (int i = 0; i < notifs.length; i++)
             notifications[i] = notifs[i].createNotificationInfo();
-        OperationInfo opers[] = getOperations();
-        ModelMBeanOperationInfo operations[] =
-            new ModelMBeanOperationInfo[opers.length];
-        for (int i = 0; i < opers.length; i++)
-            operations[i] = opers[i].createOperationInfo();
 
-        /*
-        // Add operations for attribute getters and setters as needed
-        ArrayList list = new ArrayList();
-        for (int i = 0; i < operations.length; i++)
-            list.add(operations[i]);
-        for (int i = 0; i < attributes.length; i++) {
-            Descriptor descriptor = attributes[i].getDescriptor();
-            String getMethod = (String) descriptor.getFieldValue("getMethod");
-            if (getMethod != null) {
-                OperationInfo oper =
-                    new OperationInfo(getMethod, true,
-                                      attributes[i].getType());
-                list.add(oper.createOperationInfo());
-            }
-            String setMethod = (String) descriptor.getFieldValue("setMethod");
-            if (setMethod != null) {
-                OperationInfo oper =
-                    new OperationInfo(setMethod, false,
-                                      attributes[i].getType());
-                list.add(oper.createOperationInfo());
-            }
-        }
-        if (list.size() > operations.length)
-            operations =
-                (ModelMBeanOperationInfo[]) list.toArray(operations);
-        */
         
         // Construct and return a new ModelMBeanInfo object
-        info = new ModelMBeanInfoSupport
-            (getClassName(), getDescription(),
-             attributes, constructors, operations, notifications);
-        try {
-            Descriptor descriptor = info.getMBeanDescriptor();
-            Iterator fields = getFields().iterator();
-            while (fields.hasNext()) {
-                FieldInfo field = (FieldInfo) fields.next();
-                descriptor.setField(field.getName(), field.getValue());
-            }
-            info.setMBeanDescriptor(descriptor);
-        } catch (MBeanException e) {
-            ;
-        }
+        info = new MBeanInfo(getClassName(), 
+                             getDescription(),
+                             attributes, 
+                             new MBeanConstructorInfo[] {}, 
+                             operations, 
+                             notifications);
+//        try {
+//            Descriptor descriptor = info.getMBeanDescriptor();
+//            Iterator fields = getFields().iterator();
+//            while (fields.hasNext()) {
+//                FieldInfo field = (FieldInfo) fields.next();
+//                descriptor.setField(field.getName(), field.getValue());
+//            }
+//            info.setMBeanDescriptor(descriptor);
+//        } catch (MBeanException e) {
+//            ;
+//        }
 
         return (info);
 
@@ -502,6 +475,152 @@
         sb.append("]");
         return (sb.toString());
 
+    }
+
+    Method getGetter(String aname, BaseModelMBean mbean, Object resource) 
+            throws AttributeNotFoundException, MBeanException, ReflectionException {
+        // TODO: do we need caching ? JMX is for management, it's not supposed to require lots of performance.
+        Method m=null; // (Method)getAttMap.get( name );
+
+        if( m==null ) {
+            AttributeInfo attrInfo = (AttributeInfo)attributes.get(aname);
+            // Look up the actual operation to be used
+            if (attrInfo == null)
+                throw new AttributeNotFoundException(" Cannot find attribute " + aname + " for " + resource);
+            
+            String getMethod = attrInfo.getGetMethod();
+            if (getMethod == null)
+                throw new AttributeNotFoundException("Cannot find attribute " + aname + " get method name");
+
+            Object object = null;
+            NoSuchMethodException exception = null;
+            try {
+                object = mbean;
+                m = object.getClass().getMethod(getMethod, NO_ARGS_PARAM_SIG);
+            } catch (NoSuchMethodException e) {
+                exception = e;;
+            }
+            if( m== null && resource != null ) {
+                try {
+                    object = resource;
+                    m = object.getClass().getMethod(getMethod, NO_ARGS_PARAM_SIG);
+                    exception=null;
+                } catch (NoSuchMethodException e) {
+                    exception = e;
+                }
+            }
+            if( exception != null )
+                throw new ReflectionException(exception,
+                                              "Cannot find getter method " + getMethod);
+            //getAttMap.put( name, m );
+        }
+
+        return m;
+    }
+
+    public Method getSetter(String aname, BaseModelMBean bean, Object resource) 
+            throws AttributeNotFoundException, MBeanException, ReflectionException {
+        // Cache may be needed for getters, but it is a really bad idea for setters, this is far 
+        // less frequent.
+        Method m=null;//(Method)setAttMap.get( name );
+
+        if( m==null ) {
+            AttributeInfo attrInfo = (AttributeInfo)attributes.get(aname);
+            if (attrInfo == null)
+                throw new AttributeNotFoundException(" Cannot find attribute " + aname);
+
+            // Look up the actual operation to be used
+            String setMethod = attrInfo.getSetMethod();
+            if (setMethod == null)
+                throw new AttributeNotFoundException("Cannot find attribute " + aname + " set method name");
+
+            String argType=attrInfo.getType();
+
+            Class signature[] = new Class[] { BaseModelMBean.getAttributeClass( argType ) };
+
+            Object object = null;
+            NoSuchMethodException exception = null;
+            try {
+                object = this;
+                m = object.getClass().getMethod(setMethod, signature);
+            } catch (NoSuchMethodException e) {
+                exception = e;;
+            }
+            if( m== null && resource != null ) {
+                try {
+                    object = resource;
+                    m = object.getClass().getMethod(setMethod, signature);
+                    exception=null;
+                } catch (NoSuchMethodException e) {
+                    exception = e;
+                }
+            }
+            if( exception != null )
+                throw new ReflectionException(exception,
+                                              "Cannot find setter method " + setMethod +
+                        " " + resource);
+            //setAttMap.put( name, m );
+        }
+
+        return m;
+    }
+
+    public Method getInvoke(String aname, Object[] params, String[] signature, BaseModelMBean bean, Object resource) 
+            throws MBeanException, ReflectionException {
+        Method method = null;
+        if (method == null) {
+            if (params == null)
+                params = new Object[0];
+            if (signature == null)
+                signature = new String[0];
+            if (params.length != signature.length)
+                throw new RuntimeOperationsException(
+                        new IllegalArgumentException(
+                                "Inconsistent arguments and signature"),
+                        "Inconsistent arguments and signature");
+
+            // Acquire the ModelMBeanOperationInfo information for
+            // the requested operation
+            OperationInfo opInfo = (OperationInfo)operations.get(aname);
+            if (opInfo == null)
+                throw new MBeanException(new ServiceNotFoundException(
+                        "Cannot find operation " + aname),
+                        "Cannot find operation " + aname);
+
+            // Prepare the signature required by Java reflection APIs
+            // FIXME - should we use the signature from opInfo?
+            Class types[] = new Class[signature.length];
+            for (int i = 0; i < signature.length; i++) {
+                types[i] = BaseModelMBean.getAttributeClass(signature[i]);
+            }
+
+            // Locate the method to be invoked, either in this MBean itself
+            // or in the corresponding managed resource
+            // FIXME - Accessible methods in superinterfaces?
+            Object object = null;
+            Exception exception = null;
+            try {
+                object = this;
+                method = object.getClass().getMethod(aname, types);
+            } catch (NoSuchMethodException e) {
+                exception = e;
+                ;
+            }
+            try {
+                if ((method == null) && (resource != null)) {
+                    object = resource;
+                    method = object.getClass().getMethod(aname, types);
+                }
+            } catch (NoSuchMethodException e) {
+                exception = e;
+            }
+            if (method == null) {
+                throw new ReflectionException(exception, "Cannot find method "
+                        + aname + " with this signature");
+            }
+            // invokeAttMap.put(mkey, method);
+        }
+        return method;
     }
 
 

Modified: tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/modeler/NotificationInfo.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/modeler/NotificationInfo.java?rev=415811&r1=415810&r2=415811&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/modeler/NotificationInfo.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/modeler/NotificationInfo.java Tue Jun 20 14:31:42 2006
@@ -20,8 +20,7 @@
 
 import java.io.Serializable;
 
-import javax.management.Descriptor;
-import javax.management.modelmbean.ModelMBeanNotificationInfo;
+import javax.management.MBeanNotificationInfo;
 
 
 /**
@@ -42,7 +41,7 @@
      * The <code>ModelMBeanNotificationInfo</code> object that corresponds
      * to this <code>NotificationInfo</code> instance.
      */
-    transient ModelMBeanNotificationInfo info = null;
+    transient MBeanNotificationInfo info = null;
     protected String notifTypes[] = new String[0];
 
     // ------------------------------------------------------------- Properties
@@ -103,18 +102,18 @@
      * Create and return a <code>ModelMBeanNotificationInfo</code> object that
      * corresponds to the attribute described by this instance.
      */
-    public ModelMBeanNotificationInfo createNotificationInfo() {
+    public MBeanNotificationInfo createNotificationInfo() {
 
         // Return our cached information (if any)
         if (info != null)
             return (info);
 
         // Create and return a new information object
-        info = new ModelMBeanNotificationInfo
+        info = new MBeanNotificationInfo
             (getNotifTypes(), getName(), getDescription());
-        Descriptor descriptor = info.getDescriptor();
-        addFields(descriptor);
-        info.setDescriptor(descriptor);
+        //Descriptor descriptor = info.getDescriptor();
+        //addFields(descriptor);
+        //info.setDescriptor(descriptor);
         return (info);
 
     }

Modified: tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/modeler/OperationInfo.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/modeler/OperationInfo.java?rev=415811&r1=415810&r2=415811&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/modeler/OperationInfo.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/modeler/OperationInfo.java Tue Jun 20 14:31:42 2006
@@ -20,9 +20,8 @@
 
 import java.io.Serializable;
 
-import javax.management.Descriptor;
+import javax.management.MBeanOperationInfo;
 import javax.management.MBeanParameterInfo;
-import javax.management.modelmbean.ModelMBeanOperationInfo;
 
 
 /**
@@ -30,9 +29,7 @@
  * descriptor.</p>
  *
  * @author Craig R. McClanahan
- * @version $Revision: 155428 $ $Date: 2005-02-26 14:12:25 +0100 (sam., 26 févr. 2005) $
  */
-
 public class OperationInfo extends FeatureInfo implements Serializable {
     static final long serialVersionUID = 4418342922072614875L;
     // ----------------------------------------------------------- Constructors
@@ -46,77 +43,16 @@
         super();
 
     }
-
-
-    /**
-     * Special constructor for setting up getter and setter operations.
-     *
-     * @param name Name of this operation
-     * @param getter Is this a getter (as opposed to a setter)?
-     * @param type Data type of the return value (if this is a getter)
-     *  or the parameter (if this is a setter)
-     * 
-     */
-    public OperationInfo(String name, boolean getter, String type) {
-
-        super();
-        setName(name);
-        if (getter) {
-            setDescription("Attribute getter method");
-            setImpact("INFO");
-            setReturnType(type);
-            setRole("getter");
-        } else {
-            setDescription("Attribute setter method");
-            setImpact("ACTION");
-            setReturnType("void");
-            setRole("setter");
-            addParameter(new ParameterInfo("value", type,
-                                           "New attribute value"));
-        }
-
-    }
-
-
+   
     // ----------------------------------------------------- Instance Variables
 
-
-    /**
-     * The <code>ModelMBeanOperationInfo</code> object that corresponds
-     * to this <code>OperationInfo</code> instance.
-     */
-    transient ModelMBeanOperationInfo info = null;
     protected String impact = "UNKNOWN";
     protected String role = "operation";
-    protected String returnType = "void";    // FIXME - Validate
     protected ParameterInfo parameters[] = new ParameterInfo[0];
 
 
     // ------------------------------------------------------------- Properties
 
-
-    /**
-     * Override the <code>description</code> property setter.
-     *
-     * @param description The new description
-     */
-    public void setDescription(String description) {
-        super.setDescription(description);
-        this.info = null;
-    }
-
-
-    /**
-     * Override the <code>name</code> property setter.
-     *
-     * @param name The new name
-     */
-    public void setName(String name) {
-        super.setName(name);
-        this.info = null;
-    }
-
-
     /**
      * The "impact" of this operation, which should be a (case-insensitive)
      * string value "ACTION", "ACTION_INFO", "INFO", or "UNKNOWN".
@@ -151,11 +87,14 @@
      * operation.
      */
     public String getReturnType() {
-        return (this.returnType);
+        if(type == null) {
+            type = "void";
+        }
+        return type;
     }
 
     public void setReturnType(String returnType) {
-        this.returnType = returnType;
+        this.type = returnType;
     }
 
     /**
@@ -190,57 +129,32 @@
      * Create and return a <code>ModelMBeanOperationInfo</code> object that
      * corresponds to the attribute described by this instance.
      */
-    public ModelMBeanOperationInfo createOperationInfo() {
+    MBeanOperationInfo createOperationInfo() {
 
         // Return our cached information (if any)
-        if (info != null)
-            return (info);
+        if (info == null) {
+            // Create and return a new information object
+            int impact = MBeanOperationInfo.UNKNOWN;
+            if ("ACTION".equals(getImpact()))
+                impact = MBeanOperationInfo.ACTION;
+            else if ("ACTION_INFO".equals(getImpact()))
+                impact = MBeanOperationInfo.ACTION_INFO;
+            else if ("INFO".equals(getImpact()))
+                impact = MBeanOperationInfo.INFO;
+    
+            info = new MBeanOperationInfo(getName(), getDescription(), 
+                                          getMBeanParameterInfo(),
+                                          getReturnType(), impact);
+        }
+        return (MBeanOperationInfo)info;
+    }
 
-        // Create and return a new information object
+    protected MBeanParameterInfo[] getMBeanParameterInfo() {
         ParameterInfo params[] = getSignature();
         MBeanParameterInfo parameters[] =
             new MBeanParameterInfo[params.length];
         for (int i = 0; i < params.length; i++)
             parameters[i] = params[i].createParameterInfo();
-        int impact = ModelMBeanOperationInfo.UNKNOWN;
-        if ("ACTION".equals(getImpact()))
-            impact = ModelMBeanOperationInfo.ACTION;
-        else if ("ACTION_INFO".equals(getImpact()))
-            impact = ModelMBeanOperationInfo.ACTION_INFO;
-        else if ("INFO".equals(getImpact()))
-            impact = ModelMBeanOperationInfo.INFO;
-
-        info = new ModelMBeanOperationInfo
-            (getName(), getDescription(), parameters,
-             getReturnType(), impact);
-        Descriptor descriptor = info.getDescriptor();
-        descriptor.removeField("class");
-        descriptor.setField("role", getRole());
-        addFields(descriptor);
-        info.setDescriptor(descriptor);
-        return (info);
-
-    }
-
-
-    /**
-     * Return a string representation of this operation descriptor.
-     */
-    public String toString() {
-
-        StringBuffer sb = new StringBuffer("OperationInfo[");
-        sb.append("name=");
-        sb.append(name);
-        sb.append(", description=");
-        sb.append(description);
-        sb.append(", returnType=");
-        sb.append(returnType);
-        sb.append(", parameters=");
-        sb.append(parameters.length);
-        sb.append("]");
-        return (sb.toString());
-
+        return parameters;
     }
-
-
 }

Modified: tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/modeler/ParameterInfo.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/modeler/ParameterInfo.java?rev=415811&r1=415810&r2=415811&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/modeler/ParameterInfo.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/modeler/ParameterInfo.java Tue Jun 20 14:31:42 2006
@@ -40,80 +40,9 @@
      * Standard zero-arguments constructor.
      */
     public ParameterInfo() {
-
-        super();
-
-    }
-
-
-    /**
-     * Special constructor for setting up parameters programatically.
-     *
-     * @param name Name of this parameter
-     * @param type Java class of this parameter
-     * @param description Description of this parameter
-     */
-    public ParameterInfo(String name, String type, String description) {
-
         super();
-        setName(name);
-        setType(type);
-        setDescription(description);
-
-    }
-
-
-    // ----------------------------------------------------- Instance Variables
-
-
-    /**
-     * The <code>MBeanParameterInfo</code> object that corresponds
-     * to this <code>ParameterInfo</code> instance.
-     */
-    transient MBeanParameterInfo info = null;
-    protected String type = null;
-
-    // ------------------------------------------------------------- Properties
-
-
-    /**
-     * Override the <code>description</code> property setter.
-     *
-     * @param description The new description
-     */
-    public void setDescription(String description) {
-        super.setDescription(description);
-        this.info = null;
-    }
-
-
-    /**
-     * Override the <code>name</code> property setter.
-     *
-     * @param name The new name
-     */
-    public void setName(String name) {
-        super.setName(name);
-        this.info = null;
     }
 
-
-    /**
-     * The fully qualified Java class name of this parameter.
-     */
-    public String getType() {
-        return (this.type);
-    }
-
-    public void setType(String type) {
-        this.type = type;
-        this.info = null;
-    }
-
-
-    // --------------------------------------------------------- Public Methods
-
-
     /**
      * Create and return a <code>MBeanParameterInfo</code> object that
      * corresponds to the parameter described by this instance.
@@ -121,31 +50,10 @@
     public MBeanParameterInfo createParameterInfo() {
 
         // Return our cached information (if any)
-        if (info != null)
-            return (info);
-
-        // Create and return a new information object
-        info = new MBeanParameterInfo
-            (getName(), getType(), getDescription());
-        return (info);
-
-    }
-
-
-    /**
-     * Return a string representation of this parameter descriptor.
-     */
-    public String toString() {
-
-        StringBuffer sb = new StringBuffer("ParameterInfo[");
-        sb.append("name=");
-        sb.append(name);
-        sb.append(", description=");
-        sb.append(description);
-        sb.append(", type=");
-        sb.append(type);
-        sb.append("]");
-        return (sb.toString());
-
+        if (info == null) {
+            info = new MBeanParameterInfo
+                (getName(), getType(), getDescription());
+        }
+        return (MBeanParameterInfo)info;
     }
 }



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