You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2010/05/19 18:38:41 UTC

svn commit: r946265 - in /tomcat/trunk/java/org/apache/catalina: deploy/mbeans-descriptors.xml mbeans/ContextResourceLinkMBean.java

Author: markt
Date: Wed May 19 16:38:41 2010
New Revision: 946265

URL: http://svn.apache.org/viewvc?rev=946265&view=rev
Log:
GSOC 2010: ResourceLink
Patch provided by Chamith Buddhika

Modified:
    tomcat/trunk/java/org/apache/catalina/deploy/mbeans-descriptors.xml
    tomcat/trunk/java/org/apache/catalina/mbeans/ContextResourceLinkMBean.java

Modified: tomcat/trunk/java/org/apache/catalina/deploy/mbeans-descriptors.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/deploy/mbeans-descriptors.xml?rev=946265&r1=946264&r2=946265&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/deploy/mbeans-descriptors.xml (original)
+++ tomcat/trunk/java/org/apache/catalina/deploy/mbeans-descriptors.xml Wed May 19 16:38:41 2010
@@ -95,6 +95,10 @@
     <attribute   name="name"
                description="The name of this resource"
                type="java.lang.String"/>
+               
+    <attribute   name="description"
+               description="The description of this resource"
+               type="java.lang.String"/>
       
     <attribute   name="type"
                description="The type of this resource"

Modified: tomcat/trunk/java/org/apache/catalina/mbeans/ContextResourceLinkMBean.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/mbeans/ContextResourceLinkMBean.java?rev=946265&r1=946264&r2=946265&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/mbeans/ContextResourceLinkMBean.java (original)
+++ tomcat/trunk/java/org/apache/catalina/mbeans/ContextResourceLinkMBean.java Wed May 19 16:38:41 2010
@@ -67,6 +67,58 @@ public class ContextResourceLinkMBean ex
 
     // ------------------------------------------------------------- Attributes
 
+    /**
+     * Obtain and return the value of a specific attribute of this MBean.
+     *
+     * @param name Name of the requested attribute
+     *
+     * @exception AttributeNotFoundException if this attribute is not
+     *  supported by this MBean
+     * @exception MBeanException if the initializer of an object
+     *  throws an exception
+     * @exception ReflectionException if a Java reflection exception
+     *  occurs when invoking the getter
+     */
+    @Override
+    public Object getAttribute(String name)
+        throws AttributeNotFoundException, MBeanException,
+        ReflectionException {
+ 
+        // Validate the input parameters
+        if (name == null)
+            throw new RuntimeOperationsException
+                (new IllegalArgumentException("Attribute name is null"),
+                 "Attribute name is null");
+
+        ContextResourceLink cl = null;
+        try {
+            cl = (ContextResourceLink) getManagedResource();
+        } catch (InstanceNotFoundException e) {
+            throw new MBeanException(e);
+        } catch (InvalidTargetObjectTypeException e) {
+             throw new MBeanException(e);
+        }
+        
+        String value = null;
+        if ("global".equals(name)) {
+            return (cl.getGlobal());
+        } else if ("description".equals(name)) {
+            return (cl.getDescription());
+        } else if ("name".equals(name)) {
+            return (cl.getName());              
+        } else if ("type".equals(name)) {
+            return (cl.getType());
+        } else {
+            value = (String) cl.getProperty(name);
+            if (value == null) {
+                throw new AttributeNotFoundException
+                    ("Cannot find attribute "+name);
+            }
+        }
+        
+        return value;
+        
+    }
     
     /**
      * Set the value of a specific attribute of this MBean.
@@ -85,9 +137,20 @@ public class ContextResourceLinkMBean ex
     public void setAttribute(Attribute attribute)
         throws AttributeNotFoundException, MBeanException,
         ReflectionException {
-
-        super.setAttribute(attribute);
+       
+        // Validate the input parameters
+        if (attribute == null)
+            throw new RuntimeOperationsException
+                (new IllegalArgumentException("Attribute is null"),
+                 "Attribute is null");
         
+        String name = attribute.getName();
+        Object value = attribute.getValue();
+        if (name == null)
+            throw new RuntimeOperationsException
+                (new IllegalArgumentException("Attribute name is null"),
+                 "Attribute name is null"); 
+         
         ContextResourceLink crl = null;
         try {
             crl = (ContextResourceLink) getManagedResource();
@@ -97,6 +160,18 @@ public class ContextResourceLinkMBean ex
              throw new MBeanException(e);
         }
         
+        if ("global".equals(name)) {
+            crl.setGlobal((String)value);
+        } else if ("description".equals(name)) {
+            crl.setDescription((String)value);
+        } else if ("name".equals(name)) {
+            crl.setName((String)value);              
+        } else if ("type".equals(name)) {
+            crl.setType((String)value);
+        } else {
+            crl.setProperty(name, ""+value);
+        }
+        
         // cannot use side-effects.  It's removed and added back each time 
         // there is a modification in a resource.
         NamingResources nr = crl.getNamingResources();



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