Update the modeler with the sandbox version, using dynamic mbeans instead of model...
authorcostin <costin@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 20 Jun 2006 21:31:42 +0000 (21:31 +0000)
committercostin <costin@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 20 Jun 2006 21:31:42 +0000 (21:31 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc6.0.x/trunk@415811 13f79535-47bb-0310-9956-ffa450edef68

16 files changed:
java/org/apache/tomcat/util/modeler/AttributeInfo.java
java/org/apache/tomcat/util/modeler/BaseModelMBean.java
java/org/apache/tomcat/util/modeler/BaseNotification.java [deleted file]
java/org/apache/tomcat/util/modeler/ConstructorInfo.java
java/org/apache/tomcat/util/modeler/FeatureInfo.java
java/org/apache/tomcat/util/modeler/FieldInfo.java [deleted file]
java/org/apache/tomcat/util/modeler/JndiJmx.java [deleted file]
java/org/apache/tomcat/util/modeler/ManagedBean.java
java/org/apache/tomcat/util/modeler/NotificationInfo.java
java/org/apache/tomcat/util/modeler/OperationInfo.java
java/org/apache/tomcat/util/modeler/ParameterInfo.java
java/org/apache/tomcat/util/modeler/Registry.java
java/org/apache/tomcat/util/modeler/modules/MbeansDescriptorsDOMSource.java
java/org/apache/tomcat/util/modeler/modules/MbeansDescriptorsDigesterSource.java
java/org/apache/tomcat/util/modeler/modules/MbeansDescriptorsDynamicMBeanSource.java [deleted file]
java/org/apache/tomcat/util/modeler/modules/MbeansDescriptorsIntrospectionSource.java

index f806a1d..b69c4e5 100644 (file)
@@ -19,10 +19,8 @@ package org.apache.tomcat.util.modeler;
 \r
 \r
 import java.io.Serializable;\r
-import java.lang.reflect.Method;\r
 \r
-import javax.management.Descriptor;\r
-import javax.management.modelmbean.ModelMBeanAttributeInfo;\r
+import javax.management.MBeanAttributeInfo;\r
 \r
 \r
 /**\r
@@ -30,58 +28,22 @@ import javax.management.modelmbean.ModelMBeanAttributeInfo;
  * descriptor.</p>\r
  *\r
  * @author Craig R. McClanahan\r
- * @version $Revision: 155428 $ $Date: 2005-02-26 14:12:25 +0100 (sam., 26 févr. 2005) $\r
  */\r
-\r
 public class AttributeInfo extends FeatureInfo implements Serializable {\r
     static final long serialVersionUID = -2511626862303972143L;\r
 \r
     // ----------------------------------------------------- Instance Variables\r
-\r
-\r
-    /**\r
-     * The <code>ModelMBeanAttributeInfo</code> object that corresponds\r
-     * to this <code>AttributeInfo</code> instance.\r
-     */\r
-    protected transient ModelMBeanAttributeInfo info = null;\r
     protected String displayName = null;\r
+\r
+    // Information about the method to use\r
     protected String getMethod = null;\r
     protected String setMethod = null;\r
-\r
-    protected transient Method getMethodObj = null;\r
-    protected transient Method setMethodObj = null;\r
-\r
     protected boolean readable = true;\r
     protected boolean writeable = true;\r
-\r
     protected boolean is = false;\r
-    protected String type = null;\r
-\r
-    protected String persist;\r
-    protected String defaultStringValue;\r
+    \r
     // ------------------------------------------------------------- Properties\r
 \r
-\r
-    /**\r
-     * Override the <code>description</code> property setter.\r
-     *\r
-     * @param description The new description\r
-     */\r
-    public void setDescription(String description) {\r
-        super.setDescription(description);\r
-        this.info = null;\r
-    }\r
-\r
-    /**\r
-     * Override the <code>name</code> property setter.\r
-     *\r
-     * @param name The new name\r
-     */\r
-    public void setName(String name) {\r
-        super.setName(name);\r
-        this.info = null;\r
-    }\r
-\r
     /**\r
      * The display name of this attribute.\r
      */\r
@@ -97,28 +59,13 @@ public class AttributeInfo extends FeatureInfo implements Serializable {
      * The name of the property getter method, if non-standard.\r
      */\r
     public String getGetMethod() {\r
+        if(getMethod == null) \r
+            getMethod = getMethodName(getName(), true, isIs());\r
         return (this.getMethod);\r
     }\r
 \r
     public void setGetMethod(String getMethod) {\r
         this.getMethod = getMethod;\r
-        this.info = null;\r
-    }\r
-\r
-    public Method getGetMethodObj() {\r
-        return getMethodObj;\r
-    }\r
-\r
-    public void setGetMethodObj(Method getMethodObj) {\r
-        this.getMethodObj = getMethodObj;\r
-    }\r
-\r
-    public Method getSetMethodObj() {\r
-        return setMethodObj;\r
-    }\r
-\r
-    public void setSetMethodObj(Method setMethodObj) {\r
-        this.setMethodObj = setMethodObj;\r
     }\r
 \r
     /**\r
@@ -130,7 +77,6 @@ public class AttributeInfo extends FeatureInfo implements Serializable {
 \r
     public void setIs(boolean is) {\r
         this.is = is;\r
-        this.info = null;\r
     }\r
 \r
 \r
@@ -143,7 +89,6 @@ public class AttributeInfo extends FeatureInfo implements Serializable {
 \r
     public void setReadable(boolean readable) {\r
         this.readable = readable;\r
-        this.info = null;\r
     }\r
 \r
 \r
@@ -151,28 +96,15 @@ public class AttributeInfo extends FeatureInfo implements Serializable {
      * The name of the property setter method, if non-standard.\r
      */\r
     public String getSetMethod() {\r
+        if( setMethod == null )\r
+            setMethod = getMethodName(getName(), false, false);\r
         return (this.setMethod);\r
     }\r
 \r
     public void setSetMethod(String setMethod) {\r
         this.setMethod = setMethod;\r
-        this.info = null;\r
-    }\r
-\r
-\r
-    /**\r
-     * The fully qualified Java class name of this attribute.\r
-     */\r
-    public String getType() {\r
-        return (this.type);\r
-    }\r
-\r
-    public void setType(String type) {\r
-        this.type = type;\r
-        this.info = null;\r
     }\r
 \r
-\r
     /**\r
      * Is this attribute writeable by management applications?\r
      */\r
@@ -182,35 +114,8 @@ public class AttributeInfo extends FeatureInfo implements Serializable {
 \r
     public void setWriteable(boolean writeable) {\r
         this.writeable = writeable;\r
-        this.info = null;\r
-    }\r
-\r
-    /** Persistence policy.\r
-     * All persistent attributes should have this attribute set.\r
-     * Valid values:\r
-     *   ???\r
-     */\r
-    public String getPersist() {\r
-        return persist;\r
     }\r
 \r
-    public void setPersist(String persist) {\r
-        this.persist = persist;\r
-    }\r
-\r
-    /** Default value. If set, it can provide info to the user and\r
-     * it can be used by persistence mechanism to generate a more compact\r
-     * representation ( a value may not be saved if it's default )\r
-     */\r
-    public String getDefault() {\r
-        return defaultStringValue;\r
-    }\r
-\r
-    public void setDefault(String defaultStringValue) {\r
-        this.defaultStringValue = defaultStringValue;\r
-    }\r
-\r
-\r
     // --------------------------------------------------------- Public Methods\r
 \r
 \r
@@ -218,74 +123,15 @@ public class AttributeInfo extends FeatureInfo implements Serializable {
      * Create and return a <code>ModelMBeanAttributeInfo</code> object that\r
      * corresponds to the attribute described by this instance.\r
      */\r
-    public ModelMBeanAttributeInfo createAttributeInfo() {\r
+    MBeanAttributeInfo createAttributeInfo() {\r
         // Return our cached information (if any)\r
-        if (info != null)\r
-            return (info);\r
-        if((getMethodObj != null) || (setMethodObj != null) ) {\r
-            try {\r
-                info=new ModelMBeanAttributeInfo(getName(), getDescription(),\r
-                                        getMethodObj,  setMethodObj);\r
-                return info;\r
-            } catch( Exception ex) {\r
-                ex.printStackTrace();\r
-            }\r
+        if (info == null) {\r
+            info = new MBeanAttributeInfo(getName(), getType(), getDescription(),\r
+                            isReadable(), isWriteable(), false);\r
         }\r
-\r
-        // Create and return a new information object\r
-        info = new ModelMBeanAttributeInfo\r
-            (getName(), getType(), getDescription(),\r
-             isReadable(), isWriteable(), false);\r
-        Descriptor descriptor = info.getDescriptor();\r
-        if (getDisplayName() != null)\r
-            descriptor.setField("displayName", getDisplayName());\r
-        if (isReadable()) {\r
-            if (getGetMethod() != null)\r
-                descriptor.setField("getMethod", getGetMethod());\r
-            else\r
-                descriptor.setField("getMethod",\r
-                                    getMethodName(getName(), true, isIs()));\r
-        }\r
-        if (isWriteable()) {\r
-            if (getSetMethod() != null)\r
-                descriptor.setField("setMethod", getSetMethod());\r
-            else\r
-                descriptor.setField("setMethod",\r
-                                    getMethodName(getName(), false, false));\r
-        }\r
-        addFields(descriptor);\r
-        info.setDescriptor(descriptor);\r
-        return (info);\r
-\r
-    }\r
-\r
-\r
-    /**\r
-     * Return a string representation of this attribute descriptor.\r
-     */\r
-    public String toString() {\r
-\r
-        StringBuffer sb = new StringBuffer("AttributeInfo[");\r
-        sb.append("name=");\r
-        sb.append(name);\r
-        sb.append(", description=");\r
-        sb.append(description);\r
-        if (!readable) {\r
-            sb.append(", readable=");\r
-            sb.append(readable);\r
-        }\r
-        sb.append(", type=");\r
-        sb.append(type);\r
-        if (!writeable) {\r
-            sb.append(", writeable=");\r
-            sb.append(writeable);\r
-        }\r
-        sb.append("]");\r
-        return (sb.toString());\r
-\r
+        return (MBeanAttributeInfo)info;\r
     }\r
 \r
-\r
     // -------------------------------------------------------- Private Methods\r
 \r
 \r
index f633beb..28b8c9c 100644 (file)
@@ -20,15 +20,12 @@ package org.apache.tomcat.util.modeler;
 \r
 import java.lang.reflect.InvocationTargetException;\r
 import java.lang.reflect.Method;\r
-import java.util.HashMap;\r
-import java.util.Hashtable;\r
 import java.util.Iterator;\r
 \r
 import javax.management.Attribute;\r
 import javax.management.AttributeChangeNotification;\r
 import javax.management.AttributeList;\r
 import javax.management.AttributeNotFoundException;\r
-import javax.management.Descriptor;\r
 import javax.management.DynamicMBean;\r
 import javax.management.InstanceNotFoundException;\r
 import javax.management.InvalidAttributeValueException;\r
@@ -45,30 +42,40 @@ import javax.management.ObjectName;
 import javax.management.ReflectionException;\r
 import javax.management.RuntimeErrorException;\r
 import javax.management.RuntimeOperationsException;\r
-import javax.management.ServiceNotFoundException;\r
-import javax.management.modelmbean.DescriptorSupport;\r
 import javax.management.modelmbean.InvalidTargetObjectTypeException;\r
-import javax.management.modelmbean.ModelMBean;\r
-import javax.management.modelmbean.ModelMBeanAttributeInfo;\r
-import javax.management.modelmbean.ModelMBeanInfo;\r
-import javax.management.modelmbean.ModelMBeanInfoSupport;\r
-import javax.management.modelmbean.ModelMBeanNotificationInfo;\r
-import javax.management.modelmbean.ModelMBeanOperationInfo;\r
+import javax.management.modelmbean.ModelMBeanNotificationBroadcaster;\r
 \r
 import org.apache.commons.logging.Log;\r
 import org.apache.commons.logging.LogFactory;\r
-import org.apache.tomcat.util.modeler.modules.ModelerSource;\r
 \r
-// TODO: enable ant-like substitutions ? ( or at least discuss it )\r
+/*\r
+ * Changes from commons.modeler:\r
+ * \r
+ *  - use DynamicMBean\r
+ *  - remove methods not used in tomcat and redundant/not very generic\r
+ *  - must be created from the ManagedBean - I don't think there were any direct\r
+ *    uses, but now it is required.\r
+ *  - some of the gratuituous flexibility removed - instead this is more predictive and\r
+ *    strict with the use cases.\r
+ *  - all Method and metadata is stored in ManagedBean. BaseModelBMean and ManagedBean act\r
+ *    like Object and Class. \r
+ *  - setModelMBean is no longer called on resources ( not used in tomcat )\r
+ *  - no caching of Methods for now - operations and setters are not called repeatedly in most \r
+ *  management use cases. Getters should't be called very frequently either - and even if they\r
+ *  are, the overhead of getting the method should be small compared with other JMX costs ( RMI, etc ).\r
+ *  We can add getter cache if needed.\r
+ *  - removed unused constructor, fields\r
+ *  \r
+ *  TODO:\r
+ *   - clean up catalina.mbeans, stop using weird inheritance\r
+ */\r
 \r
 /**\r
- * <p>Basic implementation of the <code>ModelMBean</code> interface, which\r
+ * <p>Basic implementation of the <code>DynamicMBean</code> interface, which\r
  * supports the minimal requirements of the interface contract.</p>\r
  *\r
  * <p>This can be used directly to wrap an existing java bean, or inside\r
- * an mlet or anywhere an MBean would be used. The String parameter\r
- * passed to the constructor will be used to construct an instance of the\r
- * real object that we wrap.\r
+ * an mlet or anywhere an MBean would be used. \r
  *\r
  * Limitations:\r
  * <ul>\r
@@ -76,7 +83,6 @@ import org.apache.tomcat.util.modeler.modules.ModelerSource;
  *     supportd.</li>\r
  * <li>Caching of attribute values and operation results is not supported.\r
  *     All calls to <code>invoke()</code> are immediately executed.</li>\r
- * <li>Logging (under control of descriptors) is not supported.</li>\r
  * <li>Persistence of MBean attributes and operations is not supported.</li>\r
  * <li>All classes referenced as attribute types, operation parameters, or\r
  *     operation return values must be one of the following:\r
@@ -92,10 +98,8 @@ import org.apache.tomcat.util.modeler.modules.ModelerSource;
  *\r
  * @author Craig R. McClanahan\r
  * @author Costin Manolache\r
- * @version $Revision: 383269 $ $Date: 2006-03-05 03:22:41 +0100 (dim., 05 mars 2006) $\r
  */\r
-\r
-public class BaseModelMBean implements ModelMBean, MBeanRegistration {\r
+public class BaseModelMBean implements DynamicMBean, MBeanRegistration, ModelMBeanNotificationBroadcaster {\r
     private static Log log = LogFactory.getLog(BaseModelMBean.class);\r
 \r
     // ----------------------------------------------------------- Constructors\r
@@ -109,119 +113,42 @@ public class BaseModelMBean implements ModelMBean, MBeanRegistration {
      * @exception RuntimeOperationsException if an IllegalArgumentException\r
      *  occurs\r
      */\r
-    public BaseModelMBean() throws MBeanException, RuntimeOperationsException {\r
-\r
-        super();\r
-        if( log.isDebugEnabled()) log.debug("default constructor");\r
-        setModelMBeanInfo(createDefaultModelMBeanInfo());\r
-    }\r
-\r
-\r
-    /**\r
-     * Construct a <code>ModelMBean</code> associated with the specified\r
-     * <code>ModelMBeanInfo</code> information.\r
-     *\r
-     * @param info ModelMBeanInfo for this MBean\r
-     *\r
-     * @exception MBeanException if the initializer of an object\r
-     *  throws an exception\r
-     * @exception RuntimeOperationsException if an IllegalArgumentException\r
-     *  occurs\r
-     */\r
-    public BaseModelMBean(ModelMBeanInfo info)\r
-        throws MBeanException, RuntimeOperationsException {\r
-        // XXX should be deprecated - just call setInfo\r
+    protected BaseModelMBean() throws MBeanException, RuntimeOperationsException {\r
         super();\r
-        setModelMBeanInfo(info);\r
-        if( log.isDebugEnabled()) log.debug("ModelMBeanInfo constructor");\r
-    }\r
-\r
-    /** Construct a ModelMBean of a specified type.\r
-     *  The type can be a class name or the key used in one of the descriptors.\r
-     *\r
-     * If no descriptor is available, we'll first try to locate one in\r
-     * the same package with the class, then use introspection.\r
-     *\r
-     * The mbean resource will be created.\r
-     *\r
-     * @param type Class name or the type key used in the descriptor.\r
-     * @throws MBeanException\r
-     * @throws RuntimeOperationsException\r
-     */\r
-    public BaseModelMBean( String type )\r
-        throws MBeanException, RuntimeOperationsException\r
-    {\r
-        try {\r
-            // This constructor is used from <mlet>, it should create\r
-            // the resource\r
-            setModeledType(type);\r
-        } catch( Throwable ex ) {\r
-            log.error( "Error creating mbean ", ex);\r
-        }\r
-    }\r
-\r
-    public BaseModelMBean( String type, ModelerSource source )\r
-        throws MBeanException, RuntimeOperationsException\r
-    {\r
-        try {\r
-            setModeledType(type);\r
-        } catch( Throwable ex ) {\r
-            log.error( "Error creating mbean ", ex);\r
-        }\r
-        this.source=source;\r
     }\r
 \r
     // ----------------------------------------------------- Instance Variables\r
 \r
+    protected ObjectName oname=null;\r
 \r
     /**\r
      * Notification broadcaster for attribute changes.\r
      */\r
     protected BaseNotificationBroadcaster attributeBroadcaster = null;\r
 \r
-    /** Registry we are associated with\r
-     */\r
-    protected Registry registry=null;\r
-\r
     /**\r
      * Notification broadcaster for general notifications.\r
      */\r
     protected BaseNotificationBroadcaster generalBroadcaster = null;\r
-\r
-    protected ObjectName oname=null;\r
-\r
-    /**\r
-     * The <code>ModelMBeanInfo</code> object that controls our activity.\r
+    \r
+    /** Metadata for the mbean instance.\r
      */\r
-    protected ModelMBeanInfo info = null;\r
-\r
+    protected ManagedBean managedBean = null;\r
 \r
     /**\r
      * The managed resource this MBean is associated with (if any).\r
      */\r
     protected Object resource = null;\r
-    protected String resourceType = null;\r
-\r
-    /** Source object used to read this mbean. Can be used to\r
-     * persist the mbean\r
-     */\r
-    protected ModelerSource source=null;\r
-\r
-    /** Attribute values. XXX That can be stored in the value Field\r
-     */\r
-    protected HashMap attributes=new HashMap();\r
 \r
     // --------------------------------------------------- DynamicMBean Methods\r
+    // TODO: move to ManagedBean\r
     static final Object[] NO_ARGS_PARAM=new Object[0];\r
     static final Class[] NO_ARGS_PARAM_SIG=new Class[0];\r
-    // key: attribute val: getter method\r
-    private Hashtable getAttMap=new Hashtable();\r
-\r
-    // key: attribute val: setter method\r
-    private Hashtable setAttMap=new Hashtable();\r
+    \r
+    protected String resourceType = null;\r
 \r
     // key: operation val: invoke method\r
-    private Hashtable invokeAttMap=new Hashtable();\r
+    //private Hashtable invokeAttMap=new Hashtable();\r
 \r
     /**\r
      * Obtain and return the value of a specific attribute of this MBean.\r
@@ -249,45 +176,7 @@ public class BaseModelMBean implements ModelMBean, MBeanRegistration {
             return ((DynamicMBean)resource).getAttribute(name);\r
         }\r
         \r
-        // Extract the method from cache\r
-        Method m=(Method)getAttMap.get( name );\r
-\r
-        if( m==null ) {\r
-            // Look up the actual operation to be used\r
-            ModelMBeanAttributeInfo attrInfo = info.getAttribute(name);\r
-            if (attrInfo == null)\r
-                throw new AttributeNotFoundException(" Cannot find attribute " + name);\r
-            Descriptor attrDesc = attrInfo.getDescriptor();\r
-            if (attrDesc == null)\r
-                throw new AttributeNotFoundException("Cannot find attribute " + name + " descriptor");\r
-            String getMethod = (String) attrDesc.getFieldValue("getMethod");\r
-\r
-            if (getMethod == null)\r
-                throw new AttributeNotFoundException("Cannot find attribute " + name + " get method name");\r
-\r
-            Object object = null;\r
-            NoSuchMethodException exception = null;\r
-            try {\r
-                object = this;\r
-                m = object.getClass().getMethod(getMethod, NO_ARGS_PARAM_SIG);\r
-            } catch (NoSuchMethodException e) {\r
-                exception = e;;\r
-            }\r
-            if( m== null && resource != null ) {\r
-                try {\r
-                    object = resource;\r
-                    m = object.getClass().getMethod(getMethod, NO_ARGS_PARAM_SIG);\r
-                    exception=null;\r
-                } catch (NoSuchMethodException e) {\r
-                    exception = e;\r
-                }\r
-            }\r
-            if( exception != null )\r
-                throw new ReflectionException(exception,\r
-                                              "Cannot find getter method " + getMethod);\r
-            getAttMap.put( name, m );\r
-        }\r
-\r
+        Method m=managedBean.getGetter(name, this, resource);\r
         Object result = null;\r
         try {\r
             Class declaring=m.getDeclaringClass();\r
@@ -349,14 +238,15 @@ public class BaseModelMBean implements ModelMBean, MBeanRegistration {
 \r
     }\r
 \r
+    public void setManagedBean(ManagedBean managedBean) {\r
+        this.managedBean = managedBean;\r
+    }\r
 \r
     /**\r
      * Return the <code>MBeanInfo</code> object for this MBean.\r
      */\r
     public MBeanInfo getMBeanInfo() {\r
-        // XXX Why do we have to clone ?\r
-        if( info== null ) return null;\r
-        return ((MBeanInfo) info.clone());\r
+        return managedBean.getMBeanInfo();\r
     }\r
 \r
 \r
@@ -395,59 +285,8 @@ public class BaseModelMBean implements ModelMBean, MBeanRegistration {
 \r
         if( log.isDebugEnabled()) log.debug("Invoke " + name);\r
        MethodKey mkey = new MethodKey(name, signature);\r
-        Method method=(Method)invokeAttMap.get(mkey);\r
-        if( method==null ) {\r
-            if (params == null)\r
-                params = new Object[0];\r
-            if (signature == null)\r
-                signature = new String[0];\r
-            if (params.length != signature.length)\r
-                throw new RuntimeOperationsException\r
-                    (new IllegalArgumentException("Inconsistent arguments and signature"),\r
-                     "Inconsistent arguments and signature");\r
-\r
-            // Acquire the ModelMBeanOperationInfo information for\r
-            // the requested operation\r
-            ModelMBeanOperationInfo opInfo = info.getOperation(name);\r
-            if (opInfo == null)\r
-                throw new MBeanException\r
-                    (new ServiceNotFoundException("Cannot find operation " + name),\r
-                     "Cannot find operation " + name);\r
-\r
-            // Prepare the signature required by Java reflection APIs\r
-            // FIXME - should we use the signature from opInfo?\r
-            Class types[] = new Class[signature.length];\r
-            for (int i = 0; i < signature.length; i++) {\r
-                types[i]=getAttributeClass( signature[i] );\r
-            }\r
-\r
-            // Locate the method to be invoked, either in this MBean itself\r
-            // or in the corresponding managed resource\r
-            // FIXME - Accessible methods in superinterfaces?\r
-            Object object = null;\r
-            Exception exception = null;\r
-            try {\r
-                object = this;\r
-                method = object.getClass().getMethod(name, types);\r
-            } catch (NoSuchMethodException e) {\r
-                exception = e;;\r
-            }\r
-            try {\r
-                if ((method == null) && (resource != null)) {\r
-                    object = resource;\r
-                    method = object.getClass().getMethod(name, types);\r
-                }\r
-            } catch (NoSuchMethodException e) {\r
-                exception = e;\r
-            }\r
-            if (method == null) {\r
-                throw new ReflectionException(exception,\r
-                                              "Cannot find method " + name +\r
-                                              " with this signature");\r
-            }\r
-            invokeAttMap.put( mkey, method );\r
-        }\r
-\r
+        Method method= managedBean.getInvoke(name, params, signature, this, resource);\r
+        \r
         // Invoke the selected method on the appropriate object\r
         Object result = null;\r
         try {\r
@@ -482,7 +321,7 @@ public class BaseModelMBean implements ModelMBean, MBeanRegistration {
 \r
     }\r
 \r
-    private Class getAttributeClass(String signature)\r
+    static Class getAttributeClass(String signature)\r
         throws ReflectionException\r
     {\r
         if (signature.equals(Boolean.TYPE.getName()))\r
@@ -561,64 +400,17 @@ public class BaseModelMBean implements ModelMBean, MBeanRegistration {
                 (new IllegalArgumentException("Attribute name is null"),\r
                  "Attribute name is null");\r
 \r
-        ModelMBeanAttributeInfo attrInfo=info.getAttribute(name);\r
-        if (attrInfo == null)\r
-            throw new AttributeNotFoundException("Cannot find attribute " + name);\r
-\r
-        Descriptor attrDesc=attrInfo.getDescriptor();\r
-        if (attrDesc == null)\r
-            throw new AttributeNotFoundException("Cannot find attribute " + name + " descriptor");\r
-\r
         Object oldValue=null;\r
-        if( getAttMap.get(name) != null )\r
-            oldValue=getAttribute( name );\r
-\r
-\r
-        // Extract the method from cache\r
-        Method m=(Method)setAttMap.get( name );\r
+        //if( getAttMap.get(name) != null )\r
+        //    oldValue=getAttribute( name );\r
 \r
-        if( m==null ) {\r
-            // Look up the actual operation to be used\r
-            String setMethod = (String) attrDesc.getFieldValue("setMethod");\r
-            if (setMethod == null)\r
-                throw new AttributeNotFoundException("Cannot find attribute " + name + " set method name");\r
+        Method m=managedBean.getSetter(name,this,resource);\r
 \r
-            String argType=attrInfo.getType();\r
-\r
-            Class signature[] = new Class[] { getAttributeClass( argType ) };\r
-\r
-            Object object = null;\r
-            NoSuchMethodException exception = null;\r
-            try {\r
-                object = this;\r
-                m = object.getClass().getMethod(setMethod, signature);\r
-            } catch (NoSuchMethodException e) {\r
-                exception = e;;\r
-            }\r
-            if( m== null && resource != null ) {\r
-                try {\r
-                    object = resource;\r
-                    m = object.getClass().getMethod(setMethod, signature);\r
-                    exception=null;\r
-                } catch (NoSuchMethodException e) {\r
-                    if( log.isDebugEnabled())\r
-                        log.debug("Method not found in resource " +resource);\r
-                    exception = e;\r
-                }\r
-            }\r
-            if( exception != null )\r
-                throw new ReflectionException(exception,\r
-                                              "Cannot find setter method " + setMethod +\r
-                        " " + resource);\r
-            setAttMap.put( name, m );\r
-        }\r
-\r
-        Object result = null;\r
         try {\r
             if( m.getDeclaringClass().isAssignableFrom( this.getClass()) ) {\r
-                result = m.invoke(this, new Object[] { value });\r
+                m.invoke(this, new Object[] { value });\r
             } else {\r
-                result = m.invoke(resource, new Object[] { value });\r
+                m.invoke(resource, new Object[] { value });\r
             }\r
         } catch (InvocationTargetException e) {\r
             Throwable t = e.getTargetException();\r
@@ -644,11 +436,11 @@ public class BaseModelMBean implements ModelMBean, MBeanRegistration {
         } catch(Exception ex) {\r
             log.error("Error sending notification " + name, ex);\r
         }\r
-        attributes.put( name, value );\r
-        if( source != null ) {\r
-            // this mbean is asscoiated with a source - maybe we want to persist\r
-            source.updateField(oname, name, value);\r
-        }\r
+        //attributes.put( name, value );\r
+//        if( source != null ) {\r
+//            // this mbean is asscoiated with a source - maybe we want to persist\r
+//            source.updateField(oname, name, value);\r
+//        }\r
     }\r
 \r
     public String toString() {\r
@@ -665,15 +457,13 @@ public class BaseModelMBean implements ModelMBean, MBeanRegistration {
      * @return The list of attributes that were set and their new values\r
      */\r
     public AttributeList setAttributes(AttributeList attributes) {\r
+        AttributeList response = new AttributeList();\r
 \r
         // Validate the input parameters\r
         if (attributes == null)\r
-            throw new RuntimeOperationsException\r
-                (new IllegalArgumentException("Attributes list is null"),\r
-                 "Attributes list is null");\r
-\r
+            return response;\r
+        \r
         // Prepare and return our response, eating all exceptions\r
-        AttributeList response = new AttributeList();\r
         String names[] = new String[attributes.size()];\r
         int n = 0;\r
         Iterator items = attributes.iterator();\r
@@ -724,10 +514,12 @@ public class BaseModelMBean implements ModelMBean, MBeanRegistration {
      * Set the instance handle of the object against which we will execute\r
      * all methods in this ModelMBean management interface.\r
      *\r
-     * This method will detect and call "setModelMbean" method. A resource\r
+     * <strike>This method will detect and call "setModelMbean" method. A resource\r
      * can implement this method to get a reference to the model mbean.\r
      * The reference can be used to send notification and access the\r
      * registry.\r
+     * </strike> The caller can provide the mbean instance or the object name to\r
+     * the resource, if needed.\r
      *\r
      * @param resource The resource object to be managed\r
      * @param type The type of reference for the managed resource\r
@@ -744,7 +536,7 @@ public class BaseModelMBean implements ModelMBean, MBeanRegistration {
      *  resource type is <code>null</code> or invalid\r
      */\r
     public void setManagedResource(Object resource, String type)\r
-        throws InstanceNotFoundException, InvalidTargetObjectTypeException,\r
+        throws InstanceNotFoundException, \r
         MBeanException, RuntimeOperationsException\r
     {\r
         if (resource == null)\r
@@ -752,58 +544,24 @@ public class BaseModelMBean implements ModelMBean, MBeanRegistration {
                 (new IllegalArgumentException("Managed resource is null"),\r
                  "Managed resource is null");\r
 \r
-        if (!"objectreference".equalsIgnoreCase(type))\r
-            throw new InvalidTargetObjectTypeException(type);\r
+//        if (!"objectreference".equalsIgnoreCase(type))\r
+//            throw new InvalidTargetObjectTypeException(type);\r
 \r
         this.resource = resource;\r
         this.resourceType = resource.getClass().getName();\r
         \r
-        // Make the resource aware of the model mbean.\r
-        try {\r
-            Method m=resource.getClass().getMethod("setModelMBean",\r
-                    new Class[] {ModelMBean.class});\r
-            if( m!= null ) {\r
-                m.invoke(resource, new Object[] {this});\r
-            }\r
-        } catch( NoSuchMethodException t ) {\r
-            // ignore\r
-        } catch( Throwable t ) {\r
-            log.error( "Can't set model mbean ", t );\r
-        }\r
-    }\r
-\r
-\r
-    /**\r
-     * Initialize the <code>ModelMBeanInfo</code> associated with this\r
-     * <code>ModelMBean</code>.  After the information and associated\r
-     * descriptors have been customized, the <code>ModelMBean</code> should\r
-     * be registered with the associated <code>MBeanServer</code>.\r
-     *\r
-     * Currently the model can be set after registration. This behavior is\r
-     * deprecated and won't be supported in future versions.\r
-     *\r
-     * @param info The ModelMBeanInfo object to be used by this ModelMBean\r
-     *\r
-     * @exception MBeanException If an exception occurs recording this\r
-     *  ModelMBeanInfo information\r
-     * @exception RuntimeOperations if the specified parameter is\r
-     *  <code>null</code> or invalid\r
-     */\r
-    public void setModelMBeanInfo(ModelMBeanInfo info)\r
-        throws MBeanException, RuntimeOperationsException {\r
-\r
-        if (info == null)\r
-            throw new RuntimeOperationsException\r
-                (new IllegalArgumentException("ModelMBeanInfo is null"),\r
-                 "ModelMBeanInfo is null");\r
-\r
-        if (!isModelMBeanInfoValid(info))\r
-            throw new RuntimeOperationsException\r
-                (new IllegalArgumentException("ModelMBeanInfo is invalid"),\r
-                 "ModelMBeanInfo is invalid");\r
-\r
-        this.info = (ModelMBeanInfo) info.clone();\r
-\r
+//        // Make the resource aware of the model mbean.\r
+//        try {\r
+//            Method m=resource.getClass().getMethod("setModelMBean",\r
+//                    new Class[] {ModelMBean.class});\r
+//            if( m!= null ) {\r
+//                m.invoke(resource, new Object[] {this});\r
+//            }\r
+//        } catch( NoSuchMethodException t ) {\r
+//            // ignore\r
+//        } catch( Throwable t ) {\r
+//            log.error( "Can't set model mbean ", t );\r
+//        }\r
     }\r
 \r
 \r
@@ -1058,38 +816,38 @@ public class BaseModelMBean implements ModelMBean, MBeanRegistration {
     public MBeanNotificationInfo[] getNotificationInfo() {\r
 \r
         // Acquire the set of application notifications\r
-        MBeanNotificationInfo current[] = info.getNotifications();\r
+        MBeanNotificationInfo current[] = getMBeanInfo().getNotifications();\r
         if (current == null)\r
             current = new MBeanNotificationInfo[0];\r
         MBeanNotificationInfo response[] =\r
             new MBeanNotificationInfo[current.length + 2];\r
-        Descriptor descriptor = null;\r
//       Descriptor descriptor = null;\r
 \r
         // Fill in entry for general notifications\r
-        descriptor = new DescriptorSupport\r
-            (new String[] { "name=GENERIC",\r
-                            "descriptorType=notification",\r
-                            "log=T",\r
-                            "severity=5",\r
-                            "displayName=jmx.modelmbean.generic" });\r
-        response[0] = new ModelMBeanNotificationInfo\r
+//        descriptor = new DescriptorSupport\r
+//            (new String[] { "name=GENERIC",\r
+//                            "descriptorType=notification",\r
+//                            "log=T",\r
+//                            "severity=5",\r
+//                            "displayName=jmx.modelmbean.generic" });\r
+        response[0] = new MBeanNotificationInfo\r
             (new String[] { "jmx.modelmbean.generic" },\r
              "GENERIC",\r
-             "Text message notification from the managed resource",\r
-             descriptor);\r
+             "Text message notification from the managed resource");\r
+             //descriptor);\r
 \r
         // Fill in entry for attribute change notifications\r
-        descriptor = new DescriptorSupport\r
-            (new String[] { "name=ATTRIBUTE_CHANGE",\r
-                            "descriptorType=notification",\r
-                            "log=T",\r
-                            "severity=5",\r
-                            "displayName=jmx.attribute.change" });\r
-        response[1] = new ModelMBeanNotificationInfo\r
+//        descriptor = new DescriptorSupport\r
+//            (new String[] { "name=ATTRIBUTE_CHANGE",\r
+//                            "descriptorType=notification",\r
+//                            "log=T",\r
+//                            "severity=5",\r
+//                            "displayName=jmx.attribute.change" });\r
+        response[1] = new MBeanNotificationInfo\r
             (new String[] { "jmx.attribute.change" },\r
              "ATTRIBUTE_CHANGE",\r
-             "Observed MBean attribute value has changed",\r
-             descriptor);\r
+             "Observed MBean attribute value has changed");\r
+             //descriptor);\r
 \r
         // Copy remaining notifications as reported by the application\r
         System.arraycopy(current, 0, response, 2, current.length);\r
@@ -1183,14 +941,14 @@ public class BaseModelMBean implements ModelMBean, MBeanRegistration {
      * @exception RuntimeOperationsException if an exception is reported\r
      *  by the persistence mechanism\r
      */\r
-    public void load() throws InstanceNotFoundException,\r
-        MBeanException, RuntimeOperationsException {\r
-        // XXX If a context was set, use it to load the data\r
-        throw new MBeanException\r
-            (new IllegalStateException("Persistence is not supported"),\r
-             "Persistence is not supported");\r
-\r
-    }\r
+//    public void load() throws InstanceNotFoundException,\r
+//        MBeanException, RuntimeOperationsException {\r
+//        // XXX If a context was set, use it to load the data\r
+//        throw new MBeanException\r
+//            (new IllegalStateException("Persistence is not supported"),\r
+//             "Persistence is not supported");\r
+//\r
+//    }\r
 \r
 \r
     /**\r
@@ -1209,15 +967,15 @@ public class BaseModelMBean implements ModelMBean, MBeanRegistration {
      * @exception RuntimeOperationsException if an exception is reported\r
      *  by the persistence mechanism\r
      */\r
-    public void store() throws InstanceNotFoundException,\r
-        MBeanException, RuntimeOperationsException {\r
-\r
-        // XXX if a context was set, use it to store the data\r
-        throw new MBeanException\r
-            (new IllegalStateException("Persistence is not supported"),\r
-             "Persistence is not supported");\r
-\r
-    }\r
+//    public void store() throws InstanceNotFoundException,\r
+//        MBeanException, RuntimeOperationsException {\r
+//\r
+//        // XXX if a context was set, use it to store the data\r
+//        throw new MBeanException\r
+//            (new IllegalStateException("Persistence is not supported"),\r
+//             "Persistence is not supported");\r
+//\r
+//    }\r
 \r
     // --------------------  BaseModelMBean methods --------------------\r
 \r
@@ -1226,62 +984,62 @@ public class BaseModelMBean implements ModelMBean, MBeanRegistration {
      *\r
      * @param type the type of classname of the modeled object\r
      */\r
-    public void setModeledType( String type ) {\r
-        initModelInfo(type);\r
-        createResource();\r
-    }\r
+//    void setModeledType( String type ) {\r
+//        initModelInfo(type);\r
+//        createResource();\r
+//    }\r
     /** Set the type of the mbean. This is used as a key to locate\r
      * the description in the Registry.\r
      *\r
      * @param type the type of classname of the modeled object\r
      */\r
-    protected void initModelInfo( String type ) {\r
-        try {\r
-            if( log.isDebugEnabled())\r
-                log.debug("setModeledType " + type);\r
-\r
-            log.debug( "Set model Info " + type);\r
-            if(type==null) {\r
-                return;\r
-            }\r
-            resourceType=type;\r
-            //Thread.currentThread().setContextClassLoader(BaseModelMBean.class.getClassLoader());\r
-            Class c=null;\r
-            try {\r
-                c=Class.forName( type);\r
-            } catch( Throwable t ) {\r
-                log.debug( "Error creating class " + t);\r
-            }\r
-\r
-            // The class c doesn't need to exist\r
-            ManagedBean descriptor=getRegistry().findManagedBean(c, type);\r
-            if( descriptor==null ) \r
-                return;\r
-            this.setModelMBeanInfo(descriptor.createMBeanInfo());\r
-        } catch( Throwable ex) {\r
-            log.error( "TCL: " + Thread.currentThread().getContextClassLoader(),\r
-                    ex);\r
-        }\r
-    }\r
+//    void initModelInfo( String type ) {\r
+//        try {\r
+//            if( log.isDebugEnabled())\r
+//                log.debug("setModeledType " + type);\r
+//\r
+//            log.debug( "Set model Info " + type);\r
+//            if(type==null) {\r
+//                return;\r
+//            }\r
+//            resourceType=type;\r
+//            //Thread.currentThread().setContextClassLoader(BaseModelMBean.class.getClassLoader());\r
+//            Class c=null;\r
+//            try {\r
+//                c=Class.forName( type);\r
+//            } catch( Throwable t ) {\r
+//                log.debug( "Error creating class " + t);\r
+//            }\r
+//\r
+//            // The class c doesn't need to exist\r
+//            ManagedBean descriptor=getRegistry().findManagedBean(c, type);\r
+//            if( descriptor==null ) \r
+//                return;\r
+//            this.setModelMBeanInfo(descriptor.createMBeanInfo());\r
+//        } catch( Throwable ex) {\r
+//            log.error( "TCL: " + Thread.currentThread().getContextClassLoader(),\r
+//                    ex);\r
+//        }\r
+//    }\r
 \r
     /** Set the type of the mbean. This is used as a key to locate\r
      * the description in the Registry.\r
      */\r
-    protected void createResource() {\r
-        try {\r
-            //Thread.currentThread().setContextClassLoader(BaseModelMBean.class.getClassLoader());\r
-            Class c=null;\r
-            try {\r
-                c=Class.forName( resourceType );\r
-                resource = c.newInstance();\r
-            } catch( Throwable t ) {\r
-                log.error( "Error creating class " + t);\r
-            }\r
-        } catch( Throwable ex) {\r
-            log.error( "TCL: " + Thread.currentThread().getContextClassLoader(),\r
-                    ex);\r
-        }\r
-    }\r
+//    protected void createResource() {\r
+//        try {\r
+//            //Thread.currentThread().setContextClassLoader(BaseModelMBean.class.getClassLoader());\r
+//            Class c=null;\r
+//            try {\r
+//                c=Class.forName( resourceType );\r
+//                resource = c.newInstance();\r
+//            } catch( Throwable t ) {\r
+//                log.error( "Error creating class " + t);\r
+//            }\r
+//        } catch( Throwable ex) {\r
+//            log.error( "TCL: " + Thread.currentThread().getContextClassLoader(),\r
+//                    ex);\r
+//        }\r
+//    }\r
 \r
 \r
     public String getModelerType() {\r
@@ -1304,17 +1062,17 @@ public class BaseModelMBean implements ModelMBean, MBeanRegistration {
         }\r
     }\r
 \r
-    public void setRegistry(Registry registry) {\r
-        this.registry = registry;\r
-    }\r
-\r
-    public Registry getRegistry() {\r
-        // XXX Need a better solution - to avoid the static\r
-        if( registry == null )\r
-            registry=Registry.getRegistry();\r
-\r
-        return registry;\r
-    }\r
+//    public void setRegistry(Registry registry) {\r
+//        this.registry = registry;\r
+//    }\r
+//\r
+//    public Registry getRegistry() {\r
+//        // XXX Need a better solution - to avoid the static\r
+//        if( registry == null )\r
+//            registry=Registry.getRegistry();\r
+//\r
+//        return registry;\r
+//    }\r
 \r
     // ------------------------------------------------------ Protected Methods\r
 \r
@@ -1322,13 +1080,13 @@ public class BaseModelMBean implements ModelMBean, MBeanRegistration {
     /**\r
      * Create and return a default <code>ModelMBeanInfo</code> object.\r
      */\r
-    protected ModelMBeanInfo createDefaultModelMBeanInfo() {\r
-\r
-        return (new ModelMBeanInfoSupport(this.getClass().getName(),\r
-                                          "Default ModelMBean",\r
-                                          null, null, null, null));\r
-\r
-    }\r
+//    protected ModelMBeanInfo createDefaultModelMBeanInfo() {\r
+//\r
+//        return (new ModelMBeanInfoSupport(this.getClass().getName(),\r
+//                                          "Default ModelMBean",\r
+//                                          null, null, null, null));\r
+//\r
+//    }\r
 \r
     /**\r
      * Is the specified <code>ModelMBeanInfo</code> instance valid?\r
@@ -1339,9 +1097,9 @@ public class BaseModelMBean implements ModelMBean, MBeanRegistration {
      *\r
      * @param info The <code>ModelMBeanInfo object to check\r
      */\r
-    protected boolean isModelMBeanInfoValid(ModelMBeanInfo info) {\r
-        return (true);\r
-    }\r
+//    protected boolean isModelMBeanInfoValid(ModelMBeanInfo info) {\r
+//        return (true);\r
+//    }\r
 \r
     // -------------------- Registration  --------------------\r
     // XXX We can add some method patterns here- like setName() and\r
diff --git a/java/org/apache/tomcat/util/modeler/BaseNotification.java b/java/org/apache/tomcat/util/modeler/BaseNotification.java
deleted file mode 100644 (file)
index d6a5e27..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-/*\r
- * Copyright 1999,2004 The Apache Software Foundation.\r
- * \r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- *      http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */ \r
-package org.apache.tomcat.util.modeler;\r
-\r
-import javax.management.Notification;\r
-\r
-\r
-/**\r
- * Base JMX Notification. Supports in int code and notes - for faster \r
- * access and dispatching. \r
- *\r
- * @author Costin Manolache\r
- */\r
-public final class BaseNotification extends Notification {\r
-\r
-    // ----------------------------------------------------------- Constructors\r
-    private int code;\r
-    private String type;\r
-    private Object source;\r
-    private long seq;\r
-    private long tstamp;\r
-\r
-    /**\r
-     * Private constructor.\r
-     */\r
-    private BaseNotification(String type,\r
-                             Object source,\r
-                             long seq,\r
-                             long tstamp,\r
-                             int code) {\r
-        super(type, source, seq, tstamp);\r
-        init( type, source, seq, tstamp, code );\r
-        this.code=code;\r
-    }\r
-\r
-    public void recycle() {\r
-\r
-    }\r
-\r
-    public void init( String type, Object source,\r
-                      long seq, long tstamp, int code )\r
-    {\r
-        this.type=type;\r
-        this.source = source;\r
-        this.seq=seq;\r
-        this.tstamp=tstamp;\r
-        this.code = code;\r
-    }\r
-\r
-    // -------------------- Override base methods  --------------------\r
-    // All base methods need to be overriden - in order to support recycling.\r
-\r
-\r
-    // -------------------- Information associated with the notification  ----\r
-    // Like events ( which Notification extends ), notifications may store\r
-    // informations related with the event that trigered it. Source and type is\r
-    // one piece, but it is common to store more info.\r
-\r
-    /** Action id, useable in switches and table indexes\r
-     */\r
-    public int getCode() {\r
-        return code;\r
-    }\r
-\r
-    // XXX Make it customizable - or grow it\r
-    private Object notes[]=new Object[32];\r
-\r
-    public final Object getNote(int i ) {\r
-        return notes[i];\r
-    }\r
-\r
-    public final void setNote(int i, Object o ) {\r
-        notes[i]=o;\r
-    }\r
-}\r
index 13d0104..d3af7b4 100644 (file)
@@ -20,9 +20,7 @@ package org.apache.tomcat.util.modeler;
 \r
 import java.io.Serializable;\r
 \r
-import javax.management.Descriptor;\r
-import javax.management.MBeanParameterInfo;\r
-import javax.management.modelmbean.ModelMBeanConstructorInfo;\r
+import javax.management.MBeanConstructorInfo;\r
 \r
 \r
 /**\r
@@ -30,135 +28,28 @@ import javax.management.modelmbean.ModelMBeanConstructorInfo;
  * descriptor.</p>\r
  *\r
  * @author Craig R. McClanahan\r
- * @version $Revision: 155428 $ $Date: 2005-02-26 14:12:25 +0100 (sam., 26 févr. 2005) $\r
  */\r
-\r
-public class ConstructorInfo extends FeatureInfo implements Serializable {\r
+public class ConstructorInfo extends OperationInfo implements Serializable {\r
     static final long serialVersionUID = -5735336213417238238L;\r
-\r
-    // ----------------------------------------------------- Instance Variables\r
-\r
-\r
-    /**\r
-     * The <code>ModelMBeanConstructorInfo</code> object that corresponds\r
-     * to this <code>ConstructorInfo</code> instance.\r
-     */\r
-    transient ModelMBeanConstructorInfo info = null;\r
-    protected String displayName = null;\r
-    protected ParameterInfo parameters[] = new ParameterInfo[0];\r
-\r
-\r
     // ------------------------------------------------------------- Properties\r
 \r
-\r
-    /**\r
-     * Override the <code>description</code> property setter.\r
-     *\r
-     * @param description The new description\r
-     */\r
-    public void setDescription(String description) {\r
-        super.setDescription(description);\r
-        this.info = null;\r
+    public ConstructorInfo() {\r
     }\r
 \r
-\r
-    /**\r
-     * Override the <code>name</code> property setter.\r
-     *\r
-     * @param name The new name\r
-     */\r
-    public void setName(String name) {\r
-        super.setName(name);\r
-        this.info = null;\r
-    }\r
-\r
-\r
-    /**\r
-     * The display name of this attribute.\r
-     */\r
-    public String getDisplayName() {\r
-        return (this.displayName);\r
-    }\r
-\r
-    public void setDisplayName(String displayName) {\r
-        this.displayName = displayName;\r
-    }\r
-\r
-\r
-    /**\r
-     * The set of parameters for this constructor.\r
-     */\r
-    public ParameterInfo[] getSignature() {\r
-        return (this.parameters);\r
-    }\r
-\r
-\r
     // --------------------------------------------------------- Public Methods\r
 \r
 \r
     /**\r
-     * Add a new parameter to the set of parameters for this constructor.\r
-     *\r
-     * @param parameter The new parameter descriptor\r
-     */\r
-    public void addParameter(ParameterInfo parameter) {\r
-\r
-        synchronized (parameters) {\r
-            ParameterInfo results[] = new ParameterInfo[parameters.length + 1];\r
-            System.arraycopy(parameters, 0, results, 0, parameters.length);\r
-            results[parameters.length] = parameter;\r
-            parameters = results;\r
-            this.info = null;\r
-        }\r
-\r
-    }\r
-\r
-\r
-    /**\r
      * Create and return a <code>ModelMBeanConstructorInfo</code> object that\r
      * corresponds to the attribute described by this instance.\r
      */\r
-    public ModelMBeanConstructorInfo createConstructorInfo() {\r
-\r
+    public MBeanConstructorInfo createConstructorInfo() {\r
         // Return our cached information (if any)\r
-        if (info != null)\r
-            return (info);\r
-\r
-        // Create and return a new information object\r
-        ParameterInfo params[] = getSignature();\r
-        MBeanParameterInfo parameters[] =\r
-            new MBeanParameterInfo[params.length];\r
-        for (int i = 0; i < params.length; i++)\r
-            parameters[i] = params[i].createParameterInfo();\r
-        info = new ModelMBeanConstructorInfo\r
-            (getName(), getDescription(), parameters);\r
-        Descriptor descriptor = info.getDescriptor();\r
-        descriptor.removeField("class");\r
-        if (getDisplayName() != null)\r
-            descriptor.setField("displayName", getDisplayName());\r
-        addFields(descriptor);\r
-        info.setDescriptor(descriptor);\r
-        return (info);\r
-\r
-    }\r
-\r
-\r
-    /**\r
-     * Return a string representation of this constructor descriptor.\r
-     */\r
-    public String toString() {\r
-\r
-        StringBuffer sb = new StringBuffer("ConstructorInfo[");\r
-        sb.append("name=");\r
-        sb.append(name);\r
-        sb.append(", description=");\r
-        sb.append(description);\r
-        sb.append(", parameters=");\r
-        sb.append(parameters.length);\r
-        sb.append("]");\r
-        return (sb.toString());\r
-\r
+        if (info == null) {\r
+            info = new MBeanConstructorInfo(getName(), getDescription(), \r
+                    getMBeanParameterInfo());\r
+        }\r
+        return (MBeanConstructorInfo)info;\r
     }\r
 \r
-\r
 }\r
index c23d96c..75e149c 100644 (file)
@@ -19,11 +19,8 @@ package org.apache.tomcat.util.modeler;
 \r
 \r
 import java.io.Serializable;\r
-import java.util.ArrayList;\r
-import java.util.Iterator;\r
-import java.util.List;\r
 \r
-import javax.management.Descriptor;\r
+import javax.management.MBeanFeatureInfo;\r
 \r
 \r
 /**\r
@@ -38,13 +35,17 @@ import javax.management.Descriptor;
 \r
 public class FeatureInfo implements Serializable {\r
     static final long serialVersionUID = -911529176124712296L;\r
+    \r
     protected String description = null;\r
-    protected List fields = new ArrayList();\r
     protected String name = null;\r
+    protected MBeanFeatureInfo info = null;\r
+    \r
+    // all have type except Constructor\r
+    protected String type = null;\r
 \r
+    \r
     // ------------------------------------------------------------- Properties\r
 \r
-\r
     /**\r
      * The human-readable description of this feature.\r
      */\r
@@ -58,14 +59,6 @@ public class FeatureInfo implements Serializable {
 \r
 \r
     /**\r
-     * The field information for this feature.\r
-     */\r
-    public List getFields() {\r
-        return (fields);\r
-    }\r
-\r
-\r
-    /**\r
      * The name of this feature, which must be unique among features in the\r
      * same collection.\r
      */\r
@@ -77,38 +70,15 @@ public class FeatureInfo implements Serializable {
         this.name = name;\r
     }\r
 \r
-\r
-    // --------------------------------------------------------- Public Methods\r
-\r
-\r
     /**\r
-     * <p>Add a new field to the fields associated with the\r
-     * Descriptor that will be created from this metadata.</p>\r
-     *\r
-     * @param field The field to be added\r
+     * The fully qualified Java class name of this element.\r
      */\r
-    public void addField(FieldInfo field) {\r
-        fields.add(field);\r
+    public String getType() {\r
+        return (this.type);\r
     }\r
 \r
-\r
-    // ------------------------------------------------------ Protected Methods\r
-\r
-\r
-    /**\r
-     * <p>Add the name/value fields that have been stored into the\r
-     * specified <code>Descriptor</code> instance.</p>\r
-     *\r
-     * @param descriptor The <code>Descriptor</code> to add fields to\r
-     */\r
-    protected void addFields(Descriptor descriptor) {\r
-\r
-        Iterator items = getFields().iterator();\r
-        while (items.hasNext()) {\r
-            FieldInfo item = (FieldInfo) items.next();\r
-            descriptor.setField(item.getName(), item.getValue());\r
-        }\r
-\r
+    public void setType(String type) {\r
+        this.type = type;\r
     }\r
 \r
 \r
diff --git a/java/org/apache/tomcat/util/modeler/FieldInfo.java b/java/org/apache/tomcat/util/modeler/FieldInfo.java
deleted file mode 100644 (file)
index ddc6a3c..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/*\r
- * Copyright 1999-2004 The Apache Software Foundation.\r
- * \r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- *      http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-\r
-package org.apache.tomcat.util.modeler;\r
-\r
-\r
-import java.io.Serializable;\r
-\r
-\r
-/**\r
- * <p>Simple JavaBean representing the contents of a <code>&lt;field&gt;</code>\r
- * element in an MBeans descriptor file.\r
- */\r
-\r
-public class FieldInfo implements Serializable {\r
-    static final long serialVersionUID = -8226401620640873691L;\r
-\r
-    /**\r
-     * <p>The field name for this field of a descriptor.</p>\r
-     */\r
-    protected String name = null;\r
-\r
-    public String getName() {\r
-        return (this.name);\r
-    }\r
-\r
-    public void setName(String name) {\r
-        this.name = name;\r
-    }\r
-\r
-\r
-    /**\r
-     * <p>The field value for this field of a descriptor.</p>\r
-     */\r
-    protected Object value = null;\r
-\r
-    public Object getValue() {\r
-        return (this.value);\r
-    }\r
-\r
-    public void setValue(Object value) {\r
-        this.value = value;\r
-    }\r
-\r
-\r
-}\r
diff --git a/java/org/apache/tomcat/util/modeler/JndiJmx.java b/java/org/apache/tomcat/util/modeler/JndiJmx.java
deleted file mode 100644 (file)
index 988b5e1..0000000
+++ /dev/null
@@ -1,227 +0,0 @@
-/*\r
- * Copyright 2001-2002,2004 The Apache Software Foundation.\r
- * \r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- *      http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-\r
-package org.apache.tomcat.util.modeler;\r
-\r
-\r
-import java.util.Enumeration;\r
-import java.util.Hashtable;\r
-\r
-import javax.management.AttributeChangeNotification;\r
-import javax.management.InstanceNotFoundException;\r
-import javax.management.MBeanException;\r
-import javax.management.MBeanServer;\r
-import javax.management.MBeanServerNotification;\r
-import javax.management.Notification;\r
-import javax.management.NotificationBroadcaster;\r
-import javax.management.NotificationListener;\r
-import javax.management.ObjectName;\r
-import javax.naming.Context;\r
-\r
-import org.apache.commons.logging.Log;\r
-import org.apache.commons.logging.LogFactory;\r
-\r
-// EXPERIMENTAL. It may fit better in tomcat jndi impl.\r
-\r
-\r
-/**\r
- *\r
- * Link between JNDI and JMX. JNDI can be used for persistence ( it is\r
- * an API for storing hierarchical data and a perfect fit for that ), as\r
- * well as an alternate view of the MBean registry.\r
- *\r
- * If this component is enabled, all MBeans will be registered in JNDI, and\r
- * all attributes that are set via JMX can be stored in a DirContext.\r
- *\r
- * This acts as a "recorder" for creation of mbeans and attribute changes\r
- * done via JMX.\r
- *\r
- * XXX How can we control ( filter ) which mbeans will be registere ? Or\r
- * attributes ?\r
- * XXX How can we get the beans and attributes loaded before jndijmx ?\r
- *\r
- * The intended use:\r
- * - do whatever you want to start the application\r
- * - load JndiJmx as an mbean\r
- * - make changes via JMX. All changes are recorded\r
- * - you can use JndiJmx to save the changes in a Jndi context.\r
- * - you can use JndiJmx to load changes from a JndiContext and replay them.\r
- *\r
- * The main benefit is that only changed attributes are saved, and the Jndi\r
- * layer can preserve most of the original structure of the config file. The\r
- * alternative is to override the config files with config info extracted\r
- * from the live objects - but it's very hard to save only what was actually\r
- * changed and preserve structure and comments.\r
- *\r
- * @author Costin Manolache\r
- */\r
-public class JndiJmx extends BaseModelMBean implements NotificationListener {\r
-\r
-\r
-    private static Log log= LogFactory.getLog(JndiJmx.class);\r
-\r
-    protected Context componentContext;\r
-    protected Context descriptorContext;\r
-    protected Context configContext;\r
-\r
-    MBeanServer mserver;\r
-\r
-    /**\r
-     * Protected constructor to require use of the factory create method.\r
-     */\r
-    public JndiJmx() throws MBeanException {\r
-        super(JndiJmx.class.getName());\r
-    }\r
-\r
-\r
-    /** If a JNDI context is set, all components\r
-     * will be registered in the context.\r
-     *\r
-     * @param ctx\r
-     */\r
-    public void setComponentContext(Context ctx) {\r
-        this.componentContext= ctx;\r
-    }\r
-\r
-    /** JNDI context for component descriptors ( metadata ).\r
-     *\r
-     * @param ctx\r
-     */\r
-    public void setDescriptorContext(Context ctx) {\r
-        this.descriptorContext= ctx;\r
-    }\r
-\r
-    /** JNDI context where attributes will be stored for persistence\r
-     *\r
-     */\r
-    public void setConfigContext( Context ctx ) {\r
-        this.configContext= ctx;\r
-    }\r
-\r
-    // --------------------  Registration/unregistration --------------------\r
-    // temp - will only set in the jndi contexts\r
-    Hashtable attributes=new Hashtable();\r
-    Hashtable instances=new Hashtable();\r
-\r
-    public void handleNotification(Notification notification, Object handback)\r
-    {\r
-        // register/unregister mbeans in jndi\r
-        if( notification instanceof MBeanServerNotification ) {\r
-            MBeanServerNotification msnot=(MBeanServerNotification)notification;\r
-\r
-            ObjectName oname=msnot.getMBeanName();\r
-\r
-            if( "jmx.mbean.created".equalsIgnoreCase( notification.getType() )) {\r
-                try {\r
-                    Object mbean=mserver.getObjectInstance(oname);\r
-\r
-                    if( log.isDebugEnabled() )\r
-                        log.debug( "MBean created " + oname + " " + mbean);\r
-\r
-                    // XXX add filter support\r
-                    if( mbean instanceof NotificationBroadcaster ) {\r
-                        // register for attribute changes\r
-                        NotificationBroadcaster nb=(NotificationBroadcaster)mbean;\r
-                        nb.addNotificationListener(this, null, null);\r
-                        if( log.isDebugEnabled() )\r
-                            log.debug( "Add attribute change listener");\r
-                    }\r
-\r
-                    instances.put( oname.toString(), mbean );\r
-                } catch( InstanceNotFoundException ex ) {\r
-                    log.error( "Instance not found for the created object", ex );\r
-                }\r
-            }\r
-            if( "jmx.mbean.deleted".equalsIgnoreCase( notification.getType() )) {\r
-                instances.remove(oname.toString());\r
-            }\r
-        }\r
-\r
-        // set attributes in jndi\r
-       //     if( "jmx.attribute.changed".equals( notification.getType() )) {\r
-        if( notification instanceof AttributeChangeNotification) {\r
-\r
-            AttributeChangeNotification anotif=(AttributeChangeNotification)notification;\r
-            String name=anotif.getAttributeName();\r
-            Object value=anotif.getNewValue();\r
-            Object source=anotif.getSource();\r
-            String mname=null;\r
-\r
-            Hashtable mbeanAtt=(Hashtable)attributes.get( source );\r
-            if( mbeanAtt==null ) {\r
-                mbeanAtt=new Hashtable();\r
-                attributes.put( source, mbeanAtt);\r
-                if( log.isDebugEnabled())\r
-                    log.debug("First attribute for " + source );\r
-            }\r
-            mbeanAtt.put( name, anotif );\r
-\r
-            log.debug( "Attribute change notification " + name + " " + value + " " + source );\r
-\r
-        }\r
-\r
-    }\r
-\r
-    public String dumpStatus() throws Exception\r
-    {\r
-        StringBuffer sb=new StringBuffer();\r
-        Enumeration en=instances.keys();\r
-        while (en.hasMoreElements()) {\r
-            String on = (String) en.nextElement();\r
-            Object mbean=instances.get(on);\r
-            Hashtable mbeanAtt=(Hashtable)attributes.get(mbean);\r
-\r
-            sb.append( "<mbean class=\"").append(on).append("\">");\r
-            sb.append( "\n");\r
-            Enumeration attEn=mbeanAtt.keys();\r
-            while (attEn.hasMoreElements()) {\r
-                String an = (String) attEn.nextElement();\r
-                AttributeChangeNotification anotif=\r
-                        (AttributeChangeNotification)mbeanAtt.get(an);\r
-                sb.append("  <attribute name=\"").append(an).append("\" ");\r
-                sb.append("value=\"").append(anotif.getNewValue()).append("\">");\r
-                sb.append( "\n");\r
-            }\r
-\r
-\r
-            sb.append( "</mbean>");\r
-            sb.append( "\n");\r
-        }\r
-        return sb.toString();\r
-    }\r
-\r
-    public void replay() throws Exception\r
-    {\r
-\r
-\r
-    }\r
-\r
-\r
-    public void init() throws Exception\r
-    {\r
-\r
-        MBeanServer mserver=(MBeanServer)Registry.getRegistry().getMBeanServer();\r
-        ObjectName delegate=new ObjectName("JMImplementation:type=MBeanServerDelegate");\r
-\r
-        // XXX need to extract info about previously loaded beans\r
-\r
-        // we'll know of all registered beans\r
-        mserver.addNotificationListener(delegate, this, null, null );\r
-\r
-    }\r
-\r
-}\r
index a2c39a7..1470446 100644 (file)
 package org.apache.tomcat.util.modeler;\r
 \r
 \r
-import java.util.ArrayList;\r
-import java.util.Iterator;\r
-import java.util.List;\r
+import java.lang.reflect.Method;\r
+import java.util.HashMap;\r
+import java.util.Map;\r
 \r
-import javax.management.Descriptor;\r
+import javax.management.AttributeNotFoundException;\r
+import javax.management.DynamicMBean;\r
 import javax.management.InstanceNotFoundException;\r
+import javax.management.MBeanAttributeInfo;\r
+import javax.management.MBeanConstructorInfo;\r
 import javax.management.MBeanException;\r
+import javax.management.MBeanInfo;\r
+import javax.management.MBeanNotificationInfo;\r
+import javax.management.MBeanOperationInfo;\r
+import javax.management.ReflectionException;\r
 import javax.management.RuntimeOperationsException;\r
-import javax.management.modelmbean.InvalidTargetObjectTypeException;\r
-import javax.management.modelmbean.ModelMBean;\r
-import javax.management.modelmbean.ModelMBeanAttributeInfo;\r
-import javax.management.modelmbean.ModelMBeanConstructorInfo;\r
-import javax.management.modelmbean.ModelMBeanInfo;\r
-import javax.management.modelmbean.ModelMBeanInfoSupport;\r
-import javax.management.modelmbean.ModelMBeanNotificationInfo;\r
-import javax.management.modelmbean.ModelMBeanOperationInfo;\r
+import javax.management.ServiceNotFoundException;\r
+//import javax.management.modelmbean.InvalidTargetObjectTypeException;\r
 \r
 \r
 /**\r
@@ -46,26 +47,31 @@ import javax.management.modelmbean.ModelMBeanOperationInfo;
 \r
 public class ManagedBean implements java.io.Serializable\r
 {\r
+    private static final String BASE_MBEAN = "org.apache.tomcat.util.modeler.BaseModelMBean";\r
     // ----------------------------------------------------- Instance Variables\r
+    static final Object[] NO_ARGS_PARAM=new Object[0];\r
+    static final Class[] NO_ARGS_PARAM_SIG=new Class[0];\r
 \r
 \r
     /**\r
      * The <code>ModelMBeanInfo</code> object that corresponds\r
      * to this <code>ManagedBean</code> instance.\r
      */\r
-    transient ModelMBeanInfo info = null;\r
-    protected AttributeInfo attributes[] = new AttributeInfo[0];\r
-    protected String className =\r
-            "org.apache.tomcat.util.modeler.BaseModelMBean";\r
-    protected ConstructorInfo constructors[] = new ConstructorInfo[0];\r
+    transient MBeanInfo info = null;\r
+    // Map<AttributeInfo>\r
+    private Map attributes = new HashMap();\r
+    //Map<OperationInfo>\r
+    private Map operations = new HashMap();\r
+    \r
+    protected String className = BASE_MBEAN;\r
+    //protected ConstructorInfo constructors[] = new ConstructorInfo[0];\r
     protected String description = null;\r
     protected String domain = null;\r
     protected String group = null;\r
     protected String name = null;\r
 \r
-    protected List fields = new ArrayList();\r
+    //protected List fields = new ArrayList();\r
     protected NotificationInfo notifications[] = new NotificationInfo[0];\r
-    protected OperationInfo operations[] = new OperationInfo[0];\r
     protected String type = null;\r
 \r
     /** Constructor. Will add default attributes. \r
@@ -87,7 +93,9 @@ public class ManagedBean implements java.io.Serializable
      * The collection of attributes for this MBean.\r
      */\r
     public AttributeInfo[] getAttributes() {\r
-        return (this.attributes);\r
+        AttributeInfo result[] = new AttributeInfo[attributes.size()];\r
+        attributes.values().toArray(result);\r
+        return result;\r
     }\r
 \r
 \r
@@ -107,12 +115,12 @@ public class ManagedBean implements java.io.Serializable
     }\r
 \r
 \r
-    /**\r
-     * The collection of constructors for this MBean.\r
-     */\r
-    public ConstructorInfo[] getConstructors() {\r
-        return (this.constructors);\r
-    }\r
+//    /**\r
+//     * The collection of constructors for this MBean.\r
+//     */\r
+//    public ConstructorInfo[] getConstructors() {\r
+//        return (this.constructors);\r
+//    }\r
 \r
 \r
     /**\r
@@ -146,10 +154,10 @@ public class ManagedBean implements java.io.Serializable
      * the name/value pairs that should be\r
      * added to the Descriptor created from this metadata.</p>\r
      */\r
-    public List getFields() {\r
-        return (this.fields);\r
-    }\r
-\r
+//    public List getFields() {\r
+//        return (this.fields);\r
+//    }\r
+//\r
 \r
     /**\r
      * The (optional) group to which this MBean belongs.\r
@@ -189,7 +197,9 @@ public class ManagedBean implements java.io.Serializable
      * The collection of operations for this MBean.\r
      */\r
     public OperationInfo[] getOperations() {\r
-        return (this.operations);\r
+        OperationInfo[] result = new OperationInfo[operations.size()];\r
+        operations.values().toArray(result);\r
+        return result;\r
     }\r
 \r
 \r
@@ -217,16 +227,7 @@ public class ManagedBean implements java.io.Serializable
      * @param attribute The new attribute descriptor\r
      */\r
     public void addAttribute(AttributeInfo attribute) {\r
-\r
-        synchronized (attributes) {\r
-            AttributeInfo results[] =\r
-                new AttributeInfo[attributes.length + 1];\r
-            System.arraycopy(attributes, 0, results, 0, attributes.length);\r
-            results[attributes.length] = attribute;\r
-            attributes = results;\r
-            this.info = null;\r
-        }\r
-\r
+        attributes.put(attribute.getName(), attribute);\r
     }\r
 \r
 \r
@@ -235,18 +236,18 @@ public class ManagedBean implements java.io.Serializable
      *\r
      * @param constructor The new constructor descriptor\r
      */\r
-    public void addConstructor(ConstructorInfo constructor) {\r
-\r
-        synchronized (constructors) {\r
-            ConstructorInfo results[] =\r
-                new ConstructorInfo[constructors.length + 1];\r
-            System.arraycopy(constructors, 0, results, 0, constructors.length);\r
-            results[constructors.length] = constructor;\r
-            constructors = results;\r
-            this.info = null;\r
-        }\r
-\r
-    }\r
+//    public void addConstructor(ConstructorInfo constructor) {\r
+//\r
+//        synchronized (constructors) {\r
+//            ConstructorInfo results[] =\r
+//                new ConstructorInfo[constructors.length + 1];\r
+//            System.arraycopy(constructors, 0, results, 0, constructors.length);\r
+//            results[constructors.length] = constructor;\r
+//            constructors = results;\r
+//            this.info = null;\r
+//        }\r
+//\r
+//    }\r
 \r
 \r
     /**\r
@@ -255,9 +256,9 @@ public class ManagedBean implements java.io.Serializable
      *\r
      * @param field The field to be added\r
      */\r
-    public void addField(FieldInfo field) {\r
-        fields.add(field);\r
-    }\r
+//    public void addField(FieldInfo field) {\r
+//        fields.add(field);\r
+//    }\r
 \r
 \r
     /**\r
@@ -286,15 +287,7 @@ public class ManagedBean implements java.io.Serializable
      * @param operation The new operation descriptor\r
      */\r
     public void addOperation(OperationInfo operation) {\r
-        synchronized (operations) {\r
-            OperationInfo results[] =\r
-                new OperationInfo[operations.length + 1];\r
-            System.arraycopy(operations, 0, results, 0, operations.length);\r
-            results[operations.length] = operation;\r
-            operations = results;\r
-            this.info = null;\r
-        }\r
-\r
+        operations.put(operation.getName(), operation);\r
     }\r
 \r
 \r
@@ -314,9 +307,8 @@ public class ManagedBean implements java.io.Serializable
      *  <code>ModelMBean</code> instance\r
      * @exception RuntimeOperationsException if a JMX runtime error occurs\r
      */\r
-    public ModelMBean createMBean()\r
+    public DynamicMBean createMBean()\r
         throws InstanceNotFoundException,\r
-        InvalidTargetObjectTypeException,\r
         MBeanException, RuntimeOperationsException {\r
 \r
         return (createMBean(null));\r
@@ -343,57 +335,58 @@ public class ManagedBean implements java.io.Serializable
      *  <code>ModelMBean</code> instance\r
      * @exception RuntimeOperationsException if a JMX runtime error occurs\r
      */\r
-    public ModelMBean createMBean(Object instance)\r
+    public DynamicMBean createMBean(Object instance)\r
         throws InstanceNotFoundException,\r
-        InvalidTargetObjectTypeException,\r
         MBeanException, RuntimeOperationsException {\r
 \r
+        BaseModelMBean mbean = null;\r
+\r
         // Load the ModelMBean implementation class\r
-        Class clazz = null;\r
-        Exception ex = null;\r
-        try {\r
-            clazz = Class.forName(getClassName());\r
-        } catch (Exception e) {\r
-        }\r
-      \r
-        if( clazz==null ) {  \r
+        if(getClassName().equals(BASE_MBEAN)) {\r
+            // Skip introspection\r
+            mbean = new BaseModelMBean();\r
+        } else {\r
+            Class clazz = null;\r
+            Exception ex = null;\r
             try {\r
-                ClassLoader cl= Thread.currentThread().getContextClassLoader();\r
-                if ( cl != null)\r
-                    clazz= cl.loadClass(getClassName());\r
+                clazz = Class.forName(getClassName());\r
             } catch (Exception e) {\r
-                ex=e;\r
+            }\r
+          \r
+            if( clazz==null ) {  \r
+                try {\r
+                    ClassLoader cl= Thread.currentThread().getContextClassLoader();\r
+                    if ( cl != null)\r
+                        clazz= cl.loadClass(getClassName());\r
+                } catch (Exception e) {\r
+                    ex=e;\r
+                }\r
+            }\r
+    \r
+            if( clazz==null) { \r
+                throw new MBeanException\r
+                    (ex, "Cannot load ModelMBean class " + getClassName());\r
+            }\r
+            try {\r
+                // Stupid - this will set the default minfo first....\r
+                mbean = (BaseModelMBean) clazz.newInstance();\r
+            } catch (RuntimeOperationsException e) {\r
+                throw e;\r
+            } catch (Exception e) {\r
+                throw new MBeanException\r
+                    (e, "Cannot instantiate ModelMBean of class " +\r
+                     getClassName());\r
             }\r
         }\r
-\r
-        if( clazz==null) { \r
-            throw new MBeanException\r
-                (ex, "Cannot load ModelMBean class " + getClassName());\r
-        }\r
-\r
-        // Create a new ModelMBean instance\r
-        ModelMBean mbean = null;\r
-        try {\r
-            mbean = (ModelMBean) clazz.newInstance();\r
-            mbean.setModelMBeanInfo(createMBeanInfo());\r
-        } catch (MBeanException e) {\r
-            throw e;\r
-        } catch (RuntimeOperationsException e) {\r
-            throw e;\r
-        } catch (Exception e) {\r
-            throw new MBeanException\r
-                (e, "Cannot instantiate ModelMBean of class " +\r
-                 getClassName());\r
-        }\r
-\r
+        \r
+        mbean.setManagedBean(this);\r
+        \r
         // Set the managed resource (if any)\r
         try {\r
             if (instance != null)\r
                 mbean.setManagedResource(instance, "ObjectReference");\r
         } catch (InstanceNotFoundException e) {\r
             throw e;\r
-        } catch (InvalidTargetObjectTypeException e) {\r
-            throw e;\r
         }\r
         return (mbean);\r
 \r
@@ -404,7 +397,7 @@ public class ManagedBean implements java.io.Serializable
      * Create and return a <code>ModelMBeanInfo</code> object that\r
      * describes this entire managed bean.\r
      */\r
-    public ModelMBeanInfo createMBeanInfo() {\r
+    MBeanInfo getMBeanInfo() {\r
 \r
         // Return our cached information (if any)\r
         if (info != null)\r
@@ -412,69 +405,49 @@ public class ManagedBean implements java.io.Serializable
 \r
         // Create subordinate information descriptors as required\r
         AttributeInfo attrs[] = getAttributes();\r
-        ModelMBeanAttributeInfo attributes[] =\r
-            new ModelMBeanAttributeInfo[attrs.length];\r
+        MBeanAttributeInfo attributes[] =\r
+            new MBeanAttributeInfo[attrs.length];\r
         for (int i = 0; i < attrs.length; i++)\r
             attributes[i] = attrs[i].createAttributeInfo();\r
+\r
+        OperationInfo opers[] = getOperations();\r
+        MBeanOperationInfo operations[] =\r
+            new MBeanOperationInfo[opers.length];\r
+        for (int i = 0; i < opers.length; i++)\r
+            operations[i] = opers[i].createOperationInfo();\r
+\r
+\r
+//        ConstructorInfo consts[] = getConstructors();\r
+//        ModelMBeanConstructorInfo constructors[] =\r
+//            new ModelMBeanConstructorInfo[consts.length];\r
+//        for (int i = 0; i < consts.length; i++)\r
+//            constructors[i] = consts[i].createConstructorInfo();\r
         \r
-        ConstructorInfo consts[] = getConstructors();\r
-        ModelMBeanConstructorInfo constructors[] =\r
-            new ModelMBeanConstructorInfo[consts.length];\r
-        for (int i = 0; i < consts.length; i++)\r
-            constructors[i] = consts[i].createConstructorInfo();\r
         NotificationInfo notifs[] = getNotifications();\r
-        ModelMBeanNotificationInfo notifications[] =\r
-            new ModelMBeanNotificationInfo[notifs.length];\r
+        MBeanNotificationInfo notifications[] =\r
+            new MBeanNotificationInfo[notifs.length];\r
         for (int i = 0; i < notifs.length; i++)\r
             notifications[i] = notifs[i].createNotificationInfo();\r
-        OperationInfo opers[] = getOperations();\r
-        ModelMBeanOperationInfo operations[] =\r
-            new ModelMBeanOperationInfo[opers.length];\r
-        for (int i = 0; i < opers.length; i++)\r
-            operations[i] = opers[i].createOperationInfo();\r
 \r
-        /*\r
-        // Add operations for attribute getters and setters as needed\r
-        ArrayList list = new ArrayList();\r
-        for (int i = 0; i < operations.length; i++)\r
-            list.add(operations[i]);\r
-        for (int i = 0; i < attributes.length; i++) {\r
-            Descriptor descriptor = attributes[i].getDescriptor();\r
-            String getMethod = (String) descriptor.getFieldValue("getMethod");\r
-            if (getMethod != null) {\r
-                OperationInfo oper =\r
-                    new OperationInfo(getMethod, true,\r
-                                      attributes[i].getType());\r
-                list.add(oper.createOperationInfo());\r
-            }\r
-            String setMethod = (String) descriptor.getFieldValue("setMethod");\r
-            if (setMethod != null) {\r
-                OperationInfo oper =\r
-                    new OperationInfo(setMethod, false,\r
-                                      attributes[i].getType());\r
-                list.add(oper.createOperationInfo());\r
-            }\r
-        }\r
-        if (list.size() > operations.length)\r
-            operations =\r
-                (ModelMBeanOperationInfo[]) list.toArray(operations);\r
-        */\r
         \r
         // Construct and return a new ModelMBeanInfo object\r
-        info = new ModelMBeanInfoSupport\r
-            (getClassName(), getDescription(),\r
-             attributes, constructors, operations, notifications);\r
-        try {\r
-            Descriptor descriptor = info.getMBeanDescriptor();\r
-            Iterator fields = getFields().iterator();\r
-            while (fields.hasNext()) {\r
-                FieldInfo field = (FieldInfo) fields.next();\r
-                descriptor.setField(field.getName(), field.getValue());\r
-            }\r
-            info.setMBeanDescriptor(descriptor);\r
-        } catch (MBeanException e) {\r
-            ;\r
-        }\r
+        info = new MBeanInfo(getClassName(), \r
+                             getDescription(),\r
+                             attributes, \r
+                             new MBeanConstructorInfo[] {}, \r
+                             operations, \r
+                             notifications);\r
+//        try {\r
+//            Descriptor descriptor = info.getMBeanDescriptor();\r
+//            Iterator fields = getFields().iterator();\r
+//            while (fields.hasNext()) {\r
+//                FieldInfo field = (FieldInfo) fields.next();\r
+//                descriptor.setField(field.getName(), field.getValue());\r
+//            }\r
+//            info.setMBeanDescriptor(descriptor);\r
+//        } catch (MBeanException e) {\r
+//            ;\r
+//        }\r
 \r
         return (info);\r
 \r
@@ -504,5 +477,151 @@ public class ManagedBean implements java.io.Serializable
 \r
     }\r
 \r
+    Method getGetter(String aname, BaseModelMBean mbean, Object resource) \r
+            throws AttributeNotFoundException, MBeanException, ReflectionException {\r
+        // TODO: do we need caching ? JMX is for management, it's not supposed to require lots of performance.\r
+        Method m=null; // (Method)getAttMap.get( name );\r
+\r
+        if( m==null ) {\r
+            AttributeInfo attrInfo = (AttributeInfo)attributes.get(aname);\r
+            // Look up the actual operation to be used\r
+            if (attrInfo == null)\r
+                throw new AttributeNotFoundException(" Cannot find attribute " + aname + " for " + resource);\r
+            \r
+            String getMethod = attrInfo.getGetMethod();\r
+            if (getMethod == null)\r
+                throw new AttributeNotFoundException("Cannot find attribute " + aname + " get method name");\r
+\r
+            Object object = null;\r
+            NoSuchMethodException exception = null;\r
+            try {\r
+                object = mbean;\r
+                m = object.getClass().getMethod(getMethod, NO_ARGS_PARAM_SIG);\r
+            } catch (NoSuchMethodException e) {\r
+                exception = e;;\r
+            }\r
+            if( m== null && resource != null ) {\r
+                try {\r
+                    object = resource;\r
+                    m = object.getClass().getMethod(getMethod, NO_ARGS_PARAM_SIG);\r
+                    exception=null;\r
+                } catch (NoSuchMethodException e) {\r
+                    exception = e;\r
+                }\r
+            }\r
+            if( exception != null )\r
+                throw new ReflectionException(exception,\r
+                                              "Cannot find getter method " + getMethod);\r
+            //getAttMap.put( name, m );\r
+        }\r
+\r
+        return m;\r
+    }\r
+\r
+    public Method getSetter(String aname, BaseModelMBean bean, Object resource) \r
+            throws AttributeNotFoundException, MBeanException, ReflectionException {\r
+        // Cache may be needed for getters, but it is a really bad idea for setters, this is far \r
+        // less frequent.\r
+        Method m=null;//(Method)setAttMap.get( name );\r
+\r
+        if( m==null ) {\r
+            AttributeInfo attrInfo = (AttributeInfo)attributes.get(aname);\r
+            if (attrInfo == null)\r
+                throw new AttributeNotFoundException(" Cannot find attribute " + aname);\r
+\r
+            // Look up the actual operation to be used\r
+            String setMethod = attrInfo.getSetMethod();\r
+            if (setMethod == null)\r
+                throw new AttributeNotFoundException("Cannot find attribute " + aname + " set method name");\r
+\r
+            String argType=attrInfo.getType();\r
+\r
+            Class signature[] = new Class[] { BaseModelMBean.getAttributeClass( argType ) };\r
+\r
+            Object object = null;\r
+            NoSuchMethodException exception = null;\r
+            try {\r
+                object = this;\r
+                m = object.getClass().getMethod(setMethod, signature);\r
+            } catch (NoSuchMethodException e) {\r
+                exception = e;;\r
+            }\r
+            if( m== null && resource != null ) {\r
+                try {\r
+                    object = resource;\r
+                    m = object.getClass().getMethod(setMethod, signature);\r
+                    exception=null;\r
+                } catch (NoSuchMethodException e) {\r
+                    exception = e;\r
+                }\r
+            }\r
+            if( exception != null )\r
+                throw new ReflectionException(exception,\r
+                                              "Cannot find setter method " + setMethod +\r
+                        " " + resource);\r
+            //setAttMap.put( name, m );\r
+        }\r
+\r
+        return m;\r
+    }\r
+\r
+    public Method getInvoke(String aname, Object[] params, String[] signature, BaseModelMBean bean, Object resource) \r
+            throws MBeanException, ReflectionException {\r
+        Method method = null;\r
+        if (method == null) {\r
+            if (params == null)\r
+                params = new Object[0];\r
+            if (signature == null)\r
+                signature = new String[0];\r
+            if (params.length != signature.length)\r
+                throw new RuntimeOperationsException(\r
+                        new IllegalArgumentException(\r
+                                "Inconsistent arguments and signature"),\r
+                        "Inconsistent arguments and signature");\r
+\r
+            // Acquire the ModelMBeanOperationInfo information for\r
+            // the requested operation\r
+            OperationInfo opInfo = (OperationInfo)operations.get(aname);\r
+            if (opInfo == null)\r
+                throw new MBeanException(new ServiceNotFoundException(\r
+                        "Cannot find operation " + aname),\r
+                        "Cannot find operation " + aname);\r
+\r
+            // Prepare the signature required by Java reflection APIs\r
+            // FIXME - should we use the signature from opInfo?\r
+            Class types[] = new Class[signature.length];\r
+            for (int i = 0; i < signature.length; i++) {\r
+                types[i] = BaseModelMBean.getAttributeClass(signature[i]);\r
+            }\r
+\r
+            // Locate the method to be invoked, either in this MBean itself\r
+            // or in the corresponding managed resource\r
+            // FIXME - Accessible methods in superinterfaces?\r
+            Object object = null;\r
+            Exception exception = null;\r
+            try {\r
+                object = this;\r
+                method = object.getClass().getMethod(aname, types);\r
+            } catch (NoSuchMethodException e) {\r
+                exception = e;\r
+                ;\r
+            }\r
+            try {\r
+                if ((method == null) && (resource != null)) {\r
+                    object = resource;\r
+                    method = object.getClass().getMethod(aname, types);\r
+                }\r
+            } catch (NoSuchMethodException e) {\r
+                exception = e;\r
+            }\r
+            if (method == null) {\r
+                throw new ReflectionException(exception, "Cannot find method "\r
+                        + aname + " with this signature");\r
+            }\r
+            // invokeAttMap.put(mkey, method);\r
+        }\r
+        return method;\r
+    }\r
+\r
 \r
 }\r
index 98e6556..f6c66f1 100644 (file)
@@ -20,8 +20,7 @@ package org.apache.tomcat.util.modeler;
 \r
 import java.io.Serializable;\r
 \r
-import javax.management.Descriptor;\r
-import javax.management.modelmbean.ModelMBeanNotificationInfo;\r
+import javax.management.MBeanNotificationInfo;\r
 \r
 \r
 /**\r
@@ -42,7 +41,7 @@ public class NotificationInfo extends FeatureInfo implements Serializable {
      * The <code>ModelMBeanNotificationInfo</code> object that corresponds\r
      * to this <code>NotificationInfo</code> instance.\r
      */\r
-    transient ModelMBeanNotificationInfo info = null;\r
+    transient MBeanNotificationInfo info = null;\r
     protected String notifTypes[] = new String[0];\r
 \r
     // ------------------------------------------------------------- Properties\r
@@ -103,18 +102,18 @@ public class NotificationInfo extends FeatureInfo implements Serializable {
      * Create and return a <code>ModelMBeanNotificationInfo</code> object that\r
      * corresponds to the attribute described by this instance.\r
      */\r
-    public ModelMBeanNotificationInfo createNotificationInfo() {\r
+    public MBeanNotificationInfo createNotificationInfo() {\r
 \r
         // Return our cached information (if any)\r
         if (info != null)\r
             return (info);\r
 \r
         // Create and return a new information object\r
-        info = new ModelMBeanNotificationInfo\r
+        info = new MBeanNotificationInfo\r
             (getNotifTypes(), getName(), getDescription());\r
-        Descriptor descriptor = info.getDescriptor();\r
-        addFields(descriptor);\r
-        info.setDescriptor(descriptor);\r
+        //Descriptor descriptor = info.getDescriptor();\r
+        //addFields(descriptor);\r
+        //info.setDescriptor(descriptor);\r
         return (info);\r
 \r
     }\r
index 6be9ea4..6874d22 100644 (file)
@@ -20,9 +20,8 @@ package org.apache.tomcat.util.modeler;
 \r
 import java.io.Serializable;\r
 \r
-import javax.management.Descriptor;\r
+import javax.management.MBeanOperationInfo;\r
 import javax.management.MBeanParameterInfo;\r
-import javax.management.modelmbean.ModelMBeanOperationInfo;\r
 \r
 \r
 /**\r
@@ -30,9 +29,7 @@ import javax.management.modelmbean.ModelMBeanOperationInfo;
  * descriptor.</p>\r
  *\r
  * @author Craig R. McClanahan\r
- * @version $Revision: 155428 $ $Date: 2005-02-26 14:12:25 +0100 (sam., 26 févr. 2005) $\r
  */\r
-\r
 public class OperationInfo extends FeatureInfo implements Serializable {\r
     static final long serialVersionUID = 4418342922072614875L;\r
     // ----------------------------------------------------------- Constructors\r
@@ -46,77 +43,16 @@ public class OperationInfo extends FeatureInfo implements Serializable {
         super();\r
 \r
     }\r
-\r
-\r
-    /**\r
-     * Special constructor for setting up getter and setter operations.\r
-     *\r
-     * @param name Name of this operation\r
-     * @param getter Is this a getter (as opposed to a setter)?\r
-     * @param type Data type of the return value (if this is a getter)\r
-     *  or the parameter (if this is a setter)\r
-     * \r
-     */\r
-    public OperationInfo(String name, boolean getter, String type) {\r
-\r
-        super();\r
-        setName(name);\r
-        if (getter) {\r
-            setDescription("Attribute getter method");\r
-            setImpact("INFO");\r
-            setReturnType(type);\r
-            setRole("getter");\r
-        } else {\r
-            setDescription("Attribute setter method");\r
-            setImpact("ACTION");\r
-            setReturnType("void");\r
-            setRole("setter");\r
-            addParameter(new ParameterInfo("value", type,\r
-                                           "New attribute value"));\r
-        }\r
-\r
-    }\r
-\r
-\r
+   \r
     // ----------------------------------------------------- Instance Variables\r
 \r
-\r
-    /**\r
-     * The <code>ModelMBeanOperationInfo</code> object that corresponds\r
-     * to this <code>OperationInfo</code> instance.\r
-     */\r
-    transient ModelMBeanOperationInfo info = null;\r
     protected String impact = "UNKNOWN";\r
     protected String role = "operation";\r
-    protected String returnType = "void";    // FIXME - Validate\r
     protected ParameterInfo parameters[] = new ParameterInfo[0];\r
 \r
 \r
     // ------------------------------------------------------------- Properties\r
 \r
-\r
-    /**\r
-     * Override the <code>description</code> property setter.\r
-     *\r
-     * @param description The new description\r
-     */\r
-    public void setDescription(String description) {\r
-        super.setDescription(description);\r
-        this.info = null;\r
-    }\r
-\r
-\r
-    /**\r
-     * Override the <code>name</code> property setter.\r
-     *\r
-     * @param name The new name\r
-     */\r
-    public void setName(String name) {\r
-        super.setName(name);\r
-        this.info = null;\r
-    }\r
-\r
-\r
     /**\r
      * The "impact" of this operation, which should be a (case-insensitive)\r
      * string value "ACTION", "ACTION_INFO", "INFO", or "UNKNOWN".\r
@@ -151,11 +87,14 @@ public class OperationInfo extends FeatureInfo implements Serializable {
      * operation.\r
      */\r
     public String getReturnType() {\r
-        return (this.returnType);\r
+        if(type == null) {\r
+            type = "void";\r
+        }\r
+        return type;\r
     }\r
 \r
     public void setReturnType(String returnType) {\r
-        this.returnType = returnType;\r
+        this.type = returnType;\r
     }\r
 \r
     /**\r
@@ -190,57 +129,32 @@ public class OperationInfo extends FeatureInfo implements Serializable {
      * Create and return a <code>ModelMBeanOperationInfo</code> object that\r
      * corresponds to the attribute described by this instance.\r
      */\r
-    public ModelMBeanOperationInfo createOperationInfo() {\r
+    MBeanOperationInfo createOperationInfo() {\r
 \r
         // Return our cached information (if any)\r
-        if (info != null)\r
-            return (info);\r
+        if (info == null) {\r
+            // Create and return a new information object\r
+            int impact = MBeanOperationInfo.UNKNOWN;\r
+            if ("ACTION".equals(getImpact()))\r
+                impact = MBeanOperationInfo.ACTION;\r
+            else if ("ACTION_INFO".equals(getImpact()))\r
+                impact = MBeanOperationInfo.ACTION_INFO;\r
+            else if ("INFO".equals(getImpact()))\r
+                impact = MBeanOperationInfo.INFO;\r
+    \r
+            info = new MBeanOperationInfo(getName(), getDescription(), \r
+                                          getMBeanParameterInfo(),\r
+                                          getReturnType(), impact);\r
+        }\r
+        return (MBeanOperationInfo)info;\r
+    }\r
 \r
-        // Create and return a new information object\r
+    protected MBeanParameterInfo[] getMBeanParameterInfo() {\r
         ParameterInfo params[] = getSignature();\r
         MBeanParameterInfo parameters[] =\r
             new MBeanParameterInfo[params.length];\r
         for (int i = 0; i < params.length; i++)\r
             parameters[i] = params[i].createParameterInfo();\r
-        int impact = ModelMBeanOperationInfo.UNKNOWN;\r
-        if ("ACTION".equals(getImpact()))\r
-            impact = ModelMBeanOperationInfo.ACTION;\r
-        else if ("ACTION_INFO".equals(getImpact()))\r
-            impact = ModelMBeanOperationInfo.ACTION_INFO;\r
-        else if ("INFO".equals(getImpact()))\r
-            impact = ModelMBeanOperationInfo.INFO;\r
-\r
-        info = new ModelMBeanOperationInfo\r
-            (getName(), getDescription(), parameters,\r
-             getReturnType(), impact);\r
-        Descriptor descriptor = info.getDescriptor();\r
-        descriptor.removeField("class");\r
-        descriptor.setField("role", getRole());\r
-        addFields(descriptor);\r
-        info.setDescriptor(descriptor);\r
-        return (info);\r
-\r
-    }\r
-\r
-\r
-    /**\r
-     * Return a string representation of this operation descriptor.\r
-     */\r
-    public String toString() {\r
-\r
-        StringBuffer sb = new StringBuffer("OperationInfo[");\r
-        sb.append("name=");\r
-        sb.append(name);\r
-        sb.append(", description=");\r
-        sb.append(description);\r
-        sb.append(", returnType=");\r
-        sb.append(returnType);\r
-        sb.append(", parameters=");\r
-        sb.append(parameters.length);\r
-        sb.append("]");\r
-        return (sb.toString());\r
-\r
+        return parameters;\r
     }\r
-\r
-\r
 }\r
index 13717bd..f5c7cd9 100644 (file)
@@ -40,80 +40,9 @@ public class ParameterInfo extends FeatureInfo implements Serializable {
      * Standard zero-arguments constructor.\r
      */\r
     public ParameterInfo() {\r
-\r
-        super();\r
-\r
-    }\r
-\r
-\r
-    /**\r
-     * Special constructor for setting up parameters programatically.\r
-     *\r
-     * @param name Name of this parameter\r
-     * @param type Java class of this parameter\r
-     * @param description Description of this parameter\r
-     */\r
-    public ParameterInfo(String name, String type, String description) {\r
-\r
         super();\r
-        setName(name);\r
-        setType(type);\r
-        setDescription(description);\r
-\r
-    }\r
-\r
-\r
-    // ----------------------------------------------------- Instance Variables\r
-\r
-\r
-    /**\r
-     * The <code>MBeanParameterInfo</code> object that corresponds\r
-     * to this <code>ParameterInfo</code> instance.\r
-     */\r
-    transient MBeanParameterInfo info = null;\r
-    protected String type = null;\r
-\r
-    // ------------------------------------------------------------- Properties\r
-\r
-\r
-    /**\r
-     * Override the <code>description</code> property setter.\r
-     *\r
-     * @param description The new description\r
-     */\r
-    public void setDescription(String description) {\r
-        super.setDescription(description);\r
-        this.info = null;\r
-    }\r
-\r
-\r
-    /**\r
-     * Override the <code>name</code> property setter.\r
-     *\r
-     * @param name The new name\r
-     */\r
-    public void setName(String name) {\r
-        super.setName(name);\r
-        this.info = null;\r
     }\r
 \r
-\r
-    /**\r
-     * The fully qualified Java class name of this parameter.\r
-     */\r
-    public String getType() {\r
-        return (this.type);\r
-    }\r
-\r
-    public void setType(String type) {\r
-        this.type = type;\r
-        this.info = null;\r
-    }\r
-\r
-\r
-    // --------------------------------------------------------- Public Methods\r
-\r
-\r
     /**\r
      * Create and return a <code>MBeanParameterInfo</code> object that\r
      * corresponds to the parameter described by this instance.\r
@@ -121,31 +50,10 @@ public class ParameterInfo extends FeatureInfo implements Serializable {
     public MBeanParameterInfo createParameterInfo() {\r
 \r
         // Return our cached information (if any)\r
-        if (info != null)\r
-            return (info);\r
-\r
-        // Create and return a new information object\r
-        info = new MBeanParameterInfo\r
-            (getName(), getType(), getDescription());\r
-        return (info);\r
-\r
-    }\r
-\r
-\r
-    /**\r
-     * Return a string representation of this parameter descriptor.\r
-     */\r
-    public String toString() {\r
-\r
-        StringBuffer sb = new StringBuffer("ParameterInfo[");\r
-        sb.append("name=");\r
-        sb.append(name);\r
-        sb.append(", description=");\r
-        sb.append(description);\r
-        sb.append(", type=");\r
-        sb.append(type);\r
-        sb.append("]");\r
-        return (sb.toString());\r
-\r
+        if (info == null) {\r
+            info = new MBeanParameterInfo\r
+                (getName(), getType(), getDescription());\r
+        }\r
+        return (MBeanParameterInfo)info;\r
     }\r
 }\r
index 14bfa7c..55de2dd 100644 (file)
@@ -23,7 +23,6 @@ import java.io.FileInputStream;
 import java.io.InputStream;\r
 import java.net.URL;\r
 import java.util.ArrayList;\r
-import java.util.Enumeration;\r
 import java.util.HashMap;\r
 import java.util.Hashtable;\r
 import java.util.Iterator;\r
@@ -38,7 +37,6 @@ import javax.management.MBeanServer;
 import javax.management.MBeanServerFactory;\r
 import javax.management.MalformedObjectNameException;\r
 import javax.management.ObjectName;\r
-import javax.management.modelmbean.ModelMBean;\r
 \r
 import org.apache.commons.logging.Log;\r
 import org.apache.commons.logging.LogFactory;\r
@@ -73,10 +71,6 @@ import org.apache.tomcat.util.modeler.modules.ModelerSource;
  * @author Costin Manolache\r
  */\r
 public class Registry implements RegistryMBean, MBeanRegistration  {\r
-    /** Experimental support for manifest-based discovery.\r
-     */\r
-    public static String MODELER_MANIFEST="/META-INF/mbeans-descriptors.xml";\r
-\r
     /**\r
      * The Log instance to which we will write our log messages.\r
      */\r
@@ -84,7 +78,7 @@ public class Registry implements RegistryMBean, MBeanRegistration  {
 \r
     // Support for the factory methods\r
     \r
-    /** Will be used to isolate different apps and enhance security\r
+    /** Will be used to isolate different apps and enhance security.\r
      */\r
     private static HashMap perLoaderRegistries=null;\r
 \r
@@ -106,19 +100,19 @@ public class Registry implements RegistryMBean, MBeanRegistration  {
      * The set of ManagedBean instances for the beans this registry\r
      * knows about, keyed by name.\r
      */\r
-    private HashMap<String, ManagedBean> descriptors = new HashMap<String, ManagedBean>();\r
+    private HashMap descriptors = new HashMap();\r
 \r
     /** List of managed byeans, keyed by class name\r
      */\r
-    private HashMap<String, ManagedBean> descriptorsByClass = new HashMap<String, ManagedBean>();\r
+    private HashMap descriptorsByClass = new HashMap();\r
 \r
     // map to avoid duplicated searching or loading descriptors \r
-    private Hashtable<String, URL> searchedPaths=new Hashtable<String, URL>();\r
+    private HashMap searchedPaths=new HashMap();\r
     \r
-    private Object key;\r
     private Object guard;\r
 \r
     // Id - small ints to use array access. No reset on stop()\r
+    // Used for notifications\r
     private Hashtable idDomains=new Hashtable();\r
     private Hashtable ids=new Hashtable();\r
 \r
@@ -160,7 +154,7 @@ public class Registry implements RegistryMBean, MBeanRegistration  {
                 localRegistry=(Registry)perLoaderRegistries.get(key);\r
                 if( localRegistry == null ) {\r
                     localRegistry=new Registry();\r
-                    localRegistry.key=key;\r
+//                    localRegistry.key=key;\r
                     localRegistry.guard=guard;\r
                     perLoaderRegistries.put( key, localRegistry );\r
                     return localRegistry;\r
@@ -184,7 +178,8 @@ public class Registry implements RegistryMBean, MBeanRegistration  {
         return (registry);\r
     }\r
     \r
-    /** Allow containers to isolate apps. Can be called only once.\r
+    /** \r
+     * Allow containers to isolate apps. Can be called only once.\r
      * It  is highly recommended you call this method if using Registry in\r
      * a container environment. The default is false for backward compatibility\r
      * \r
@@ -199,28 +194,15 @@ public class Registry implements RegistryMBean, MBeanRegistration  {
     \r
     // -------------------- Generic methods  --------------------\r
 \r
-    /** Set a guard object that will prevent access to this registry \r
-     * by unauthorized components\r
-     * \r
-     * @param guard\r
-     * \r
-     * @since 1.1\r
-     */ \r
-    public void setGuard( Object guard ) {\r
-        if( this.guard!=null ) {\r
-            return; // already set, only once\r
-        }\r
-        this.guard=guard;\r
-    }\r
-\r
     /** Lifecycle method - clean up the registry metadata.\r
+     *  Called from resetMetadata().\r
      * \r
      * @since 1.1\r
      */ \r
     public void stop() {\r
-        descriptorsByClass = new HashMap<String, ManagedBean>();\r
-        descriptors = new HashMap<String, ManagedBean>();\r
-        searchedPaths=new Hashtable<String, URL>();\r
+        descriptorsByClass = new HashMap();\r
+        descriptors = new HashMap();\r
+        searchedPaths=new HashMap();\r
     }\r
     \r
     /** \r
@@ -249,9 +231,6 @@ public class Registry implements RegistryMBean, MBeanRegistration  {
      * descriptors file. In the case of File and URL, if the extension is ".ser"\r
      * a serialized version will be loaded. \r
      * \r
-     * Also ( experimental for now ) a ClassLoader - in which case META-INF/ will\r
-     * be used.\r
-     * \r
      * This method should be used to explicitely load metadata - but this is not\r
      * required in most cases. The registerComponent() method will find metadata\r
      * in the same pacakge.\r
@@ -259,13 +238,7 @@ public class Registry implements RegistryMBean, MBeanRegistration  {
      * @param source\r
      */ \r
     public void loadMetadata(Object source ) throws Exception {\r
-        if( source instanceof ClassLoader ) {\r
-            loadMetaInfDescriptors((ClassLoader)source);\r
-            return;\r
-        } else {\r
-            loadDescriptors( null, source, null );\r
-        }\r
-        \r
+        loadDescriptors( null, source, null );\r
     }\r
 \r
     /** Register a bean by creating a modeler mbean and adding it to the \r
@@ -411,11 +384,9 @@ public class Registry implements RegistryMBean, MBeanRegistration  {
      */\r
     public void addManagedBean(ManagedBean bean) {\r
         // XXX Use group + name\r
-        synchronized(descriptors) {\r
-            descriptors.put(bean.getName(), bean);\r
-            if( bean.getType() != null ) {\r
-                descriptorsByClass.put( bean.getType(), bean );\r
-            }\r
+        descriptors.put(bean.getName(), bean);\r
+        if( bean.getType() != null ) {\r
+            descriptorsByClass.put( bean.getType(), bean );\r
         }\r
     }\r
 \r
@@ -430,12 +401,10 @@ public class Registry implements RegistryMBean, MBeanRegistration  {
      */\r
     public ManagedBean findManagedBean(String name) {\r
         // XXX Group ?? Use Group + Type\r
-        synchronized(descriptors) {\r
-            ManagedBean mb= descriptors.get(name);\r
-            if( mb==null )\r
-                mb=descriptorsByClass.get(name);\r
-            return mb;\r
-        }\r
+        ManagedBean mb=((ManagedBean) descriptors.get(name));\r
+        if( mb==null )\r
+            mb=(ManagedBean)descriptorsByClass.get(name);\r
+        return mb;\r
     }\r
     \r
     /**\r
@@ -445,9 +414,7 @@ public class Registry implements RegistryMBean, MBeanRegistration  {
      * @since 1.0\r
      */\r
     public String[] findManagedBeans() {\r
-        synchronized(descriptors) {\r
-            return ((String[]) descriptors.keySet().toArray(new String[0]));\r
-        }\r
+        return ((String[]) descriptors.keySet().toArray(new String[0]));\r
     }\r
 \r
 \r
@@ -462,15 +429,13 @@ public class Registry implements RegistryMBean, MBeanRegistration  {
     public String[] findManagedBeans(String group) {\r
 \r
         ArrayList results = new ArrayList();\r
-        synchronized(descriptors) {\r
-            Iterator<ManagedBean> items = descriptors.values().iterator();\r
-            while (items.hasNext()) {\r
-                ManagedBean item =  items.next();\r
-                if ((group == null) && (item.getGroup() == null)) {\r
-                    results.add(item.getName());\r
-                } else if (group.equals(item.getGroup())) {\r
-                    results.add(item.getName());\r
-                }\r
+        Iterator items = descriptors.values().iterator();\r
+        while (items.hasNext()) {\r
+            ManagedBean item = (ManagedBean) items.next();\r
+            if ((group == null) && (item.getGroup() == null)) {\r
+                results.add(item.getName());\r
+            } else if (group.equals(item.getGroup())) {\r
+                results.add(item.getName());\r
             }\r
         }\r
         String values[] = new String[results.size()];\r
@@ -487,10 +452,8 @@ public class Registry implements RegistryMBean, MBeanRegistration  {
      */\r
     public void removeManagedBean(ManagedBean bean) {\r
        // TODO: change this to use group/name\r
-        synchronized(descriptors) {\r
-            descriptors.remove(bean.getName());\r
-            descriptorsByClass.remove( bean.getType());\r
-        }\r
+        descriptors.remove(bean.getName());\r
+        descriptorsByClass.remove( bean.getType());\r
     }\r
 \r
     // -------------------- Deprecated 1.0 methods  --------------------\r
@@ -829,7 +792,7 @@ public class Registry implements RegistryMBean, MBeanRegistration  {
             ManagedBean managed = findManagedBean(bean.getClass(), type);\r
 \r
             // The real mbean is created and registered\r
-            ModelMBean mbean = managed.createMBean(bean);\r
+            DynamicMBean mbean = managed.createMBean(bean);\r
 \r
             if(  getMBeanServer().isRegistered( oname )) {\r
                 if( log.isDebugEnabled()) {\r
@@ -850,7 +813,7 @@ public class Registry implements RegistryMBean, MBeanRegistration  {
      *\r
      * @param packageName\r
      */\r
-    public synchronized void loadDescriptors( String packageName, ClassLoader classLoader  ) {\r
+    public void loadDescriptors( String packageName, ClassLoader classLoader  ) {\r
         String res=packageName.replace( '.', '/');\r
 \r
         if( log.isTraceEnabled() ) {\r
@@ -910,25 +873,6 @@ public class Registry implements RegistryMBean, MBeanRegistration  {
         }\r
     }\r
 \r
-    /** Discover all META-INF/modeler.xml files in classpath and register\r
-     * the components\r
-     *\r
-     * @since EXPERIMENTAL\r
-     */\r
-    private void loadMetaInfDescriptors(ClassLoader cl) {\r
-        try {\r
-            Enumeration en=cl.getResources(MODELER_MANIFEST);\r
-            while( en.hasMoreElements() ) {\r
-                URL url=(URL)en.nextElement();\r
-                InputStream is=url.openStream();\r
-                if( log.isDebugEnabled()) log.debug("Loading " + url);\r
-                loadDescriptors("MbeansDescriptorsDigesterSource", is, null );\r
-            }\r
-        } catch( Exception ex ) {\r
-            ex.printStackTrace();\r
-        }\r
-    }\r
-\r
     /** Lookup the component descriptor in the package and\r
      * in the parent packages.\r
      *\r
@@ -1072,12 +1016,6 @@ public class Registry implements RegistryMBean, MBeanRegistration  {
         }\r
     }\r
     \r
-    public List loadMBeans( Object source )\r
-            throws Exception\r
-    {\r
-        return loadMBeans( source, null );\r
-    }\r
-\r
 \r
     /**\r
      * Load the registry from a cached .ser file. This is typically 2-3 times\r
index 3b7314c..508ea8d 100644 (file)
@@ -25,8 +25,6 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;\r
 import org.apache.tomcat.util.DomUtil;\r
 import org.apache.tomcat.util.modeler.AttributeInfo;\r
-import org.apache.tomcat.util.modeler.ConstructorInfo;\r
-import org.apache.tomcat.util.modeler.FieldInfo;\r
 import org.apache.tomcat.util.modeler.ManagedBean;\r
 import org.apache.tomcat.util.modeler.NotificationInfo;\r
 import org.apache.tomcat.util.modeler.OperationInfo;\r
@@ -116,7 +114,7 @@ public class MbeansDescriptorsDOMSource extends ModelerSource
                 Node firstN;\r
 \r
                 // Process descriptor subnode\r
-                Node mbeanDescriptorN =\r
+                /*Node mbeanDescriptorN =\r
                     DomUtil.getChild(mbeanN, "descriptor");\r
                 if (mbeanDescriptorN != null) {\r
                     Node firstFieldN =\r
@@ -127,7 +125,7 @@ public class MbeansDescriptorsDOMSource extends ModelerSource
                         DomUtil.setAttributes(fi, fieldN);\r
                         managed.addField(fi);\r
                     }\r
-                }\r
+                }*/\r
 \r
                 // process attribute nodes\r
                 firstN=DomUtil.getChild( mbeanN, "attribute");\r
@@ -140,7 +138,7 @@ public class MbeansDescriptorsDOMSource extends ModelerSource
                     DomUtil.setAttributes(ai, descN);\r
 \r
                     // Process descriptor subnode\r
-                    Node descriptorN =\r
+                    /*Node descriptorN =\r
                         DomUtil.getChild(descN, "descriptor");\r
                     if (descriptorN != null) {\r
                         Node firstFieldN =\r
@@ -152,6 +150,7 @@ public class MbeansDescriptorsDOMSource extends ModelerSource
                             ai.addField(fi);\r
                         }\r
                     }\r
+                    */\r
 \r
                     // Add this info to our managed bean info\r
                     managed.addAttribute( ai );\r
@@ -162,6 +161,7 @@ public class MbeansDescriptorsDOMSource extends ModelerSource
                 }\r
 \r
                 // process constructor nodes\r
+                /*\r
                 firstN=DomUtil.getChild( mbeanN, "constructor");\r
                 for (Node descN = firstN; descN != null;\r
                      descN = DomUtil.getNext( descN )) {\r
@@ -200,7 +200,7 @@ public class MbeansDescriptorsDOMSource extends ModelerSource
                         log.trace("Create constructor " + ci);\r
                     }\r
 \r
-                }\r
+                }*/\r
 \r
                 // process notification nodes\r
                 firstN=DomUtil.getChild( mbeanN, "notification");\r
@@ -213,7 +213,7 @@ public class MbeansDescriptorsDOMSource extends ModelerSource
                     DomUtil.setAttributes(ni, descN);\r
 \r
                     // Process descriptor subnode\r
-                    Node firstDescriptorN =\r
+                    /*Node firstDescriptorN =\r
                         DomUtil.getChild(descN, "descriptor");\r
                     if (firstDescriptorN != null) {\r
                         Node firstFieldN =\r
@@ -224,7 +224,7 @@ public class MbeansDescriptorsDOMSource extends ModelerSource
                             DomUtil.setAttributes(fi, fieldN);\r
                             ni.addField(fi);\r
                         }\r
-                    }\r
+                    }*/\r
 \r
                     // Process notification-type subnodes\r
                     Node firstParamN=DomUtil.getChild( descN, "notification-type");\r
@@ -254,7 +254,7 @@ public class MbeansDescriptorsDOMSource extends ModelerSource
                     DomUtil.setAttributes(oi, descN);\r
 \r
                     // Process descriptor subnode\r
-                    Node firstDescriptorN =\r
+                    /*Node firstDescriptorN =\r
                         DomUtil.getChild(descN, "descriptor");\r
                     if (firstDescriptorN != null) {\r
                         Node firstFieldN =\r
@@ -265,7 +265,7 @@ public class MbeansDescriptorsDOMSource extends ModelerSource
                             DomUtil.setAttributes(fi, fieldN);\r
                             oi.addField(fi);\r
                         }\r
-                    }\r
+                    }*/\r
 \r
                     // Process parameter subnodes\r
                     Node firstParamN=DomUtil.getChild( descN, "parameter");\r
index a27ff84..c7645ef 100644 (file)
@@ -70,7 +70,7 @@ public class MbeansDescriptorsDigesterSource extends ModelerSource
                 "addAttribute",\r
             "org.apache.tomcat.util.modeler.AttributeInfo");\r
         \r
-        digester.addObjectCreate\r
+        /*digester.addObjectCreate\r
             ("mbeans-descriptors/mbean/attribute/descriptor/field",\r
             "org.apache.tomcat.util.modeler.FieldInfo");\r
         digester.addSetProperties\r
@@ -119,7 +119,7 @@ public class MbeansDescriptorsDigesterSource extends ModelerSource
             ("mbeans-descriptors/mbean/descriptor/field",\r
                 "addField",\r
             "org.apache.tomcat.util.modeler.FieldInfo");\r
-        \r
+        */\r
         digester.addObjectCreate\r
             ("mbeans-descriptors/mbean/notification",\r
             "org.apache.tomcat.util.modeler.NotificationInfo");\r
diff --git a/java/org/apache/tomcat/util/modeler/modules/MbeansDescriptorsDynamicMBeanSource.java b/java/org/apache/tomcat/util/modeler/modules/MbeansDescriptorsDynamicMBeanSource.java
deleted file mode 100644 (file)
index 5aa2ff7..0000000
+++ /dev/null
@@ -1,157 +0,0 @@
-package org.apache.tomcat.util.modeler.modules;\r
-\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-import javax.management.DynamicMBean;\r
-import javax.management.MBeanAttributeInfo;\r
-import javax.management.MBeanInfo;\r
-import javax.management.MBeanOperationInfo;\r
-import javax.management.MBeanParameterInfo;\r
-\r
-import org.apache.commons.logging.Log;\r
-import org.apache.commons.logging.LogFactory;\r
-import org.apache.tomcat.util.modeler.AttributeInfo;\r
-import org.apache.tomcat.util.modeler.ManagedBean;\r
-import org.apache.tomcat.util.modeler.OperationInfo;\r
-import org.apache.tomcat.util.modeler.ParameterInfo;\r
-import org.apache.tomcat.util.modeler.Registry;\r
-\r
-\r
-/** Extract metadata from a dynamic mbean.\r
- * Used to wrap a dynamic mbean in order to implement persistence.\r
- * \r
- * This is really an ugly asspect of the JMX spec - we need to convery \r
- * from normal metainfo to model metainfo. The info is the same, but\r
- * they use a different class. Just like the DOM spec - where all implementations\r
- * get an order of unneeded complexity from the various types. \r
- * \r
- */ \r
-public class MbeansDescriptorsDynamicMBeanSource extends ModelerSource\r
-{\r
-    private static Log log = LogFactory.getLog(MbeansDescriptorsDynamicMBeanSource.class);\r
-\r
-    Registry registry;\r
-    String location;\r
-    String type;\r
-    Object source;\r
-    List mbeans=new ArrayList();\r
-\r
-    public void setRegistry(Registry reg) {\r
-        this.registry=reg;\r
-    }\r
-\r
-    public void setLocation( String loc ) {\r
-        this.location=loc;\r
-    }\r
-\r
-    /** Used if a single component is loaded\r
-     *\r
-     * @param type\r
-     */\r
-    public void setType( String type ) {\r
-       this.type=type;\r
-    }\r
-\r
-    public void setSource( Object source ) {\r
-        this.source=source;\r
-    }\r
-\r
-    public List loadDescriptors( Registry registry, String location,\r
-                                 String type, Object source)\r
-            throws Exception\r
-    {\r
-        setRegistry(registry);\r
-        setLocation(location);\r
-        setType(type);\r
-        setSource(source);\r
-        execute();\r
-        return mbeans;\r
-    }\r
-\r
-    public void execute() throws Exception {\r
-        if( registry==null ) registry=Registry.getRegistry();\r
-        try {\r
-            ManagedBean managed=createManagedBean(registry, null, source, type);\r
-            if( managed==null ) return;\r
-            managed.setName( type );\r
-            \r
-            mbeans.add(managed);\r
-\r
-        } catch( Exception ex ) {\r
-            log.error( "Error reading descriptors ", ex);\r
-        }\r
-    }\r
-\r
-\r
-\r
-    // ------------ Implementation for non-declared introspection classes\r
-\r
-\r
-    /**\r
-     * XXX Find if the 'className' is the name of the MBean or\r
-     *       the real class ( I suppose first )\r
-     * XXX Read (optional) descriptions from a .properties, generated\r
-     *       from source\r
-     * XXX Deal with constructors\r
-     *\r
-     */\r
-    public ManagedBean createManagedBean(Registry registry, String domain,\r
-                                         Object realObj, String type)\r
-    {\r
-        if( ! ( realObj instanceof DynamicMBean )) {\r
-            return null;\r
-        }\r
-        DynamicMBean dmb=(DynamicMBean)realObj;\r
-        \r
-        ManagedBean mbean= new ManagedBean();\r
-        \r
-        MBeanInfo mbi=dmb.getMBeanInfo();\r
-        \r
-        try {\r
-            MBeanAttributeInfo attInfo[]=mbi.getAttributes();\r
-            for( int i=0; i<attInfo.length; i++ ) {\r
-                MBeanAttributeInfo mai=attInfo[i];\r
-                String name=mai.getName();\r
-\r
-                AttributeInfo ai=new AttributeInfo();\r
-                ai.setName( name );\r
-\r
-                ai.setType( mai.getType());\r
-                ai.setReadable( mai.isReadable());\r
-                ai.setWriteable( mai.isWritable());\r
-                                                \r
-                mbean.addAttribute(ai);\r
-            }\r
-\r
-            MBeanOperationInfo opInfo[]=mbi.getOperations();\r
-            for( int i=0; i<opInfo.length; i++ ) {\r
-                MBeanOperationInfo moi=opInfo[i];\r
-                OperationInfo op=new OperationInfo();\r
-\r
-                op.setName(moi.getName());\r
-                op.setReturnType(moi.getReturnType());\r
-                \r
-                MBeanParameterInfo parms[]=moi.getSignature();\r
-                for(int j=0; j<parms.length; j++ ) {\r
-                    ParameterInfo pi=new ParameterInfo();\r
-                    pi.setType(parms[i].getType());\r
-                    pi.setName(parms[i].getName());\r
-                    op.addParameter(pi);\r
-                }\r
-                mbean.addOperation(op);\r
-            }\r
-\r
-            if( log.isDebugEnabled())\r
-                log.debug("Setting name: " + type );\r
-\r
-            mbean.setName( type );\r
-\r
-            return mbean;\r
-        } catch( Exception ex ) {\r
-            ex.printStackTrace();\r
-            return null;\r
-        }\r
-    }\r
-\r
-}\r
index 8c4dc34..4a21e22 100644 (file)
 \r
 package org.apache.tomcat.util.modeler.modules;\r
 \r
-import org.apache.commons.logging.Log;\r
-import org.apache.commons.logging.LogFactory;\r
-import org.apache.tomcat.util.modeler.AttributeInfo;\r
-import org.apache.tomcat.util.modeler.ConstructorInfo;\r
-import org.apache.tomcat.util.modeler.ManagedBean;\r
-import org.apache.tomcat.util.modeler.OperationInfo;\r
-import org.apache.tomcat.util.modeler.ParameterInfo;\r
-import org.apache.tomcat.util.modeler.Registry;\r
-\r
-import javax.management.ObjectName;\r
-\r
 import java.lang.reflect.Method;\r
 import java.lang.reflect.Modifier;\r
-import java.lang.reflect.Constructor;\r
 import java.math.BigDecimal;\r
 import java.math.BigInteger;\r
 import java.util.ArrayList;\r
@@ -37,6 +25,16 @@ import java.util.Enumeration;
 import java.util.Hashtable;\r
 import java.util.List;\r
 \r
+import javax.management.ObjectName;\r
+\r
+import org.apache.commons.logging.Log;\r
+import org.apache.commons.logging.LogFactory;\r
+import org.apache.tomcat.util.modeler.AttributeInfo;\r
+import org.apache.tomcat.util.modeler.ManagedBean;\r
+import org.apache.tomcat.util.modeler.OperationInfo;\r
+import org.apache.tomcat.util.modeler.ParameterInfo;\r
+import org.apache.tomcat.util.modeler.Registry;\r
+\r
 public class MbeansDescriptorsIntrospectionSource extends ModelerSource\r
 {\r
     private static Log log = LogFactory.getLog(MbeansDescriptorsIntrospectionSource.class);\r
@@ -363,7 +361,7 @@ public class MbeansDescriptorsIntrospectionSource extends ModelerSource
                 }\r
             }\r
 \r
-            Constructor[] constructors = realClass.getConstructors();\r
+            /*Constructor[] constructors = realClass.getConstructors();\r
             for(int i=0;i<constructors.length;i++) {\r
                 ConstructorInfo info = new ConstructorInfo();\r
                 String className = realClass.getName();\r
@@ -383,6 +381,7 @@ public class MbeansDescriptorsIntrospectionSource extends ModelerSource
                 }\r
                 mbean.addConstructor(info);\r
             }\r
+            */\r
             \r
             if( log.isDebugEnabled())\r
                 log.debug("Setting name: " + type );\r