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 2016/11/25 20:40:05 UTC

svn commit: r1771377 [1/2] - in /tomcat/trunk: java/org/apache/catalina/mbeans/ webapps/docs/

Author: markt
Date: Fri Nov 25 20:40:04 2016
New Revision: 1771377

URL: http://svn.apache.org/viewvc?rev=1771377&view=rev
Log:
Refactor the MBean implementations for the internal Tomcat components to
reduce code duplication.
Formatting clean-up

Added:
    tomcat/trunk/java/org/apache/catalina/mbeans/BaseCatalinaMBean.java   (with props)
Modified:
    tomcat/trunk/java/org/apache/catalina/mbeans/ClassNameMBean.java
    tomcat/trunk/java/org/apache/catalina/mbeans/ConnectorMBean.java
    tomcat/trunk/java/org/apache/catalina/mbeans/ContainerMBean.java
    tomcat/trunk/java/org/apache/catalina/mbeans/ContextEnvironmentMBean.java
    tomcat/trunk/java/org/apache/catalina/mbeans/ContextMBean.java
    tomcat/trunk/java/org/apache/catalina/mbeans/ContextResourceLinkMBean.java
    tomcat/trunk/java/org/apache/catalina/mbeans/ContextResourceMBean.java
    tomcat/trunk/java/org/apache/catalina/mbeans/GlobalResourcesLifecycleListener.java
    tomcat/trunk/java/org/apache/catalina/mbeans/GroupMBean.java
    tomcat/trunk/java/org/apache/catalina/mbeans/MemoryUserDatabaseMBean.java
    tomcat/trunk/java/org/apache/catalina/mbeans/NamingResourcesMBean.java
    tomcat/trunk/java/org/apache/catalina/mbeans/RoleMBean.java
    tomcat/trunk/java/org/apache/catalina/mbeans/ServiceMBean.java
    tomcat/trunk/java/org/apache/catalina/mbeans/UserMBean.java
    tomcat/trunk/webapps/docs/changelog.xml

Added: tomcat/trunk/java/org/apache/catalina/mbeans/BaseCatalinaMBean.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/mbeans/BaseCatalinaMBean.java?rev=1771377&view=auto
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/mbeans/BaseCatalinaMBean.java (added)
+++ tomcat/trunk/java/org/apache/catalina/mbeans/BaseCatalinaMBean.java Fri Nov 25 20:40:04 2016
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.catalina.mbeans;
+
+import javax.management.InstanceNotFoundException;
+import javax.management.MBeanException;
+import javax.management.RuntimeOperationsException;
+import javax.management.modelmbean.InvalidTargetObjectTypeException;
+
+import org.apache.tomcat.util.modeler.BaseModelMBean;
+
+public abstract class BaseCatalinaMBean<T> extends BaseModelMBean {
+
+    protected BaseCatalinaMBean() throws MBeanException, RuntimeOperationsException {
+        super();
+    }
+
+
+    protected T doGetManagedResource() throws MBeanException {
+        try {
+            @SuppressWarnings("unchecked")
+            T resource = (T) getManagedResource();
+            return resource;
+        } catch (InstanceNotFoundException | RuntimeOperationsException |
+                InvalidTargetObjectTypeException e) {
+            throw new MBeanException(e);
+        }
+    }
+
+
+    protected static Object newInstance(String type) throws MBeanException {
+        try {
+            return Class.forName(type).newInstance();
+        } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
+            throw new MBeanException(e);
+        }
+    }
+}

Propchange: tomcat/trunk/java/org/apache/catalina/mbeans/BaseCatalinaMBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: tomcat/trunk/java/org/apache/catalina/mbeans/ClassNameMBean.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/mbeans/ClassNameMBean.java?rev=1771377&r1=1771376&r2=1771377&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/mbeans/ClassNameMBean.java (original)
+++ tomcat/trunk/java/org/apache/catalina/mbeans/ClassNameMBean.java Fri Nov 25 20:40:04 2016
@@ -14,16 +14,11 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.catalina.mbeans;
 
-
 import javax.management.MBeanException;
 import javax.management.RuntimeOperationsException;
 
-import org.apache.tomcat.util.modeler.BaseModelMBean;
-
-
 /**
  * <p>A convenience base class for <strong>ModelMBean</strong> implementations
  * where the underlying base class (and therefore the set of supported
@@ -35,42 +30,28 @@ import org.apache.tomcat.util.modeler.Ba
  *
  * @author Craig R. McClanahan
  */
-public class ClassNameMBean extends BaseModelMBean {
-
-
-     // ---------------------------------------------------------- Constructors
-
-
-     /**
-      * Construct a <code>ModelMBean</code> with default
-      * <code>ModelMBeanInfo</code> information.
-      *
-      * @exception MBeanException if the initialize of an object
-      *  throws an exception
-      * @exception RuntimeOperationsException if an IllegalArgumentException
-      *  occurs
-      */
-     public ClassNameMBean()
-         throws MBeanException, RuntimeOperationsException {
-
-         super();
+public class ClassNameMBean<T> extends BaseCatalinaMBean<T> {
 
-     }
-
-
-     // ------------------------------------------------------------ Properties
-
-
-     /**
-      * Return the fully qualified Java class name of the managed object
-      * for this MBean.
-      */
-     @Override
+    /**
+     * Construct a <code>ModelMBean</code> with default
+     * <code>ModelMBeanInfo</code> information.
+     *
+     * @exception MBeanException if the initialize of an object
+     *  throws an exception
+     * @exception RuntimeOperationsException if an IllegalArgumentException
+     *  occurs
+     */
+    public ClassNameMBean() throws MBeanException, RuntimeOperationsException {
+        super();
+    }
+
+
+    /**
+     * Return the fully qualified Java class name of the managed object
+     * for this MBean.
+     */
+    @Override
     public String getClassName() {
-
-         return (this.resource.getClass().getName());
-
-     }
-
-
- }
+        return this.resource.getClass().getName();
+    }
+}

Modified: tomcat/trunk/java/org/apache/catalina/mbeans/ConnectorMBean.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/mbeans/ConnectorMBean.java?rev=1771377&r1=1771376&r2=1771377&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/mbeans/ConnectorMBean.java (original)
+++ tomcat/trunk/java/org/apache/catalina/mbeans/ConnectorMBean.java Fri Nov 25 20:40:04 2016
@@ -14,32 +14,24 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.catalina.mbeans;
 
 import javax.management.Attribute;
 import javax.management.AttributeNotFoundException;
-import javax.management.InstanceNotFoundException;
 import javax.management.MBeanException;
 import javax.management.ReflectionException;
 import javax.management.RuntimeOperationsException;
-import javax.management.modelmbean.InvalidTargetObjectTypeException;
 
 import org.apache.catalina.connector.Connector;
 import org.apache.tomcat.util.IntrospectionUtils;
 
-
 /**
  * <p>A <strong>ModelMBean</strong> implementation for the
  * <code>org.apache.coyote.tomcat5.CoyoteConnector</code> component.</p>
  *
  * @author Amy Roh
  */
-public class ConnectorMBean extends ClassNameMBean {
-
-
-    // ----------------------------------------------------------- Constructors
-
+public class ConnectorMBean extends ClassNameMBean<Connector> {
 
     /**
      * Construct a <code>ModelMBean</code> with default
@@ -50,17 +42,11 @@ public class ConnectorMBean extends Clas
      * @exception RuntimeOperationsException if an IllegalArgumentException
      *  occurs
      */
-    public ConnectorMBean()
-        throws MBeanException, RuntimeOperationsException {
-
+    public ConnectorMBean() throws MBeanException, RuntimeOperationsException {
         super();
-
     }
 
 
-    // ------------------------------------------------------------- Attributes
-
-
     /**
      * Obtain and return the value of a specific attribute of this MBean.
      *
@@ -74,26 +60,18 @@ public class ConnectorMBean extends Clas
      *  occurs when invoking the getter
      */
     @Override
-    public Object getAttribute(String name) throws AttributeNotFoundException,
-            MBeanException, ReflectionException {
+    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");
-
-        Object result = null;
-        try {
-            Connector connector = (Connector) getManagedResource();
-            result = IntrospectionUtils.getProperty(connector, name);
-        } catch (InstanceNotFoundException e) {
-            throw new MBeanException(e);
-        } catch (InvalidTargetObjectTypeException e) {
-            throw new MBeanException(e);
+        if (name == null) {
+            throw new RuntimeOperationsException(
+                    new IllegalArgumentException("Attribute name is null"),
+                    "Attribute name is null");
         }
 
-        return result;
-
+        Connector connector = doGetManagedResource();
+        return IntrospectionUtils.getProperty(connector, name);
     }
 
 
@@ -111,30 +89,23 @@ public class ConnectorMBean extends Clas
      *  occurs when invoking the getter
      */
      @Override
-    public void setAttribute(Attribute attribute)
-            throws AttributeNotFoundException, MBeanException,
+    public void setAttribute(Attribute attribute) throws AttributeNotFoundException, MBeanException,
             ReflectionException {
 
         // Validate the input parameters
-        if (attribute == null)
+        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");
-
-        try {
-            Connector connector = (Connector) getManagedResource();
-            IntrospectionUtils.setProperty(connector, name, String.valueOf(value));
-        } catch (InstanceNotFoundException e) {
-            throw new MBeanException(e);
-        } catch (InvalidTargetObjectTypeException e) {
-            throw new MBeanException(e);
+        if (name == null) {
+            throw new RuntimeOperationsException(
+                    new IllegalArgumentException("Attribute name is null"),
+                    "Attribute name is null");
         }
 
+        Connector connector = doGetManagedResource();
+        IntrospectionUtils.setProperty(connector, name, String.valueOf(value));
     }
-
-
 }

Modified: tomcat/trunk/java/org/apache/catalina/mbeans/ContainerMBean.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/mbeans/ContainerMBean.java?rev=1771377&r1=1771376&r2=1771377&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/mbeans/ContainerMBean.java (original)
+++ tomcat/trunk/java/org/apache/catalina/mbeans/ContainerMBean.java Fri Nov 25 20:40:04 2016
@@ -14,18 +14,15 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.catalina.mbeans;
 
 import java.util.ArrayList;
 import java.util.List;
 
-import javax.management.InstanceNotFoundException;
 import javax.management.MBeanException;
 import javax.management.MalformedObjectNameException;
 import javax.management.ObjectName;
 import javax.management.RuntimeOperationsException;
-import javax.management.modelmbean.InvalidTargetObjectTypeException;
 
 import org.apache.catalina.Container;
 import org.apache.catalina.ContainerListener;
@@ -38,9 +35,8 @@ import org.apache.catalina.core.Standard
 import org.apache.catalina.core.StandardHost;
 import org.apache.catalina.startup.ContextConfig;
 import org.apache.catalina.startup.HostConfig;
-import org.apache.tomcat.util.modeler.BaseModelMBean;
 
-public class ContainerMBean extends BaseModelMBean {
+public class ContainerMBean extends BaseCatalinaMBean<ContainerBase> {
 
     /**
      * Construct a <code>ModelMBean</code> with default
@@ -51,12 +47,11 @@ public class ContainerMBean extends Base
      * @exception RuntimeOperationsException if an IllegalArgumentException
      *  occurs
      */
-    public ContainerMBean()
-        throws MBeanException, RuntimeOperationsException {
-
+    public ContainerMBean() throws MBeanException, RuntimeOperationsException {
         super();
     }
 
+
     /**
      * Add a new child Container to those associated with this Container,
      * if supported. Won't start the child yet. Has to be started with a call to
@@ -68,42 +63,26 @@ public class ContainerMBean extends Base
      * @exception MBeanException if the child cannot be added
      */
     public void addChild(String type, String name) throws MBeanException{
-        Container contained = null;
-        try {
-            contained = (Container)Class.forName(type).newInstance();
-            contained.setName(name);
 
-            if(contained instanceof StandardHost){
-                HostConfig config = new HostConfig();
-                contained.addLifecycleListener(config);
-            } else if(contained instanceof StandardContext){
-                ContextConfig config = new ContextConfig();
-                contained.addLifecycleListener(config);
-            }
+        Container contained = (Container) newInstance(type);
+        contained.setName(name);
 
-        } catch (InstantiationException e) {
-            throw new MBeanException(e);
-        } catch (IllegalAccessException e) {
-            throw new MBeanException(e);
-        } catch (ClassNotFoundException e) {
-            throw new MBeanException(e);
+        if(contained instanceof StandardHost){
+            HostConfig config = new HostConfig();
+            contained.addLifecycleListener(config);
+        } else if(contained instanceof StandardContext){
+            ContextConfig config = new ContextConfig();
+            contained.addLifecycleListener(config);
         }
 
         boolean oldValue= true;
 
-        ContainerBase container = null;
+        ContainerBase container = doGetManagedResource();
         try {
-            container = (ContainerBase)getManagedResource();
             oldValue = container.getStartChildren();
             container.setStartChildren(false);
             container.addChild(contained);
             contained.init();
-        } catch (InstanceNotFoundException e) {
-            throw new MBeanException(e);
-        } catch (RuntimeOperationsException e) {
-            throw new MBeanException(e);
-        } catch (InvalidTargetObjectTypeException e) {
-            throw new MBeanException(e);
         } catch (LifecycleException e){
             throw new MBeanException(e);
         } finally {
@@ -113,6 +92,7 @@ public class ContainerMBean extends Base
         }
     }
 
+
     /**
      * Remove an existing child Container from association with this parent
      * Container.
@@ -121,21 +101,14 @@ public class ContainerMBean extends Base
      * @throws MBeanException if the child cannot be removed
      */
     public void removeChild(String name) throws MBeanException{
-        if(name != null){
-            try {
-                Container container = (Container)getManagedResource();
-                Container contained = container.findChild(name);
-                container.removeChild(contained);
-            } catch (InstanceNotFoundException e) {
-                throw new MBeanException(e);
-            } catch (RuntimeOperationsException e) {
-                throw new MBeanException(e);
-            } catch (InvalidTargetObjectTypeException e) {
-                throw new MBeanException(e);
-            }
+        if (name != null) {
+            Container container = doGetManagedResource();
+            Container contained = container.findChild(name);
+            container.removeChild(contained);
         }
     }
 
+
     /**
      * Adds a valve to this Container instance.
      *
@@ -144,31 +117,10 @@ public class ContainerMBean extends Base
      * @throws MBeanException if adding the valve failed
      */
     public String addValve(String valveType) throws MBeanException{
-        Valve valve = null;
-        try {
-            valve = (Valve)Class.forName(valveType).newInstance();
-        } catch (InstantiationException e) {
-            throw new MBeanException(e);
-        } catch (IllegalAccessException e) {
-            throw new MBeanException(e);
-        } catch (ClassNotFoundException e) {
-            throw new MBeanException(e);
-        }
+        Valve valve = (Valve) newInstance(valveType);
 
-        if (valve == null) {
-            return null;
-        }
-
-        try {
-            Container container = (Container)getManagedResource();
-            container.getPipeline().addValve(valve);
-        } catch (InstanceNotFoundException e) {
-            throw new MBeanException(e);
-        } catch (RuntimeOperationsException e) {
-            throw new MBeanException(e);
-        } catch (InvalidTargetObjectTypeException e) {
-            throw new MBeanException(e);
-        }
+        Container container = doGetManagedResource();
+        container.getPipeline().addValve(valve);
 
         if (valve instanceof JmxEnabled) {
             return ((JmxEnabled)valve).getObjectName().toString();
@@ -177,6 +129,7 @@ public class ContainerMBean extends Base
         }
     }
 
+
     /**
      * Remove an existing Valve.
      *
@@ -185,16 +138,7 @@ public class ContainerMBean extends Base
      * @exception MBeanException if a component cannot be removed
      */
     public void removeValve(String valveName) throws MBeanException{
-        Container container=null;
-        try {
-            container = (Container)getManagedResource();
-        } catch (InstanceNotFoundException e) {
-            throw new MBeanException(e);
-        } catch (RuntimeOperationsException e) {
-            throw new MBeanException(e);
-        } catch (InvalidTargetObjectTypeException e) {
-            throw new MBeanException(e);
-        }
+        Container container = doGetManagedResource();
 
         ObjectName oname;
         try {
@@ -205,12 +149,11 @@ public class ContainerMBean extends Base
             throw new MBeanException(e);
         }
 
-        if(container != null){
+        if (container != null){
             Valve[] valves = container.getPipeline().getValves();
             for (int i = 0; i < valves.length; i++) {
                 if (valves[i] instanceof JmxEnabled) {
-                    ObjectName voname =
-                            ((JmxEnabled) valves[i]).getObjectName();
+                    ObjectName voname = ((JmxEnabled) valves[i]).getObjectName();
                     if (voname.equals(oname)) {
                         container.getPipeline().removeValve(valves[i]);
                     }
@@ -219,6 +162,7 @@ public class ContainerMBean extends Base
         }
     }
 
+
     /**
      * Add a LifecycleEvent listener to this component.
      *
@@ -226,31 +170,12 @@ public class ContainerMBean extends Base
      * @throws MBeanException if adding the listener failed
     */
     public void addLifecycleListener(String type) throws MBeanException{
-        LifecycleListener listener = null;
-        try {
-            listener = (LifecycleListener)Class.forName(type).newInstance();
-        } catch (InstantiationException e) {
-            throw new MBeanException(e);
-        } catch (IllegalAccessException e) {
-            throw new MBeanException(e);
-        } catch (ClassNotFoundException e) {
-            throw new MBeanException(e);
-        }
-
-        if(listener != null){
-            try {
-                Container container = (Container)getManagedResource();
-                container.addLifecycleListener(listener);
-            } catch (InstanceNotFoundException e) {
-                throw new MBeanException(e);
-            } catch (RuntimeOperationsException e) {
-                throw new MBeanException(e);
-            } catch (InvalidTargetObjectTypeException e) {
-                throw new MBeanException(e);
-            }
-        }
+        LifecycleListener listener = (LifecycleListener) newInstance(type);
+        Container container = doGetManagedResource();
+        container.addLifecycleListener(listener);
     }
 
+
     /**
      * Remove a LifecycleEvent listeners from this component.
      *
@@ -259,20 +184,11 @@ public class ContainerMBean extends Base
      * @throws MBeanException propagated from the managed resource access
      */
     public void removeLifecycleListeners(String type) throws MBeanException{
-        Container container=null;
-        try {
-            container = (Container)getManagedResource();
-        } catch (InstanceNotFoundException e) {
-            throw new MBeanException(e);
-        } catch (RuntimeOperationsException e) {
-            throw new MBeanException(e);
-        } catch (InvalidTargetObjectTypeException e) {
-            throw new MBeanException(e);
-        }
+        Container container = doGetManagedResource();
 
         LifecycleListener[] listeners = container.findLifecycleListeners();
-        for(LifecycleListener listener: listeners){
-            if(listener.getClass().getName().equals(type)){
+        for (LifecycleListener listener : listeners){
+            if (listener.getClass().getName().equals(type)) {
                 container.removeLifecycleListener(listener);
             }
         }
@@ -286,19 +202,9 @@ public class ContainerMBean extends Base
      * @throws MBeanException propagated from the managed resource access
      */
     public String[] findLifecycleListenerNames() throws MBeanException {
-        Container container = null;
+        Container container = doGetManagedResource();
         List<String> result = new ArrayList<>();
 
-        try {
-            container = (Container) getManagedResource();
-        } catch (InstanceNotFoundException e) {
-            throw new MBeanException(e);
-        } catch (RuntimeOperationsException e) {
-            throw new MBeanException(e);
-        } catch (InvalidTargetObjectTypeException e) {
-            throw new MBeanException(e);
-        }
-
         LifecycleListener[] listeners = container.findLifecycleListeners();
         for(LifecycleListener listener: listeners){
             result.add(listener.getClass().getName());
@@ -315,19 +221,9 @@ public class ContainerMBean extends Base
      * @throws MBeanException propagated from the managed resource access
      */
     public String[] findContainerListenerNames() throws MBeanException {
-        Container container = null;
+        Container container = doGetManagedResource();
         List<String> result = new ArrayList<>();
 
-        try {
-            container = (Container) getManagedResource();
-        } catch (InstanceNotFoundException e) {
-            throw new MBeanException(e);
-        } catch (RuntimeOperationsException e) {
-            throw new MBeanException(e);
-        } catch (InvalidTargetObjectTypeException e) {
-            throw new MBeanException(e);
-        }
-
         ContainerListener[] listeners = container.findContainerListeners();
         for(ContainerListener listener: listeners){
             result.add(listener.getClass().getName());

Modified: tomcat/trunk/java/org/apache/catalina/mbeans/ContextEnvironmentMBean.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/mbeans/ContextEnvironmentMBean.java?rev=1771377&r1=1771376&r2=1771377&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/mbeans/ContextEnvironmentMBean.java (original)
+++ tomcat/trunk/java/org/apache/catalina/mbeans/ContextEnvironmentMBean.java Fri Nov 25 20:40:04 2016
@@ -18,16 +18,12 @@ package org.apache.catalina.mbeans;
 
 import javax.management.Attribute;
 import javax.management.AttributeNotFoundException;
-import javax.management.InstanceNotFoundException;
 import javax.management.MBeanException;
 import javax.management.ReflectionException;
 import javax.management.RuntimeOperationsException;
-import javax.management.modelmbean.InvalidTargetObjectTypeException;
 
 import org.apache.tomcat.util.descriptor.web.ContextEnvironment;
 import org.apache.tomcat.util.descriptor.web.NamingResources;
-import org.apache.tomcat.util.modeler.BaseModelMBean;
-
 
 /**
  * <p>A <strong>ModelMBean</strong> implementation for the
@@ -35,10 +31,7 @@ import org.apache.tomcat.util.modeler.Ba
  *
  * @author Amy Roh
  */
-public class ContextEnvironmentMBean extends BaseModelMBean {
-
-
-    // ----------------------------------------------------------- Constructors
+public class ContextEnvironmentMBean extends BaseCatalinaMBean<ContextEnvironment> {
 
 
     /**
@@ -50,20 +43,11 @@ public class ContextEnvironmentMBean ext
      * @exception RuntimeOperationsException if an IllegalArgumentException
      *  occurs
      */
-    public ContextEnvironmentMBean()
-        throws MBeanException, RuntimeOperationsException {
-
+    public ContextEnvironmentMBean() throws MBeanException, RuntimeOperationsException {
         super();
-
     }
 
 
-    // ----------------------------------------------------- Instance Variables
-
-
-    // ------------------------------------------------------------- Attributes
-
-
     /**
      * Set the value of a specific attribute of this MBean.
      *
@@ -78,20 +62,12 @@ public class ContextEnvironmentMBean ext
      *  occurs when invoking the getter
      */
      @Override
-    public void setAttribute(Attribute attribute)
-        throws AttributeNotFoundException, MBeanException,
-        ReflectionException {
+    public void setAttribute(Attribute attribute) throws AttributeNotFoundException, MBeanException,
+            ReflectionException {
 
         super.setAttribute(attribute);
 
-        ContextEnvironment ce = null;
-        try {
-            ce = (ContextEnvironment) getManagedResource();
-        } catch (InstanceNotFoundException e) {
-            throw new MBeanException(e);
-        } catch (InvalidTargetObjectTypeException e) {
-             throw new MBeanException(e);
-        }
+        ContextEnvironment ce = doGetManagedResource();
 
         // cannot use side-effects.  It's removed and added back each time
         // there is a modification in a resource.
@@ -99,5 +75,4 @@ public class ContextEnvironmentMBean ext
         nr.removeEnvironment(ce.getName());
         nr.addEnvironment(ce);
     }
-
 }

Modified: tomcat/trunk/java/org/apache/catalina/mbeans/ContextMBean.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/mbeans/ContextMBean.java?rev=1771377&r1=1771376&r2=1771377&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/mbeans/ContextMBean.java (original)
+++ tomcat/trunk/java/org/apache/catalina/mbeans/ContextMBean.java Fri Nov 25 20:40:04 2016
@@ -14,13 +14,10 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.catalina.mbeans;
 
-import javax.management.InstanceNotFoundException;
 import javax.management.MBeanException;
 import javax.management.RuntimeOperationsException;
-import javax.management.modelmbean.InvalidTargetObjectTypeException;
 
 import org.apache.catalina.Context;
 import org.apache.tomcat.util.descriptor.web.ApplicationParameter;
@@ -29,13 +26,13 @@ import org.apache.tomcat.util.descriptor
 import org.apache.tomcat.util.descriptor.web.FilterMap;
 import org.apache.tomcat.util.descriptor.web.SecurityConstraint;
 
-public class ContextMBean extends ContainerMBean {
+public class ContextMBean extends BaseCatalinaMBean<Context> {
 
     public ContextMBean() throws MBeanException, RuntimeOperationsException {
-
         super();
     }
 
+
      /**
      * Return the set of application parameters for this application.
      * @return a string array with a representation of each parameter
@@ -43,27 +40,18 @@ public class ContextMBean extends Contai
      */
     public String[] findApplicationParameters() throws MBeanException {
 
-        Context context;
-        try {
-            context = (Context)getManagedResource();
-        } catch (InstanceNotFoundException e) {
-            throw new MBeanException(e);
-        } catch (RuntimeOperationsException e) {
-            throw new MBeanException(e);
-        } catch (InvalidTargetObjectTypeException e) {
-            throw new MBeanException(e);
-        }
+        Context context = doGetManagedResource();
 
         ApplicationParameter[] params = context.findApplicationParameters();
         String[] stringParams = new String[params.length];
-        for(int counter=0; counter < params.length; counter++){
-           stringParams[counter]=params[counter].toString();
+        for (int counter = 0; counter < params.length; counter++) {
+           stringParams[counter] = params[counter].toString();
         }
 
         return stringParams;
-
     }
 
+
     /**
      * Return the security constraints for this web application.
      * If there are none, a zero-length array is returned.
@@ -73,27 +61,18 @@ public class ContextMBean extends Contai
      */
     public String[] findConstraints() throws MBeanException {
 
-        Context context;
-        try {
-            context = (Context)getManagedResource();
-        } catch (InstanceNotFoundException e) {
-            throw new MBeanException(e);
-        } catch (RuntimeOperationsException e) {
-            throw new MBeanException(e);
-        } catch (InvalidTargetObjectTypeException e) {
-            throw new MBeanException(e);
-        }
+        Context context = doGetManagedResource();
 
         SecurityConstraint[] constraints = context.findConstraints();
         String[] stringConstraints = new String[constraints.length];
-        for(int counter=0; counter < constraints.length; counter++){
-            stringConstraints[counter]=constraints[counter].toString();
+        for (int counter = 0; counter < constraints.length; counter++) {
+            stringConstraints[counter] = constraints[counter].toString();
         }
 
         return stringConstraints;
-
     }
 
+
     /**
      * Return the error page entry for the specified HTTP error code,
      * if any; otherwise return <code>null</code>.
@@ -103,22 +82,11 @@ public class ContextMBean extends Contai
      * @throws MBeanException propagated from the managed resource access
      */
     public String findErrorPage(int errorCode) throws MBeanException {
-
-        Context context;
-        try {
-            context = (Context)getManagedResource();
-        } catch (InstanceNotFoundException e) {
-            throw new MBeanException(e);
-        } catch (RuntimeOperationsException e) {
-            throw new MBeanException(e);
-        } catch (InvalidTargetObjectTypeException e) {
-            throw new MBeanException(e);
-        }
-
+        Context context = doGetManagedResource();
         return context.findErrorPage(errorCode).toString();
-
     }
 
+
     /**
      * Return the error page entry for the specified Java exception type,
      * if any; otherwise return <code>null</code>.
@@ -128,22 +96,11 @@ public class ContextMBean extends Contai
      * @throws MBeanException propagated from the managed resource access
      */
     public String findErrorPage(String exceptionType) throws MBeanException {
-
-        Context context;
-        try {
-            context = (Context)getManagedResource();
-        } catch (InstanceNotFoundException e) {
-            throw new MBeanException(e);
-        } catch (RuntimeOperationsException e) {
-            throw new MBeanException(e);
-        } catch (InvalidTargetObjectTypeException e) {
-            throw new MBeanException(e);
-        }
-
+        Context context = doGetManagedResource();
         return context.findErrorPage(exceptionType).toString();
-
     }
 
+
     /**
      * Return the set of defined error pages for all specified error codes
      * and exception types.
@@ -152,27 +109,18 @@ public class ContextMBean extends Contai
      */
     public String[] findErrorPages() throws MBeanException {
 
-        Context context;
-        try {
-            context = (Context)getManagedResource();
-        } catch (InstanceNotFoundException e) {
-            throw new MBeanException(e);
-        } catch (RuntimeOperationsException e) {
-            throw new MBeanException(e);
-        } catch (InvalidTargetObjectTypeException e) {
-            throw new MBeanException(e);
-        }
+        Context context = doGetManagedResource();
 
         ErrorPage[] pages = context.findErrorPages();
         String[] stringPages = new String[pages.length];
-        for(int counter=0; counter < pages.length; counter++){
-            stringPages[counter]=pages[counter].toString();
+        for (int counter = 0; counter < pages.length; counter++) {
+            stringPages[counter] = pages[counter].toString();
         }
 
         return stringPages;
-
     }
 
+
     /**
      * Return the filter definition for the specified filter name, if any;
      * otherwise return <code>null</code>.
@@ -183,22 +131,13 @@ public class ContextMBean extends Contai
      */
     public String findFilterDef(String name) throws MBeanException {
 
-        Context context;
-        try {
-            context = (Context)getManagedResource();
-        } catch (InstanceNotFoundException e) {
-            throw new MBeanException(e);
-        } catch (RuntimeOperationsException e) {
-            throw new MBeanException(e);
-        } catch (InvalidTargetObjectTypeException e) {
-            throw new MBeanException(e);
-        }
+        Context context = doGetManagedResource();
 
         FilterDef filterDef = context.findFilterDef(name);
         return filterDef.toString();
-
     }
 
+
     /**
      * Return the set of defined filters for this Context.
      * @return a string array with a representation of all
@@ -207,27 +146,18 @@ public class ContextMBean extends Contai
      */
     public String[] findFilterDefs() throws MBeanException {
 
-        Context context;
-        try {
-            context = (Context)getManagedResource();
-        } catch (InstanceNotFoundException e) {
-            throw new MBeanException(e);
-        } catch (RuntimeOperationsException e) {
-            throw new MBeanException(e);
-        } catch (InvalidTargetObjectTypeException e) {
-            throw new MBeanException(e);
-        }
+        Context context = doGetManagedResource();
 
         FilterDef[] filterDefs = context.findFilterDefs();
         String[] stringFilters = new String[filterDefs.length];
-        for(int counter=0; counter < filterDefs.length; counter++){
-            stringFilters[counter]=filterDefs[counter].toString();
+        for (int counter = 0; counter < filterDefs.length; counter++) {
+            stringFilters[counter] = filterDefs[counter].toString();
         }
 
         return stringFilters;
-
     }
 
+
     /**
      * Return the set of filter mappings for this Context.
      * @return a string array with a representation of all the filter mappings
@@ -235,25 +165,14 @@ public class ContextMBean extends Contai
      */
     public String[] findFilterMaps() throws MBeanException {
 
-        Context context;
-        try {
-            context = (Context)getManagedResource();
-        } catch (InstanceNotFoundException e) {
-            throw new MBeanException(e);
-        } catch (RuntimeOperationsException e) {
-            throw new MBeanException(e);
-        } catch (InvalidTargetObjectTypeException e) {
-            throw new MBeanException(e);
-        }
+        Context context = doGetManagedResource();
 
         FilterMap[] maps = context.findFilterMaps();
         String[] stringMaps = new String[maps.length];
-        for(int counter=0; counter < maps.length; counter++){
-            stringMaps[counter]=maps[counter].toString();
+        for (int counter = 0; counter < maps.length; counter++) {
+            stringMaps[counter] = maps[counter].toString();
         }
 
         return stringMaps;
-
     }
-
 }

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=1771377&r1=1771376&r2=1771377&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/mbeans/ContextResourceLinkMBean.java (original)
+++ tomcat/trunk/java/org/apache/catalina/mbeans/ContextResourceLinkMBean.java Fri Nov 25 20:40:04 2016
@@ -18,16 +18,12 @@ package org.apache.catalina.mbeans;
 
 import javax.management.Attribute;
 import javax.management.AttributeNotFoundException;
-import javax.management.InstanceNotFoundException;
 import javax.management.MBeanException;
 import javax.management.ReflectionException;
 import javax.management.RuntimeOperationsException;
-import javax.management.modelmbean.InvalidTargetObjectTypeException;
 
 import org.apache.tomcat.util.descriptor.web.ContextResourceLink;
 import org.apache.tomcat.util.descriptor.web.NamingResources;
-import org.apache.tomcat.util.modeler.BaseModelMBean;
-
 
 /**
  * <p>A <strong>ModelMBean</strong> implementation for the
@@ -35,10 +31,7 @@ import org.apache.tomcat.util.modeler.Ba
  *
  * @author Amy Roh
  */
-public class ContextResourceLinkMBean extends BaseModelMBean {
-
-
-    // ----------------------------------------------------------- Constructors
+public class ContextResourceLinkMBean extends BaseCatalinaMBean<ContextResourceLink> {
 
 
     /**
@@ -50,19 +43,11 @@ public class ContextResourceLinkMBean ex
      * @exception RuntimeOperationsException if an IllegalArgumentException
      *  occurs
      */
-    public ContextResourceLinkMBean()
-        throws MBeanException, RuntimeOperationsException {
-
+    public ContextResourceLinkMBean() throws MBeanException, RuntimeOperationsException {
         super();
-
     }
 
 
-    // ----------------------------------------------------- Instance Variables
-
-
-    // ------------------------------------------------------------- Attributes
-
     /**
      * Obtain and return the value of a specific attribute of this MBean.
      *
@@ -76,25 +61,18 @@ public class ContextResourceLinkMBean ex
      *  occurs when invoking the getter
      */
     @Override
-    public Object getAttribute(String name)
-        throws AttributeNotFoundException, MBeanException,
-        ReflectionException {
+    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);
+        if (name == null) {
+            throw new RuntimeOperationsException(
+                    new IllegalArgumentException("Attribute name is null"),
+                    "Attribute name is null");
         }
 
+        ContextResourceLink cl = doGetManagedResource();
+
         String value = null;
         if ("global".equals(name)) {
             return (cl.getGlobal());
@@ -107,15 +85,14 @@ public class ContextResourceLinkMBean ex
         } else {
             value = (String) cl.getProperty(name);
             if (value == null) {
-                throw new AttributeNotFoundException
-                    ("Cannot find attribute "+name);
+                throw new AttributeNotFoundException("Cannot find attribute [" + name + "]");
             }
         }
 
         return value;
-
     }
 
+
     /**
      * Set the value of a specific attribute of this MBean.
      *
@@ -130,42 +107,36 @@ public class ContextResourceLinkMBean ex
      *  occurs when invoking the getter
      */
      @Override
-    public void setAttribute(Attribute attribute)
-        throws AttributeNotFoundException, MBeanException,
-        ReflectionException {
+    public void setAttribute(Attribute attribute) throws AttributeNotFoundException, MBeanException,
+            ReflectionException {
 
         // Validate the input parameters
-        if (attribute == null)
-            throw new RuntimeOperationsException
-                (new IllegalArgumentException("Attribute is null"),
-                 "Attribute is null");
+        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();
-        } catch (InstanceNotFoundException e) {
-            throw new MBeanException(e);
-        } catch (InvalidTargetObjectTypeException e) {
-             throw new MBeanException(e);
+        if (name == null) {
+            throw new RuntimeOperationsException(
+                    new IllegalArgumentException("Attribute name is null"),
+                    "Attribute name is null");
         }
 
+        ContextResourceLink crl = doGetManagedResource();
+
         if ("global".equals(name)) {
-            crl.setGlobal((String)value);
+            crl.setGlobal((String) value);
         } else if ("description".equals(name)) {
-            crl.setDescription((String)value);
+            crl.setDescription((String) value);
         } else if ("name".equals(name)) {
-            crl.setName((String)value);
+            crl.setName((String) value);
         } else if ("type".equals(name)) {
-            crl.setType((String)value);
+            crl.setType((String) value);
         } else {
-            crl.setProperty(name, ""+value);
+            crl.setProperty(name, "" + value);
         }
 
         // cannot use side-effects.  It's removed and added back each time
@@ -174,5 +145,4 @@ public class ContextResourceLinkMBean ex
         nr.removeResourceLink(crl.getName());
         nr.addResourceLink(crl);
     }
-
 }

Modified: tomcat/trunk/java/org/apache/catalina/mbeans/ContextResourceMBean.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/mbeans/ContextResourceMBean.java?rev=1771377&r1=1771376&r2=1771377&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/mbeans/ContextResourceMBean.java (original)
+++ tomcat/trunk/java/org/apache/catalina/mbeans/ContextResourceMBean.java Fri Nov 25 20:40:04 2016
@@ -18,16 +18,12 @@ package org.apache.catalina.mbeans;
 
 import javax.management.Attribute;
 import javax.management.AttributeNotFoundException;
-import javax.management.InstanceNotFoundException;
 import javax.management.MBeanException;
 import javax.management.ReflectionException;
 import javax.management.RuntimeOperationsException;
-import javax.management.modelmbean.InvalidTargetObjectTypeException;
 
 import org.apache.tomcat.util.descriptor.web.ContextResource;
 import org.apache.tomcat.util.descriptor.web.NamingResources;
-import org.apache.tomcat.util.modeler.BaseModelMBean;
-
 
 /**
  * <p>A <strong>ModelMBean</strong> implementation for the
@@ -35,11 +31,7 @@ import org.apache.tomcat.util.modeler.Ba
  *
  * @author Amy Roh
  */
-public class ContextResourceMBean extends BaseModelMBean {
-
-
-    // ----------------------------------------------------------- Constructors
-
+public class ContextResourceMBean extends BaseCatalinaMBean<ContextResource> {
 
     /**
      * Construct a <code>ModelMBean</code> with default
@@ -50,20 +42,11 @@ public class ContextResourceMBean extend
      * @exception RuntimeOperationsException if an IllegalArgumentException
      *  occurs
      */
-    public ContextResourceMBean()
-        throws MBeanException, RuntimeOperationsException {
-
+    public ContextResourceMBean() throws MBeanException, RuntimeOperationsException {
         super();
-
     }
 
 
-    // ----------------------------------------------------- Instance Variables
-
-
-    // ------------------------------------------------------------- Attributes
-
-
     /**
      * Obtain and return the value of a specific attribute of this MBean.
      *
@@ -77,25 +60,18 @@ public class ContextResourceMBean extend
      *  occurs when invoking the getter
      */
     @Override
-    public Object getAttribute(String name)
-        throws AttributeNotFoundException, MBeanException,
-        ReflectionException {
+    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");
-
-        ContextResource cr = null;
-        try {
-            cr = (ContextResource) getManagedResource();
-        } catch (InstanceNotFoundException e) {
-            throw new MBeanException(e);
-        } catch (InvalidTargetObjectTypeException e) {
-             throw new MBeanException(e);
+        if (name == null) {
+            throw new RuntimeOperationsException(
+                    new IllegalArgumentException("Attribute name is null"),
+                    "Attribute name is null");
         }
 
+        ContextResource cr = doGetManagedResource();
+
         String value = null;
         if ("auth".equals(name)) {
             return (cr.getAuth());
@@ -111,12 +87,11 @@ public class ContextResourceMBean extend
             value = (String) cr.getProperty(name);
             if (value == null) {
                 throw new AttributeNotFoundException
-                    ("Cannot find attribute "+name);
+                    ("Cannot find attribute [" + name + "]");
             }
         }
 
         return value;
-
     }
 
 
@@ -134,31 +109,25 @@ public class ContextResourceMBean extend
      *  occurs when invoking the getter
      */
      @Override
-    public void setAttribute(Attribute attribute)
-        throws AttributeNotFoundException, MBeanException,
-        ReflectionException {
+    public void setAttribute(Attribute attribute) throws AttributeNotFoundException, MBeanException,
+            ReflectionException {
 
         // Validate the input parameters
-        if (attribute == null)
-            throw new RuntimeOperationsException
-                (new IllegalArgumentException("Attribute is null"),
-                 "Attribute is null");
+        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");
-
-        ContextResource cr = null;
-        try {
-            cr = (ContextResource) getManagedResource();
-        } catch (InstanceNotFoundException e) {
-            throw new MBeanException(e);
-        } catch (InvalidTargetObjectTypeException e) {
-             throw new MBeanException(e);
+        if (name == null) {
+            throw new RuntimeOperationsException(
+                    new IllegalArgumentException("Attribute name is null"),
+                    "Attribute name is null");
         }
 
+        ContextResource cr = doGetManagedResource();
+
         if ("auth".equals(name)) {
             cr.setAuth((String)value);
         } else if ("description".equals(name)) {
@@ -170,7 +139,7 @@ public class ContextResourceMBean extend
         } else if ("type".equals(name)) {
             cr.setType((String)value);
         } else {
-            cr.setProperty(name, ""+value);
+            cr.setProperty(name, "" + value);
         }
 
         // cannot use side-effects.  It's removed and added back each time

Modified: tomcat/trunk/java/org/apache/catalina/mbeans/GlobalResourcesLifecycleListener.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/mbeans/GlobalResourcesLifecycleListener.java?rev=1771377&r1=1771376&r2=1771377&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/mbeans/GlobalResourcesLifecycleListener.java (original)
+++ tomcat/trunk/java/org/apache/catalina/mbeans/GlobalResourcesLifecycleListener.java Fri Nov 25 20:40:04 2016
@@ -47,12 +47,12 @@ import org.apache.tomcat.util.modeler.Re
  * @author Craig R. McClanahan
  * @since 4.1
  */
-public class GlobalResourcesLifecycleListener
-    implements LifecycleListener {
+public class GlobalResourcesLifecycleListener implements LifecycleListener {
+
     private static final Log log = LogFactory.getLog(GlobalResourcesLifecycleListener.class);
 
-    // ----------------------------------------------------- Instance Variables
 
+    // ----------------------------------------------------- Instance Variables
 
     /**
      * The owning Catalina component that we are attached to.
@@ -68,7 +68,6 @@ public class GlobalResourcesLifecycleLis
 
     // ---------------------------------------------- LifecycleListener Methods
 
-
     /**
      * Primary entry point for startup and shutdown events.
      *
@@ -84,18 +83,15 @@ public class GlobalResourcesLifecycleLis
             destroyMBeans();
             component = null;
         }
-
     }
 
 
     // ------------------------------------------------------ Protected Methods
 
-
     /**
      * Create the MBeans for the interesting global JNDI resources.
      */
     protected void createMBeans() {
-
         // Look up our global naming context
         Context context = null;
         try {
@@ -111,7 +107,6 @@ public class GlobalResourcesLifecycleLis
         } catch (NamingException e) {
             log.error("Exception processing Global JNDI Resources", e);
         }
-
     }
 
 
@@ -124,8 +119,7 @@ public class GlobalResourcesLifecycleLis
      *
      * @exception NamingException if a JNDI exception occurs
      */
-    protected void createMBeans(String prefix, Context context)
-        throws NamingException {
+    protected void createMBeans(String prefix, Context context) throws NamingException {
 
         if (log.isDebugEnabled()) {
             log.debug("Creating MBeans for Global JNDI Resources in Context '" +
@@ -147,8 +141,7 @@ public class GlobalResourcesLifecycleLis
                     try {
                         createMBeans(name, (UserDatabase) value);
                     } catch (Exception e) {
-                        log.error("Exception creating UserDatabase MBeans for " + name,
-                                e);
+                        log.error("Exception creating UserDatabase MBeans for " + name, e);
                     }
                 }
             }
@@ -157,7 +150,6 @@ public class GlobalResourcesLifecycleLis
         } catch( OperationNotSupportedException ex) {
             log.error("Operation not supported " + ex);
         }
-
     }
 
 
@@ -169,8 +161,7 @@ public class GlobalResourcesLifecycleLis
      *
      * @exception Exception if an exception occurs while creating MBeans
      */
-    protected void createMBeans(String name, UserDatabase database)
-        throws Exception {
+    protected void createMBeans(String name, UserDatabase database) throws Exception {
 
         // Create the MBean for the UserDatabase itself
         if (log.isDebugEnabled()) {
@@ -194,8 +185,7 @@ public class GlobalResourcesLifecycleLis
             try {
                 MBeanUtils.createMBean(role);
             } catch (Exception e) {
-                throw new IllegalArgumentException(
-                        "Cannot create Role MBean for role " + role, e);
+                throw new IllegalArgumentException("Cannot create Role MBean for role " + role, e);
             }
         }
 
@@ -228,7 +218,6 @@ public class GlobalResourcesLifecycleLis
                         "Cannot create User MBean for user " + user, e);
             }
         }
-
     }
 
 
@@ -236,11 +225,8 @@ public class GlobalResourcesLifecycleLis
      * Destroy the MBeans for the interesting global JNDI resources.
      */
     protected void destroyMBeans() {
-
         if (log.isDebugEnabled()) {
             log.debug("Destroying MBeans for Global JNDI Resources");
         }
-
     }
-
 }

Modified: tomcat/trunk/java/org/apache/catalina/mbeans/GroupMBean.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/mbeans/GroupMBean.java?rev=1771377&r1=1771376&r2=1771377&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/mbeans/GroupMBean.java (original)
+++ tomcat/trunk/java/org/apache/catalina/mbeans/GroupMBean.java Fri Nov 25 20:40:04 2016
@@ -14,10 +14,8 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.catalina.mbeans;
 
-
 import java.util.ArrayList;
 import java.util.Iterator;
 
@@ -41,10 +39,6 @@ import org.apache.tomcat.util.modeler.Re
  */
 public class GroupMBean extends BaseModelMBean {
 
-
-    // ----------------------------------------------------------- Constructors
-
-
     /**
      * Construct a <code>ModelMBean</code> with default
      * <code>ModelMBeanInfo</code> information.
@@ -54,17 +48,11 @@ public class GroupMBean extends BaseMode
      * @exception RuntimeOperationsException if an IllegalArgumentException
      *  occurs
      */
-    public GroupMBean()
-        throws MBeanException, RuntimeOperationsException {
-
+    public GroupMBean() throws MBeanException, RuntimeOperationsException {
         super();
-
     }
 
 
-    // ----------------------------------------------------- Instance Variables
-
-
     /**
      * The configuration information registry for our managed beans.
      */
@@ -77,9 +65,6 @@ public class GroupMBean extends BaseMode
     protected final ManagedBean managed = registry.findManagedBean("Group");
 
 
-    // ------------------------------------------------------------- Attributes
-
-
     /**
      * @return the MBean Names of all authorized roles for this group.
      */
@@ -92,18 +77,16 @@ public class GroupMBean extends BaseMode
             Role role = null;
             try {
                 role = roles.next();
-                ObjectName oname =
-                    MBeanUtils.createObjectName(managed.getDomain(), role);
+                ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), role);
                 results.add(oname.toString());
             } catch (MalformedObjectNameException e) {
-                IllegalArgumentException iae = new IllegalArgumentException
-                    ("Cannot create object name for role " + role);
+                IllegalArgumentException iae = new IllegalArgumentException(
+                        "Cannot create object name for role " + role);
                 iae.initCause(e);
                 throw iae;
             }
         }
         return results.toArray(new String[results.size()]);
-
     }
 
 
@@ -119,24 +102,19 @@ public class GroupMBean extends BaseMode
             User user = null;
             try {
                 user = users.next();
-                ObjectName oname =
-                    MBeanUtils.createObjectName(managed.getDomain(), user);
+                ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), user);
                 results.add(oname.toString());
             } catch (MalformedObjectNameException e) {
-                IllegalArgumentException iae = new IllegalArgumentException
-                    ("Cannot create object name for user " + user);
+                IllegalArgumentException iae = new IllegalArgumentException(
+                        "Cannot create object name for user " + user);
                 iae.initCause(e);
                 throw iae;
             }
         }
         return results.toArray(new String[results.size()]);
-
     }
 
 
-    // ------------------------------------------------------------- Operations
-
-
     /**
      * Add a new {@link Role} to those this group belongs to.
      *
@@ -150,11 +128,9 @@ public class GroupMBean extends BaseMode
         }
         Role role = group.getUserDatabase().findRole(rolename);
         if (role == null) {
-            throw new IllegalArgumentException
-                ("Invalid role name '" + rolename + "'");
+            throw new IllegalArgumentException("Invalid role name '" + rolename + "'");
         }
         group.addRole(role);
-
     }
 
 
@@ -171,12 +147,8 @@ public class GroupMBean extends BaseMode
         }
         Role role = group.getUserDatabase().findRole(rolename);
         if (role == null) {
-            throw new IllegalArgumentException
-                ("Invalid role name '" + rolename + "'");
+            throw new IllegalArgumentException("Invalid role name [" + rolename + "]");
         }
         group.removeRole(role);
-
     }
-
-
 }

Modified: tomcat/trunk/java/org/apache/catalina/mbeans/MemoryUserDatabaseMBean.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/mbeans/MemoryUserDatabaseMBean.java?rev=1771377&r1=1771376&r2=1771377&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/mbeans/MemoryUserDatabaseMBean.java (original)
+++ tomcat/trunk/java/org/apache/catalina/mbeans/MemoryUserDatabaseMBean.java Fri Nov 25 20:40:04 2016
@@ -14,10 +14,8 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.catalina.mbeans;
 
-
 import java.util.ArrayList;
 import java.util.Iterator;
 
@@ -42,10 +40,8 @@ import org.apache.tomcat.util.modeler.Re
  */
 public class MemoryUserDatabaseMBean extends BaseModelMBean {
 
-
     // ----------------------------------------------------------- Constructors
 
-
     /**
      * Construct a <code>ModelMBean</code> with default
      * <code>ModelMBeanInfo</code> information.
@@ -55,17 +51,13 @@ public class MemoryUserDatabaseMBean ext
      * @exception RuntimeOperationsException if an IllegalArgumentException
      *  occurs
      */
-    public MemoryUserDatabaseMBean()
-        throws MBeanException, RuntimeOperationsException {
-
+    public MemoryUserDatabaseMBean() throws MBeanException, RuntimeOperationsException {
         super();
-
     }
 
 
     // ----------------------------------------------------- Instance Variables
 
-
     /**
      * The configuration information registry for our managed beans.
      */
@@ -75,39 +67,33 @@ public class MemoryUserDatabaseMBean ext
     /**
      * The <code>ManagedBean</code> information describing this MBean.
      */
-    protected final ManagedBean managed =
-        registry.findManagedBean("MemoryUserDatabase");
+    protected final ManagedBean managed = registry.findManagedBean("MemoryUserDatabase");
 
 
     /**
      * The <code>ManagedBean</code> information describing Group MBeans.
      */
-    protected final ManagedBean managedGroup =
-        registry.findManagedBean("Group");
+    protected final ManagedBean managedGroup = registry.findManagedBean("Group");
 
 
     /**
      * The <code>ManagedBean</code> information describing Group MBeans.
      */
-    protected final ManagedBean managedRole =
-        registry.findManagedBean("Role");
+    protected final ManagedBean managedRole = registry.findManagedBean("Role");
 
 
     /**
      * The <code>ManagedBean</code> information describing User MBeans.
      */
-    protected final ManagedBean managedUser =
-        registry.findManagedBean("User");
+    protected final ManagedBean managedUser = registry.findManagedBean("User");
 
 
     // ------------------------------------------------------------- Attributes
 
-
     /**
      * @return the MBean Names of all groups defined in this database.
      */
     public String[] getGroups() {
-
         UserDatabase database = (UserDatabase) this.resource;
         ArrayList<String> results = new ArrayList<>();
         Iterator<Group> groups = database.getGroups();
@@ -116,7 +102,6 @@ public class MemoryUserDatabaseMBean ext
             results.add(findGroup(group.getGroupname()));
         }
         return results.toArray(new String[results.size()]);
-
     }
 
 
@@ -124,7 +109,6 @@ public class MemoryUserDatabaseMBean ext
      * @return the MBean Names of all roles defined in this database.
      */
     public String[] getRoles() {
-
         UserDatabase database = (UserDatabase) this.resource;
         ArrayList<String> results = new ArrayList<>();
         Iterator<Role> roles = database.getRoles();
@@ -133,7 +117,6 @@ public class MemoryUserDatabaseMBean ext
             results.add(findRole(role.getRolename()));
         }
         return results.toArray(new String[results.size()]);
-
     }
 
 
@@ -141,7 +124,6 @@ public class MemoryUserDatabaseMBean ext
      * @return the MBean Names of all users defined in this database.
      */
     public String[] getUsers() {
-
         UserDatabase database = (UserDatabase) this.resource;
         ArrayList<String> results = new ArrayList<>();
         Iterator<User> users = database.getUsers();
@@ -150,13 +132,11 @@ public class MemoryUserDatabaseMBean ext
             results.add(findUser(user.getUsername()));
         }
         return results.toArray(new String[results.size()]);
-
     }
 
 
     // ------------------------------------------------------------- Operations
 
-
     /**
      * Create a new Group and return the corresponding MBean Name.
      *
@@ -165,19 +145,17 @@ public class MemoryUserDatabaseMBean ext
      * @return the new group object name
      */
     public String createGroup(String groupname, String description) {
-
         UserDatabase database = (UserDatabase) this.resource;
         Group group = database.createGroup(groupname, description);
         try {
             MBeanUtils.createMBean(group);
         } catch (Exception e) {
-            IllegalArgumentException iae = new IllegalArgumentException
-                ("Exception creating group [" + groupname + "] MBean");
+            IllegalArgumentException iae = new IllegalArgumentException(
+                    "Exception creating group [" + groupname + "] MBean");
             iae.initCause(e);
             throw iae;
         }
-        return (findGroup(groupname));
-
+        return findGroup(groupname);
     }
 
 
@@ -189,19 +167,17 @@ public class MemoryUserDatabaseMBean ext
      * @return the new role object name
      */
     public String createRole(String rolename, String description) {
-
         UserDatabase database = (UserDatabase) this.resource;
         Role role = database.createRole(rolename, description);
         try {
             MBeanUtils.createMBean(role);
         } catch (Exception e) {
-            IllegalArgumentException iae = new IllegalArgumentException
-                ("Exception creating role [" + rolename + "] MBean");
+            IllegalArgumentException iae = new IllegalArgumentException(
+                    "Exception creating role [" + rolename + "] MBean");
             iae.initCause(e);
             throw iae;
         }
-        return (findRole(rolename));
-
+        return findRole(rolename);
     }
 
 
@@ -213,21 +189,18 @@ public class MemoryUserDatabaseMBean ext
      * @param fullName Full name for the new user
      * @return the new user object name
      */
-    public String createUser(String username, String password,
-                             String fullName) {
-
+    public String createUser(String username, String password, String fullName) {
         UserDatabase database = (UserDatabase) this.resource;
         User user = database.createUser(username, password, fullName);
         try {
             MBeanUtils.createMBean(user);
         } catch (Exception e) {
-            IllegalArgumentException iae = new IllegalArgumentException
-                ("Exception creating user [" + username + "] MBean");
+            IllegalArgumentException iae = new IllegalArgumentException(
+                    "Exception creating user [" + username + "] MBean");
             iae.initCause(e);
             throw iae;
         }
-        return (findUser(username));
-
+        return findUser(username);
     }
 
 
@@ -239,23 +212,20 @@ public class MemoryUserDatabaseMBean ext
      * @return the group object name
      */
     public String findGroup(String groupname) {
-
         UserDatabase database = (UserDatabase) this.resource;
         Group group = database.findGroup(groupname);
         if (group == null) {
-            return (null);
+            return null;
         }
         try {
-            ObjectName oname =
-                MBeanUtils.createObjectName(managedGroup.getDomain(), group);
-            return (oname.toString());
+            ObjectName oname = MBeanUtils.createObjectName(managedGroup.getDomain(), group);
+            return oname.toString();
         } catch (MalformedObjectNameException e) {
-            IllegalArgumentException iae = new IllegalArgumentException
-                ("Cannot create object name for group [" + groupname + "]");
+            IllegalArgumentException iae = new IllegalArgumentException(
+                    "Cannot create object name for group [" + groupname + "]");
             iae.initCause(e);
             throw iae;
         }
-
     }
 
 
@@ -267,19 +237,17 @@ public class MemoryUserDatabaseMBean ext
      * @return the role object name
      */
     public String findRole(String rolename) {
-
         UserDatabase database = (UserDatabase) this.resource;
         Role role = database.findRole(rolename);
         if (role == null) {
-            return (null);
+            return null;
         }
         try {
-            ObjectName oname =
-                MBeanUtils.createObjectName(managedRole.getDomain(), role);
-            return (oname.toString());
+            ObjectName oname = MBeanUtils.createObjectName(managedRole.getDomain(), role);
+            return oname.toString();
         } catch (MalformedObjectNameException e) {
-            IllegalArgumentException iae = new IllegalArgumentException
-                ("Cannot create object name for role [" + rolename + "]");
+            IllegalArgumentException iae = new IllegalArgumentException(
+                    "Cannot create object name for role [" + rolename + "]");
             iae.initCause(e);
             throw iae;
         }
@@ -295,23 +263,20 @@ public class MemoryUserDatabaseMBean ext
      * @return the user object name
      */
     public String findUser(String username) {
-
         UserDatabase database = (UserDatabase) this.resource;
         User user = database.findUser(username);
         if (user == null) {
-            return (null);
+            return null;
         }
         try {
-            ObjectName oname =
-                MBeanUtils.createObjectName(managedUser.getDomain(), user);
-            return (oname.toString());
+            ObjectName oname = MBeanUtils.createObjectName(managedUser.getDomain(), user);
+            return oname.toString();
         } catch (MalformedObjectNameException e) {
-            IllegalArgumentException iae = new IllegalArgumentException
-                ("Cannot create object name for user [" + username + "]");
+            IllegalArgumentException iae = new IllegalArgumentException(
+                    "Cannot create object name for user [" + username + "]");
             iae.initCause(e);
             throw iae;
         }
-
     }
 
 
@@ -321,7 +286,6 @@ public class MemoryUserDatabaseMBean ext
      * @param groupname Group name to remove
      */
     public void removeGroup(String groupname) {
-
         UserDatabase database = (UserDatabase) this.resource;
         Group group = database.findGroup(groupname);
         if (group == null) {
@@ -331,12 +295,11 @@ public class MemoryUserDatabaseMBean ext
             MBeanUtils.destroyMBean(group);
             database.removeGroup(group);
         } catch (Exception e) {
-            IllegalArgumentException iae = new IllegalArgumentException
-                ("Exception destroying group [" + groupname + "] MBean");
+            IllegalArgumentException iae = new IllegalArgumentException(
+                    "Exception destroying group [" + groupname + "] MBean");
             iae.initCause(e);
             throw iae;
         }
-
     }
 
 
@@ -346,7 +309,6 @@ public class MemoryUserDatabaseMBean ext
      * @param rolename Role name to remove
      */
     public void removeRole(String rolename) {
-
         UserDatabase database = (UserDatabase) this.resource;
         Role role = database.findRole(rolename);
         if (role == null) {
@@ -356,12 +318,11 @@ public class MemoryUserDatabaseMBean ext
             MBeanUtils.destroyMBean(role);
             database.removeRole(role);
         } catch (Exception e) {
-            IllegalArgumentException iae = new IllegalArgumentException
-                ("Exception destroying role [" + rolename + "] MBean");
+            IllegalArgumentException iae = new IllegalArgumentException(
+                    "Exception destroying role [" + rolename + "] MBean");
             iae.initCause(e);
             throw iae;
         }
-
     }
 
 
@@ -371,7 +332,6 @@ public class MemoryUserDatabaseMBean ext
      * @param username User name to remove
      */
     public void removeUser(String username) {
-
         UserDatabase database = (UserDatabase) this.resource;
         User user = database.findUser(username);
         if (user == null) {
@@ -381,13 +341,10 @@ public class MemoryUserDatabaseMBean ext
             MBeanUtils.destroyMBean(user);
             database.removeUser(user);
         } catch (Exception e) {
-            IllegalArgumentException iae = new IllegalArgumentException
-                ("Exception destroying user [" + username + "] MBean");
+            IllegalArgumentException iae = new IllegalArgumentException(
+                    "Exception destroying user [" + username + "] MBean");
             iae.initCause(e);
             throw iae;
         }
-
     }
-
-
 }

Modified: tomcat/trunk/java/org/apache/catalina/mbeans/NamingResourcesMBean.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/mbeans/NamingResourcesMBean.java?rev=1771377&r1=1771376&r2=1771377&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/mbeans/NamingResourcesMBean.java (original)
+++ tomcat/trunk/java/org/apache/catalina/mbeans/NamingResourcesMBean.java Fri Nov 25 20:40:04 2016
@@ -14,7 +14,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.catalina.mbeans;
 
 import java.util.ArrayList;
@@ -40,10 +39,8 @@ import org.apache.tomcat.util.modeler.Re
  */
 public class NamingResourcesMBean extends BaseModelMBean {
 
-
     // ----------------------------------------------------------- Constructors
 
-
     /**
      * Construct a <code>ModelMBean</code> with default
      * <code>ModelMBeanInfo</code> information.
@@ -53,11 +50,8 @@ public class NamingResourcesMBean extend
      * @exception RuntimeOperationsException if an IllegalArgumentException
      *  occurs
      */
-    public NamingResourcesMBean()
-        throws MBeanException, RuntimeOperationsException {
-
+    public NamingResourcesMBean() throws MBeanException, RuntimeOperationsException {
         super();
-
     }
 
 
@@ -72,11 +66,10 @@ public class NamingResourcesMBean extend
     /**
      * The <code>ManagedBean</code> information describing this MBean.
      */
-    protected final ManagedBean managed =
-        registry.findManagedBean("NamingResources");
+    protected final ManagedBean managed = registry.findManagedBean("NamingResources");
 
-    // ------------------------------------------------------------- Attributes
 
+    // ------------------------------------------------------------- Attributes
 
     /**
      * Return the MBean Names of the set of defined environment entries for
@@ -84,23 +77,20 @@ public class NamingResourcesMBean extend
      * @return an array of object names as strings
      */
     public String[] getEnvironments() {
-        ContextEnvironment[] envs =
-                            ((NamingResourcesImpl)this.resource).findEnvironments();
+        ContextEnvironment[] envs = ((NamingResourcesImpl)this.resource).findEnvironments();
         ArrayList<String> results = new ArrayList<>();
         for (int i = 0; i < envs.length; i++) {
             try {
-                ObjectName oname =
-                    MBeanUtils.createObjectName(managed.getDomain(), envs[i]);
+                ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), envs[i]);
                 results.add(oname.toString());
             } catch (MalformedObjectNameException e) {
-                IllegalArgumentException iae = new IllegalArgumentException
-                    ("Cannot create object name for environment " + envs[i]);
+                IllegalArgumentException iae = new IllegalArgumentException (
+                        "Cannot create object name for environment " + envs[i]);
                 iae.initCause(e);
                 throw iae;
             }
         }
         return results.toArray(new String[results.size()]);
-
     }
 
 
@@ -110,24 +100,20 @@ public class NamingResourcesMBean extend
      * @return an array of object names as strings
      */
     public String[] getResources() {
-
-        ContextResource[] resources =
-                            ((NamingResourcesImpl)this.resource).findResources();
+        ContextResource[] resources = ((NamingResourcesImpl)this.resource).findResources();
         ArrayList<String> results = new ArrayList<>();
         for (int i = 0; i < resources.length; i++) {
             try {
-                ObjectName oname =
-                    MBeanUtils.createObjectName(managed.getDomain(), resources[i]);
+                ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), resources[i]);
                 results.add(oname.toString());
             } catch (MalformedObjectNameException e) {
-                IllegalArgumentException iae = new IllegalArgumentException
-                    ("Cannot create object name for resource " + resources[i]);
+                IllegalArgumentException iae = new IllegalArgumentException(
+                        "Cannot create object name for resource " + resources[i]);
                 iae.initCause(e);
                 throw iae;
             }
         }
         return results.toArray(new String[results.size()]);
-
     }
 
 
@@ -137,28 +123,26 @@ public class NamingResourcesMBean extend
      * @return an array of object names as strings
      */
     public String[] getResourceLinks() {
-
         ContextResourceLink[] resourceLinks =
-                            ((NamingResourcesImpl)this.resource).findResourceLinks();
+                ((NamingResourcesImpl)this.resource).findResourceLinks();
         ArrayList<String> results = new ArrayList<>();
         for (int i = 0; i < resourceLinks.length; i++) {
             try {
                 ObjectName oname =
-                    MBeanUtils.createObjectName(managed.getDomain(), resourceLinks[i]);
+                        MBeanUtils.createObjectName(managed.getDomain(), resourceLinks[i]);
                 results.add(oname.toString());
             } catch (MalformedObjectNameException e) {
-                IllegalArgumentException iae = new IllegalArgumentException
-                    ("Cannot create object name for resource " + resourceLinks[i]);
+                IllegalArgumentException iae = new IllegalArgumentException(
+                        "Cannot create object name for resource " + resourceLinks[i]);
                 iae.initCause(e);
                 throw iae;
             }
         }
         return results.toArray(new String[results.size()]);
-
     }
 
-    // ------------------------------------------------------------- Operations
 
+    // ------------------------------------------------------------- Operations
 
     /**
      * Add an environment entry for this web application.
@@ -170,7 +154,7 @@ public class NamingResourcesMBean extend
      * @throws MalformedObjectNameException if the object name was invalid
      */
     public String addEnvironment(String envName, String type, String value)
-        throws MalformedObjectNameException {
+            throws MalformedObjectNameException {
 
         NamingResourcesImpl nresources = (NamingResourcesImpl) this.resource;
         if (nresources == null) {
@@ -178,8 +162,8 @@ public class NamingResourcesMBean extend
         }
         ContextEnvironment env = nresources.findEnvironment(envName);
         if (env != null) {
-            throw new IllegalArgumentException
-                ("Invalid environment name - already exists '" + envName + "'");
+            throw new IllegalArgumentException(
+                    "Invalid environment name - already exists '" + envName + "'");
         }
         env = new ContextEnvironment();
         env.setName(envName);
@@ -189,10 +173,8 @@ public class NamingResourcesMBean extend
 
         // Return the corresponding MBean name
         ManagedBean managed = registry.findManagedBean("ContextEnvironment");
-        ObjectName oname =
-            MBeanUtils.createObjectName(managed.getDomain(), env);
-        return (oname.toString());
-
+        ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), env);
+        return oname.toString();
     }
 
 
@@ -205,7 +187,7 @@ public class NamingResourcesMBean extend
      * @throws MalformedObjectNameException if the object name was invalid
      */
     public String addResource(String resourceName, String type)
-        throws MalformedObjectNameException {
+            throws MalformedObjectNameException {
 
         NamingResourcesImpl nresources = (NamingResourcesImpl) this.resource;
         if (nresources == null) {
@@ -213,8 +195,8 @@ public class NamingResourcesMBean extend
         }
         ContextResource resource = nresources.findResource(resourceName);
         if (resource != null) {
-            throw new IllegalArgumentException
-                ("Invalid resource name - already exists'" + resourceName + "'");
+            throw new IllegalArgumentException(
+                    "Invalid resource name - already exists'" + resourceName + "'");
         }
         resource = new ContextResource();
         resource.setName(resourceName);
@@ -223,9 +205,8 @@ public class NamingResourcesMBean extend
 
         // Return the corresponding MBean name
         ManagedBean managed = registry.findManagedBean("ContextResource");
-        ObjectName oname =
-            MBeanUtils.createObjectName(managed.getDomain(), resource);
-        return (oname.toString());
+        ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), resource);
+        return oname.toString();
     }
 
 
@@ -247,9 +228,8 @@ public class NamingResourcesMBean extend
         ContextResourceLink resourceLink =
                             nresources.findResourceLink(resourceLinkName);
         if (resourceLink != null) {
-            throw new IllegalArgumentException
-                ("Invalid resource link name - already exists'" +
-                resourceLinkName + "'");
+            throw new IllegalArgumentException(
+                    "Invalid resource link name - already exists'" + resourceLinkName + "'");
         }
         resourceLink = new ContextResourceLink();
         resourceLink.setName(resourceLinkName);
@@ -258,9 +238,8 @@ public class NamingResourcesMBean extend
 
         // Return the corresponding MBean name
         ManagedBean managed = registry.findManagedBean("ContextResourceLink");
-        ObjectName oname =
-            MBeanUtils.createObjectName(managed.getDomain(), resourceLink);
-        return (oname.toString());
+        ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), resourceLink);
+        return oname.toString();
     }
 
 
@@ -270,18 +249,15 @@ public class NamingResourcesMBean extend
      * @param envName Name of the environment entry to remove
      */
     public void removeEnvironment(String envName) {
-
         NamingResourcesImpl nresources = (NamingResourcesImpl) this.resource;
         if (nresources == null) {
             return;
         }
         ContextEnvironment env = nresources.findEnvironment(envName);
         if (env == null) {
-            throw new IllegalArgumentException
-                ("Invalid environment name '" + envName + "'");
+            throw new IllegalArgumentException("Invalid environment name '" + envName + "'");
         }
         nresources.removeEnvironment(envName);
-
     }
 
 
@@ -291,7 +267,6 @@ public class NamingResourcesMBean extend
      * @param resourceName Name of the resource reference to remove
      */
     public void removeResource(String resourceName) {
-
         resourceName = ObjectName.unquote(resourceName);
         NamingResourcesImpl nresources = (NamingResourcesImpl) this.resource;
         if (nresources == null) {
@@ -299,11 +274,9 @@ public class NamingResourcesMBean extend
         }
         ContextResource resource = nresources.findResource(resourceName);
         if (resource == null) {
-            throw new IllegalArgumentException
-                ("Invalid resource name '" + resourceName + "'");
+            throw new IllegalArgumentException("Invalid resource name '" + resourceName + "'");
         }
         nresources.removeResource(resourceName);
-
     }
 
 
@@ -313,19 +286,16 @@ public class NamingResourcesMBean extend
      * @param resourceLinkName Name of the resource link reference to remove
      */
     public void removeResourceLink(String resourceLinkName) {
-
         resourceLinkName = ObjectName.unquote(resourceLinkName);
         NamingResourcesImpl nresources = (NamingResourcesImpl) this.resource;
         if (nresources == null) {
             return;
         }
-        ContextResourceLink resourceLink =
-                            nresources.findResourceLink(resourceLinkName);
+        ContextResourceLink resourceLink = nresources.findResourceLink(resourceLinkName);
         if (resourceLink == null) {
-            throw new IllegalArgumentException
-                ("Invalid resource Link name '" + resourceLinkName + "'");
+            throw new IllegalArgumentException(
+                    "Invalid resource Link name '" + resourceLinkName + "'");
         }
         nresources.removeResourceLink(resourceLinkName);
     }
-
 }

Modified: tomcat/trunk/java/org/apache/catalina/mbeans/RoleMBean.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/mbeans/RoleMBean.java?rev=1771377&r1=1771376&r2=1771377&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/mbeans/RoleMBean.java (original)
+++ tomcat/trunk/java/org/apache/catalina/mbeans/RoleMBean.java Fri Nov 25 20:40:04 2016
@@ -14,10 +14,8 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.catalina.mbeans;
 
-
 import javax.management.MBeanException;
 import javax.management.RuntimeOperationsException;
 
@@ -25,7 +23,6 @@ import org.apache.tomcat.util.modeler.Ba
 import org.apache.tomcat.util.modeler.ManagedBean;
 import org.apache.tomcat.util.modeler.Registry;
 
-
 /**
  * <p>A <strong>ModelMBean</strong> implementation for the
  * <code>org.apache.catalina.Role</code> component.</p>
@@ -34,10 +31,8 @@ import org.apache.tomcat.util.modeler.Re
  */
 public class RoleMBean extends BaseModelMBean {
 
-
     // ----------------------------------------------------------- Constructors
 
-
     /**
      * Construct a <code>ModelMBean</code> with default
      * <code>ModelMBeanInfo</code> information.
@@ -47,17 +42,13 @@ public class RoleMBean extends BaseModel
      * @exception RuntimeOperationsException if an IllegalArgumentException
      *  occurs
      */
-    public RoleMBean()
-        throws MBeanException, RuntimeOperationsException {
-
+    public RoleMBean() throws MBeanException, RuntimeOperationsException {
         super();
-
     }
 
 
     // ----------------------------------------------------- Instance Variables
 
-
     /**
      * The configuration information registry for our managed beans.
      */
@@ -68,12 +59,4 @@ public class RoleMBean extends BaseModel
      * The <code>ManagedBean</code> information describing this MBean.
      */
     protected final ManagedBean managed = registry.findManagedBean("Role");
-
-
-    // ------------------------------------------------------------- Attributes
-
-
-    // ------------------------------------------------------------- Operations
-
-
 }



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