This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 10.1.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit fa5e6972618c727c8f992db74c27d850172f4432 Author: Mark Thomas <ma...@apache.org> AuthorDate: Tue Sep 26 15:20:03 2023 +0100 Code clean-up - no functional change --- .../apache/catalina/mbeans/BaseCatalinaMBean.java | 3 +- .../org/apache/catalina/mbeans/ClassNameMBean.java | 17 +- .../org/apache/catalina/mbeans/ConnectorMBean.java | 46 ++- .../org/apache/catalina/mbeans/ContainerMBean.java | 57 ++-- .../catalina/mbeans/ContextEnvironmentMBean.java | 26 +- java/org/apache/catalina/mbeans/ContextMBean.java | 41 ++- .../catalina/mbeans/ContextResourceLinkMBean.java | 47 ++- .../catalina/mbeans/ContextResourceMBean.java | 57 ++-- .../mbeans/DataSourceUserDatabaseMBean.java | 34 +- .../mbeans/GlobalResourcesLifecycleListener.java | 30 +- java/org/apache/catalina/mbeans/GroupMBean.java | 5 +- java/org/apache/catalina/mbeans/MBeanDumper.java | 15 +- java/org/apache/catalina/mbeans/MBeanFactory.java | 250 +++++++-------- java/org/apache/catalina/mbeans/MBeanUtils.java | 350 +++++++++------------ .../catalina/mbeans/MemoryUserDatabaseMBean.java | 6 +- .../catalina/mbeans/NamingResourcesMBean.java | 72 +++-- java/org/apache/catalina/mbeans/RoleMBean.java | 5 +- java/org/apache/catalina/mbeans/ServiceMBean.java | 26 +- .../catalina/mbeans/SparseUserDatabaseMBean.java | 40 +-- java/org/apache/catalina/mbeans/UserMBean.java | 11 +- 20 files changed, 541 insertions(+), 597 deletions(-) diff --git a/java/org/apache/catalina/mbeans/BaseCatalinaMBean.java b/java/org/apache/catalina/mbeans/BaseCatalinaMBean.java index b483991a78..590c707f50 100644 --- a/java/org/apache/catalina/mbeans/BaseCatalinaMBean.java +++ b/java/org/apache/catalina/mbeans/BaseCatalinaMBean.java @@ -30,8 +30,7 @@ public abstract class BaseCatalinaMBean<T> extends BaseModelMBean { @SuppressWarnings("unchecked") T resource = (T) getManagedResource(); return resource; - } catch (InstanceNotFoundException | RuntimeOperationsException | - InvalidTargetObjectTypeException e) { + } catch (InstanceNotFoundException | RuntimeOperationsException | InvalidTargetObjectTypeException e) { throw new MBeanException(e); } } diff --git a/java/org/apache/catalina/mbeans/ClassNameMBean.java b/java/org/apache/catalina/mbeans/ClassNameMBean.java index 4d87b29539..bdf782086a 100644 --- a/java/org/apache/catalina/mbeans/ClassNameMBean.java +++ b/java/org/apache/catalina/mbeans/ClassNameMBean.java @@ -17,13 +17,13 @@ package org.apache.catalina.mbeans; /** - * <p>A convenience base class for <strong>ModelMBean</strong> implementations - * where the underlying base class (and therefore the set of supported - * properties) is different for varying implementations of a standard - * interface. For Catalina, that includes at least the following: - * Connector, Logger, Realm, and Valve. This class creates an artificial - * MBean attribute named <code>className</code>, which reports the fully - * qualified class name of the managed object as its value.</p> + * <p> + * A convenience base class for <strong>ModelMBean</strong> implementations where the underlying base class (and + * therefore the set of supported properties) is different for varying implementations of a standard interface. For + * Catalina, that includes at least the following: Connector, Logger, Realm, and Valve. This class creates an artificial + * MBean attribute named <code>className</code>, which reports the fully qualified class name of the managed object as + * its value. + * </p> * * @param <T> The type that this bean represents. * @@ -32,8 +32,7 @@ package org.apache.catalina.mbeans; public class ClassNameMBean<T> extends BaseCatalinaMBean<T> { /** - * Return the fully qualified Java class name of the managed object - * for this MBean. + * Return the fully qualified Java class name of the managed object for this MBean. */ @Override public String getClassName() { diff --git a/java/org/apache/catalina/mbeans/ConnectorMBean.java b/java/org/apache/catalina/mbeans/ConnectorMBean.java index 4b15bdf41f..7cd1a45e95 100644 --- a/java/org/apache/catalina/mbeans/ConnectorMBean.java +++ b/java/org/apache/catalina/mbeans/ConnectorMBean.java @@ -27,8 +27,10 @@ import org.apache.tomcat.util.IntrospectionUtils; import org.apache.tomcat.util.res.StringManager; /** - * <p>A <strong>ModelMBean</strong> implementation for the - * <code>org.apache.coyote.tomcat5.CoyoteConnector</code> component.</p> + * <p> + * A <strong>ModelMBean</strong> implementation for the <code>org.apache.coyote.tomcat5.CoyoteConnector</code> + * component. + * </p> * * @author Amy Roh */ @@ -41,21 +43,16 @@ public class ConnectorMBean extends ClassNameMBean<Connector> { * * @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 + * @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 { + public Object getAttribute(String name) throws AttributeNotFoundException, MBeanException, ReflectionException { // Validate the input parameters if (name == null) { - throw new RuntimeOperationsException( - new IllegalArgumentException(sm.getString("mBean.nullName")), + throw new RuntimeOperationsException(new IllegalArgumentException(sm.getString("mBean.nullName")), sm.getString("mBean.nullName")); } @@ -67,30 +64,25 @@ public class ConnectorMBean extends ClassNameMBean<Connector> { /** * Set the value of a specific attribute of this MBean. * - * @param attribute The identification of the attribute to be set - * and the new value + * @param attribute The identification of the attribute to be set and the new value * - * @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 + * @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 void setAttribute(Attribute attribute) throws AttributeNotFoundException, MBeanException, - ReflectionException { + @Override + public void setAttribute(Attribute attribute) + throws AttributeNotFoundException, MBeanException, ReflectionException { // Validate the input parameters if (attribute == null) { - throw new RuntimeOperationsException(new IllegalArgumentException( - sm.getString("mBean.nullAttribute")), sm.getString("mBean.nullAttribute")); + throw new RuntimeOperationsException(new IllegalArgumentException(sm.getString("mBean.nullAttribute")), + sm.getString("mBean.nullAttribute")); } String name = attribute.getName(); Object value = attribute.getValue(); if (name == null) { - throw new RuntimeOperationsException( - new IllegalArgumentException(sm.getString("mBean.nullName")), + throw new RuntimeOperationsException(new IllegalArgumentException(sm.getString("mBean.nullName")), sm.getString("mBean.nullName")); } diff --git a/java/org/apache/catalina/mbeans/ContainerMBean.java b/java/org/apache/catalina/mbeans/ContainerMBean.java index 434c09dd8b..3e08e41747 100644 --- a/java/org/apache/catalina/mbeans/ContainerMBean.java +++ b/java/org/apache/catalina/mbeans/ContainerMBean.java @@ -38,29 +38,28 @@ import org.apache.catalina.startup.HostConfig; public class ContainerMBean extends BaseCatalinaMBean<ContainerBase> { /** - * 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 - * Start method after necessary configurations are done. + * 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 Start method after necessary configurations are done. * * @param type ClassName of the child to be added * @param name Name of the child to be added * * @exception MBeanException if the child cannot be added */ - public void addChild(String type, String name) throws MBeanException{ + public void addChild(String type, String name) throws MBeanException { Container contained = (Container) newInstance(type); contained.setName(name); - if(contained instanceof StandardHost){ + if (contained instanceof StandardHost) { HostConfig config = new HostConfig(); contained.addLifecycleListener(config); - } else if(contained instanceof StandardContext){ + } else if (contained instanceof StandardContext) { ContextConfig config = new ContextConfig(); contained.addLifecycleListener(config); } - boolean oldValue= true; + boolean oldValue = true; ContainerBase container = doGetManagedResource(); try { @@ -68,10 +67,10 @@ public class ContainerMBean extends BaseCatalinaMBean<ContainerBase> { container.setStartChildren(false); container.addChild(contained); contained.init(); - } catch (LifecycleException e){ + } catch (LifecycleException e) { throw new MBeanException(e); } finally { - if(container != null) { + if (container != null) { container.setStartChildren(oldValue); } } @@ -79,13 +78,13 @@ public class ContainerMBean extends BaseCatalinaMBean<ContainerBase> { /** - * Remove an existing child Container from association with this parent - * Container. + * Remove an existing child Container from association with this parent Container. * * @param name Name of the existing child Container to be removed + * * @throws MBeanException if the child cannot be removed */ - public void removeChild(String name) throws MBeanException{ + public void removeChild(String name) throws MBeanException { if (name != null) { Container container = doGetManagedResource(); Container contained = container.findChild(name); @@ -98,17 +97,19 @@ public class ContainerMBean extends BaseCatalinaMBean<ContainerBase> { * Adds a valve to this Container instance. * * @param valveType ClassName of the valve to be added + * * @return the MBean name of the new valve + * * @throws MBeanException if adding the valve failed */ - public String addValve(String valveType) throws MBeanException{ + public String addValve(String valveType) throws MBeanException { Valve valve = (Valve) newInstance(valveType); Container container = doGetManagedResource(); container.getPipeline().addValve(valve); if (valve instanceof JmxEnabled) { - return ((JmxEnabled)valve).getObjectName().toString(); + return ((JmxEnabled) valve).getObjectName().toString(); } else { return null; } @@ -122,7 +123,7 @@ public class ContainerMBean extends BaseCatalinaMBean<ContainerBase> { * * @exception MBeanException if a component cannot be removed */ - public void removeValve(String valveName) throws MBeanException{ + public void removeValve(String valveName) throws MBeanException { Container container = doGetManagedResource(); ObjectName oname; @@ -150,9 +151,10 @@ public class ContainerMBean extends BaseCatalinaMBean<ContainerBase> { * Add a LifecycleEvent listener to this component. * * @param type ClassName of the listener to add + * * @throws MBeanException if adding the listener failed */ - public void addLifecycleListener(String type) throws MBeanException{ + public void addLifecycleListener(String type) throws MBeanException { LifecycleListener listener = (LifecycleListener) newInstance(type); Container container = doGetManagedResource(); container.addLifecycleListener(listener); @@ -162,15 +164,16 @@ public class ContainerMBean extends BaseCatalinaMBean<ContainerBase> { /** * Remove a LifecycleEvent listeners from this component. * - * @param type The ClassName of the listeners to be removed. - * Note that all the listeners having given ClassName will be removed. + * @param type The ClassName of the listeners to be removed. Note that all the listeners having given ClassName will + * be removed. + * * @throws MBeanException propagated from the managed resource access */ - public void removeLifecycleListeners(String type) throws MBeanException{ + public void removeLifecycleListeners(String type) throws MBeanException { Container container = doGetManagedResource(); LifecycleListener[] listeners = container.findLifecycleListeners(); - for (LifecycleListener listener : listeners){ + for (LifecycleListener listener : listeners) { if (listener.getClass().getName().equals(type)) { container.removeLifecycleListener(listener); } @@ -179,9 +182,10 @@ public class ContainerMBean extends BaseCatalinaMBean<ContainerBase> { /** - * List the class name of each of the lifecycle listeners added to this - * container. + * List the class name of each of the lifecycle listeners added to this container. + * * @return the lifecycle listeners class names + * * @throws MBeanException propagated from the managed resource access */ public String[] findLifecycleListenerNames() throws MBeanException { @@ -189,7 +193,7 @@ public class ContainerMBean extends BaseCatalinaMBean<ContainerBase> { List<String> result = new ArrayList<>(); LifecycleListener[] listeners = container.findLifecycleListeners(); - for(LifecycleListener listener: listeners){ + for (LifecycleListener listener : listeners) { result.add(listener.getClass().getName()); } @@ -198,9 +202,10 @@ public class ContainerMBean extends BaseCatalinaMBean<ContainerBase> { /** - * List the class name of each of the container listeners added to this - * container. + * List the class name of each of the container listeners added to this container. + * * @return the container listeners class names + * * @throws MBeanException propagated from the managed resource access */ public String[] findContainerListenerNames() throws MBeanException { @@ -208,7 +213,7 @@ public class ContainerMBean extends BaseCatalinaMBean<ContainerBase> { List<String> result = new ArrayList<>(); ContainerListener[] listeners = container.findContainerListeners(); - for(ContainerListener listener: listeners){ + for (ContainerListener listener : listeners) { result.add(listener.getClass().getName()); } diff --git a/java/org/apache/catalina/mbeans/ContextEnvironmentMBean.java b/java/org/apache/catalina/mbeans/ContextEnvironmentMBean.java index 8cfb95ccbb..797f0e9c0c 100644 --- a/java/org/apache/catalina/mbeans/ContextEnvironmentMBean.java +++ b/java/org/apache/catalina/mbeans/ContextEnvironmentMBean.java @@ -25,8 +25,10 @@ import org.apache.tomcat.util.descriptor.web.ContextEnvironment; import org.apache.tomcat.util.descriptor.web.NamingResources; /** - * <p>A <strong>ModelMBean</strong> implementation for the - * <code>org.apache.tomcat.util.descriptor.web.ContextEnvironment</code> component.</p> + * <p> + * A <strong>ModelMBean</strong> implementation for the + * <code>org.apache.tomcat.util.descriptor.web.ContextEnvironment</code> component. + * </p> * * @author Amy Roh */ @@ -36,25 +38,21 @@ public class ContextEnvironmentMBean extends BaseCatalinaMBean<ContextEnvironmen /** * Set the value of a specific attribute of this MBean. * - * @param attribute The identification of the attribute to be set - * and the new value + * @param attribute The identification of the attribute to be set and the new value * - * @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 + * @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 void setAttribute(Attribute attribute) throws AttributeNotFoundException, MBeanException, - ReflectionException { + @Override + public void setAttribute(Attribute attribute) + throws AttributeNotFoundException, MBeanException, ReflectionException { super.setAttribute(attribute); ContextEnvironment ce = doGetManagedResource(); - // cannot use side-effects. It's removed and added back each time + // cannot use side-effects. It's removed and added back each time // there is a modification in a resource. NamingResources nr = ce.getNamingResources(); nr.removeEnvironment(ce.getName()); diff --git a/java/org/apache/catalina/mbeans/ContextMBean.java b/java/org/apache/catalina/mbeans/ContextMBean.java index 7457f5d98f..2ee81ab931 100644 --- a/java/org/apache/catalina/mbeans/ContextMBean.java +++ b/java/org/apache/catalina/mbeans/ContextMBean.java @@ -27,9 +27,11 @@ import org.apache.tomcat.util.descriptor.web.SecurityConstraint; public class ContextMBean extends BaseCatalinaMBean<Context> { - /** + /** * Return the set of application parameters for this application. + * * @return a string array with a representation of each parameter + * * @throws MBeanException propagated from the managed resource access */ public String[] findApplicationParameters() throws MBeanException { @@ -39,7 +41,7 @@ public class ContextMBean extends BaseCatalinaMBean<Context> { ApplicationParameter[] params = context.findApplicationParameters(); String[] stringParams = new String[params.length]; for (int counter = 0; counter < params.length; counter++) { - stringParams[counter] = params[counter].toString(); + stringParams[counter] = params[counter].toString(); } return stringParams; @@ -47,10 +49,10 @@ public class ContextMBean extends BaseCatalinaMBean<Context> { /** - * Return the security constraints for this web application. - * If there are none, a zero-length array is returned. - * @return a string array with a representation of each - * security constraint + * Return the security constraints for this web application. If there are none, a zero-length array is returned. + * + * @return a string array with a representation of each security constraint + * * @throws MBeanException propagated from the managed resource access */ public String[] findConstraints() throws MBeanException { @@ -68,11 +70,12 @@ public class ContextMBean extends BaseCatalinaMBean<Context> { /** - * Return the error page entry for the specified HTTP error code, - * if any; otherwise return <code>null</code>. + * Return the error page entry for the specified HTTP error code, if any; otherwise return <code>null</code>. * * @param errorCode Error code to look up + * * @return a string representation of the error page + * * @throws MBeanException propagated from the managed resource access */ public String findErrorPage(int errorCode) throws MBeanException { @@ -87,11 +90,12 @@ public class ContextMBean extends BaseCatalinaMBean<Context> { /** - * Return the error page entry for the specified Java exception type, - * if any; otherwise return <code>null</code>. + * Return the error page entry for the specified Java exception type, if any; otherwise return <code>null</code>. * * @param exceptionType Exception type to look up + * * @return a string representation of the error page + * * @throws MBeanException propagated from the managed resource access */ public String findErrorPage(Throwable exceptionType) throws MBeanException { @@ -106,9 +110,10 @@ public class ContextMBean extends BaseCatalinaMBean<Context> { /** - * Return the set of defined error pages for all specified error codes - * and exception types. + * Return the set of defined error pages for all specified error codes and exception types. + * * @return a string array with a representation of each error page + * * @throws MBeanException propagated from the managed resource access */ public String[] findErrorPages() throws MBeanException { @@ -126,11 +131,12 @@ public class ContextMBean extends BaseCatalinaMBean<Context> { /** - * Return the filter definition for the specified filter name, if any; - * otherwise return <code>null</code>. + * Return the filter definition for the specified filter name, if any; otherwise return <code>null</code>. * * @param name Filter name to look up + * * @return a string representation of the filter definition + * * @throws MBeanException propagated from the managed resource access */ public String findFilterDef(String name) throws MBeanException { @@ -148,8 +154,9 @@ public class ContextMBean extends BaseCatalinaMBean<Context> { /** * Return the set of defined filters for this Context. - * @return a string array with a representation of all - * the filter definitions + * + * @return a string array with a representation of all the filter definitions + * * @throws MBeanException propagated from the managed resource access */ public String[] findFilterDefs() throws MBeanException { @@ -168,7 +175,9 @@ public class ContextMBean extends BaseCatalinaMBean<Context> { /** * Return the set of filter mappings for this Context. + * * @return a string array with a representation of all the filter mappings + * * @throws MBeanException propagated from the managed resource access */ public String[] findFilterMaps() throws MBeanException { diff --git a/java/org/apache/catalina/mbeans/ContextResourceLinkMBean.java b/java/org/apache/catalina/mbeans/ContextResourceLinkMBean.java index e8385da9c1..ae125c95a2 100644 --- a/java/org/apache/catalina/mbeans/ContextResourceLinkMBean.java +++ b/java/org/apache/catalina/mbeans/ContextResourceLinkMBean.java @@ -27,8 +27,10 @@ import org.apache.tomcat.util.descriptor.web.NamingResources; import org.apache.tomcat.util.res.StringManager; /** - * <p>A <strong>ModelMBean</strong> implementation for the - * <code>org.apache.tomcat.util.descriptor.web.ContextResourceLink</code> component.</p> + * <p> + * A <strong>ModelMBean</strong> implementation for the + * <code>org.apache.tomcat.util.descriptor.web.ContextResourceLink</code> component. + * </p> * * @author Amy Roh */ @@ -41,21 +43,16 @@ public class ContextResourceLinkMBean extends BaseCatalinaMBean<ContextResourceL * * @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 + * @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 { + public Object getAttribute(String name) throws AttributeNotFoundException, MBeanException, ReflectionException { // Validate the input parameters if (name == null) { - throw new RuntimeOperationsException( - new IllegalArgumentException(sm.getString("mBean.nullName")), + throw new RuntimeOperationsException(new IllegalArgumentException(sm.getString("mBean.nullName")), sm.getString("mBean.nullName")); } @@ -84,32 +81,26 @@ public class ContextResourceLinkMBean extends BaseCatalinaMBean<ContextResourceL /** * Set the value of a specific attribute of this MBean. * - * @param attribute The identification of the attribute to be set - * and the new value + * @param attribute The identification of the attribute to be set and the new value * - * @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 + * @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 void setAttribute(Attribute attribute) throws AttributeNotFoundException, MBeanException, - ReflectionException { + @Override + public void setAttribute(Attribute attribute) + throws AttributeNotFoundException, MBeanException, ReflectionException { // Validate the input parameters if (attribute == null) { - throw new RuntimeOperationsException( - new IllegalArgumentException(sm.getString("mBean.nullAttribute")), + throw new RuntimeOperationsException(new IllegalArgumentException(sm.getString("mBean.nullAttribute")), sm.getString("mBean.nullAttribute")); } String name = attribute.getName(); Object value = attribute.getValue(); if (name == null) { - throw new RuntimeOperationsException( - new IllegalArgumentException(sm.getString("mBean.nullName")), + throw new RuntimeOperationsException(new IllegalArgumentException(sm.getString("mBean.nullName")), sm.getString("mBean.nullName")); } @@ -127,7 +118,7 @@ public class ContextResourceLinkMBean extends BaseCatalinaMBean<ContextResourceL crl.setProperty(name, "" + value); } - // cannot use side-effects. It's removed and added back each time + // cannot use side-effects. It's removed and added back each time // there is a modification in a resource. NamingResources nr = crl.getNamingResources(); nr.removeResourceLink(crl.getName()); diff --git a/java/org/apache/catalina/mbeans/ContextResourceMBean.java b/java/org/apache/catalina/mbeans/ContextResourceMBean.java index f89f83ca72..bad2ec23cf 100644 --- a/java/org/apache/catalina/mbeans/ContextResourceMBean.java +++ b/java/org/apache/catalina/mbeans/ContextResourceMBean.java @@ -27,8 +27,10 @@ import org.apache.tomcat.util.descriptor.web.NamingResources; import org.apache.tomcat.util.res.StringManager; /** - * <p>A <strong>ModelMBean</strong> implementation for the - * <code>org.apache.tomcat.util.descriptor.web.ContextResource</code> component.</p> + * <p> + * A <strong>ModelMBean</strong> implementation for the + * <code>org.apache.tomcat.util.descriptor.web.ContextResource</code> component. + * </p> * * @author Amy Roh */ @@ -41,21 +43,16 @@ public class ContextResourceMBean extends BaseCatalinaMBean<ContextResource> { * * @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 + * @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 { + public Object getAttribute(String name) throws AttributeNotFoundException, MBeanException, ReflectionException { // Validate the input parameters if (name == null) { - throw new RuntimeOperationsException( - new IllegalArgumentException(sm.getString("mBean.nullName")), + throw new RuntimeOperationsException(new IllegalArgumentException(sm.getString("mBean.nullName")), sm.getString("mBean.nullName")); } @@ -86,51 +83,45 @@ public class ContextResourceMBean extends BaseCatalinaMBean<ContextResource> { /** * Set the value of a specific attribute of this MBean. * - * @param attribute The identification of the attribute to be set - * and the new value + * @param attribute The identification of the attribute to be set and the new value * - * @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 + * @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 void setAttribute(Attribute attribute) throws AttributeNotFoundException, MBeanException, - ReflectionException { + @Override + public void setAttribute(Attribute attribute) + throws AttributeNotFoundException, MBeanException, ReflectionException { // Validate the input parameters if (attribute == null) { - throw new RuntimeOperationsException( - new IllegalArgumentException(sm.getString("mBean.nullAttribute")), + throw new RuntimeOperationsException(new IllegalArgumentException(sm.getString("mBean.nullAttribute")), sm.getString("mBean.nullAttribute")); } String name = attribute.getName(); Object value = attribute.getValue(); if (name == null) { - throw new RuntimeOperationsException( - new IllegalArgumentException(sm.getString("mBean.nullName")), + throw new RuntimeOperationsException(new IllegalArgumentException(sm.getString("mBean.nullName")), sm.getString("mBean.nullName")); } ContextResource cr = doGetManagedResource(); if ("auth".equals(name)) { - cr.setAuth((String)value); + cr.setAuth((String) value); } else if ("description".equals(name)) { - cr.setDescription((String)value); + cr.setDescription((String) value); } else if ("name".equals(name)) { - cr.setName((String)value); + cr.setName((String) value); } else if ("scope".equals(name)) { - cr.setScope((String)value); + cr.setScope((String) value); } else if ("type".equals(name)) { - cr.setType((String)value); + cr.setType((String) value); } else { cr.setProperty(name, "" + value); } - // cannot use side-effects. It's removed and added back each time + // cannot use side-effects. It's removed and added back each time // there is a modification in a resource. NamingResources nr = cr.getNamingResources(); nr.removeResource(cr.getName()); diff --git a/java/org/apache/catalina/mbeans/DataSourceUserDatabaseMBean.java b/java/org/apache/catalina/mbeans/DataSourceUserDatabaseMBean.java index 86f78addb8..bfbe1cf48a 100644 --- a/java/org/apache/catalina/mbeans/DataSourceUserDatabaseMBean.java +++ b/java/org/apache/catalina/mbeans/DataSourceUserDatabaseMBean.java @@ -29,8 +29,10 @@ 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.users.DataSourceUserDatabase</code> component.</p> + * <p> + * A <strong>ModelMBean</strong> implementation for the <code>org.apache.catalina.users.DataSourceUserDatabase</code> + * component. + * </p> * * @author Craig R. McClanahan */ @@ -102,8 +104,9 @@ public class DataSourceUserDatabaseMBean extends BaseModelMBean { /** * Create a new Group and return the corresponding name. * - * @param groupname Group name of the new group + * @param groupname Group name of the new group * @param description Description of the new group + * * @return the new group name */ public String createGroup(String groupname, String description) { @@ -116,8 +119,9 @@ public class DataSourceUserDatabaseMBean extends BaseModelMBean { /** * Create a new Role and return the corresponding name. * - * @param rolename Group name of the new group + * @param rolename Group name of the new group * @param description Description of the new group + * * @return the new role name */ public String createRole(String rolename, String description) { @@ -133,6 +137,7 @@ public class DataSourceUserDatabaseMBean extends BaseModelMBean { * @param username User name of the new user * @param password Password for the new user * @param fullName Full name for the new user + * * @return the new user name */ public String createUser(String username, String password, String fullName) { @@ -189,6 +194,7 @@ public class DataSourceUserDatabaseMBean extends BaseModelMBean { /** * Change user credentials. + * * @param username The user name * @param password The new credentials */ @@ -203,6 +209,7 @@ public class DataSourceUserDatabaseMBean extends BaseModelMBean { /** * Add specified role to the user. + * * @param username The user name * @param rolename The role name */ @@ -218,6 +225,7 @@ public class DataSourceUserDatabaseMBean extends BaseModelMBean { /** * Remove specified role from the user. + * * @param username The user name * @param rolename The role name */ @@ -233,7 +241,9 @@ public class DataSourceUserDatabaseMBean extends BaseModelMBean { /** * Get roles for a user. + * * @param username The user name + * * @return Array of role names */ public String[] getUserRoles(String username) { @@ -255,7 +265,8 @@ public class DataSourceUserDatabaseMBean extends BaseModelMBean { /** * Add group to user. - * @param username The user name + * + * @param username The user name * @param groupname The group name */ public void addUserGroup(String username, String groupname) { @@ -270,7 +281,8 @@ public class DataSourceUserDatabaseMBean extends BaseModelMBean { /** * Remove group from user. - * @param username The user name + * + * @param username The user name * @param groupname The group name */ public void removeUserGroup(String username, String groupname) { @@ -285,7 +297,9 @@ public class DataSourceUserDatabaseMBean extends BaseModelMBean { /** * Get groups for a user. + * * @param username The user name + * * @return Array of group names */ public String[] getUserGroups(String username) { @@ -307,8 +321,9 @@ public class DataSourceUserDatabaseMBean extends BaseModelMBean { /** * Add role to a group. + * * @param groupname The group name - * @param rolename The role name + * @param rolename The role name */ public void addGroupRole(String groupname, String rolename) { UserDatabase database = (UserDatabase) this.resource; @@ -322,8 +337,9 @@ public class DataSourceUserDatabaseMBean extends BaseModelMBean { /** * Remove role from a group. + * * @param groupname The group name - * @param rolename The role name + * @param rolename The role name */ public void removeGroupRole(String groupname, String rolename) { UserDatabase database = (UserDatabase) this.resource; @@ -337,7 +353,9 @@ public class DataSourceUserDatabaseMBean extends BaseModelMBean { /** * Get roles for a group. + * * @param groupname The group name + * * @return Array of role names */ public String[] getGroupRoles(String groupname) { diff --git a/java/org/apache/catalina/mbeans/GlobalResourcesLifecycleListener.java b/java/org/apache/catalina/mbeans/GlobalResourcesLifecycleListener.java index 4f2f2dc2db..c688b6e515 100644 --- a/java/org/apache/catalina/mbeans/GlobalResourcesLifecycleListener.java +++ b/java/org/apache/catalina/mbeans/GlobalResourcesLifecycleListener.java @@ -40,13 +40,13 @@ import org.apache.tomcat.util.res.StringManager; /** - * Implementation of <code>LifecycleListener</code> that instantiates the - * set of MBeans associated with global JNDI resources that are subject to - * management. + * Implementation of <code>LifecycleListener</code> that instantiates the set of MBeans associated with global JNDI + * resources that are subject to management. * <p> * This listener must only be nested within {@link Server} elements. * * @author Craig R. McClanahan + * * @since 4.1 */ public class GlobalResourcesLifecycleListener implements LifecycleListener { @@ -75,8 +75,7 @@ public class GlobalResourcesLifecycleListener implements LifecycleListener { if (Lifecycle.START_EVENT.equals(event.getType())) { if (!(event.getLifecycle() instanceof Server)) { - log.warn(sm.getString("listener.notServer", - event.getLifecycle().getClass().getSimpleName())); + log.warn(sm.getString("listener.notServer", event.getLifecycle().getClass().getSimpleName())); } component = event.getLifecycle(); createMBeans(); @@ -112,10 +111,9 @@ public class GlobalResourcesLifecycleListener implements LifecycleListener { /** - * Create the MBeans for the interesting global JNDI resources in - * the specified naming context. + * Create the MBeans for the interesting global JNDI resources in the specified naming context. * - * @param prefix Prefix for complete object name paths + * @param prefix Prefix for complete object name paths * @param context Context to be scanned * * @exception NamingException if a JNDI exception occurs @@ -123,8 +121,7 @@ public class GlobalResourcesLifecycleListener implements LifecycleListener { protected void createMBeans(String prefix, Context context) throws NamingException { if (log.isDebugEnabled()) { - log.debug("Creating MBeans for Global JNDI Resources in Context '" + - prefix + "'"); + log.debug("Creating MBeans for Global JNDI Resources in Context '" + prefix + "'"); } try { @@ -157,7 +154,7 @@ public class GlobalResourcesLifecycleListener implements LifecycleListener { /** * Create the MBeans for the specified UserDatabase and its contents. * - * @param name Complete resource name of this UserDatabase + * @param name Complete resource name of this UserDatabase * @param database The UserDatabase to be processed * * @exception Exception if an exception occurs while creating MBeans @@ -171,7 +168,7 @@ public class GlobalResourcesLifecycleListener implements LifecycleListener { } try { MBeanUtils.createMBean(database); - } catch(Exception e) { + } catch (Exception e) { throw new IllegalArgumentException(sm.getString("globalResources.createError.userDatabase", name), e); } @@ -190,7 +187,8 @@ public class GlobalResourcesLifecycleListener implements LifecycleListener { try { MBeanUtils.createMBean(role); } catch (Exception e) { - throw new IllegalArgumentException(sm.getString("globalResources.createError.userDatabase.role", role), e); + throw new IllegalArgumentException(sm.getString("globalResources.createError.userDatabase.role", role), + e); } } @@ -204,7 +202,8 @@ public class GlobalResourcesLifecycleListener implements LifecycleListener { try { MBeanUtils.createMBean(group); } catch (Exception e) { - throw new IllegalArgumentException(sm.getString("globalResources.createError.userDatabase.group", group), e); + throw new IllegalArgumentException( + sm.getString("globalResources.createError.userDatabase.group", group), e); } } @@ -218,7 +217,8 @@ public class GlobalResourcesLifecycleListener implements LifecycleListener { try { MBeanUtils.createMBean(user); } catch (Exception e) { - throw new IllegalArgumentException(sm.getString("globalResources.createError.userDatabase.user", user), e); + throw new IllegalArgumentException(sm.getString("globalResources.createError.userDatabase.user", user), + e); } } } diff --git a/java/org/apache/catalina/mbeans/GroupMBean.java b/java/org/apache/catalina/mbeans/GroupMBean.java index 134e50de9c..f0a46018f0 100644 --- a/java/org/apache/catalina/mbeans/GroupMBean.java +++ b/java/org/apache/catalina/mbeans/GroupMBean.java @@ -32,8 +32,9 @@ import org.apache.tomcat.util.modeler.Registry; import org.apache.tomcat.util.res.StringManager; /** - * <p>A <strong>ModelMBean</strong> implementation for the - * <code>org.apache.catalina.Group</code> component.</p> + * <p> + * A <strong>ModelMBean</strong> implementation for the <code>org.apache.catalina.Group</code> component. + * </p> * * @author Craig R. McClanahan */ diff --git a/java/org/apache/catalina/mbeans/MBeanDumper.java b/java/org/apache/catalina/mbeans/MBeanDumper.java index 6c79f71603..289358d943 100644 --- a/java/org/apache/catalina/mbeans/MBeanDumper.java +++ b/java/org/apache/catalina/mbeans/MBeanDumper.java @@ -48,7 +48,8 @@ public class MBeanDumper { * The following code to dump MBeans has been copied from JMXProxyServlet. * * @param mbeanServer the MBean server - * @param names a set of object names for which to dump the info + * @param names a set of object names for which to dump the info + * * @return a string representation of the MBeans */ public static String dumpBeans(MBeanServer mbeanServer, Set<ObjectName> names) { @@ -80,8 +81,7 @@ public class MBeanDumper { if ("modelerType".equals(attName)) { continue; } - if (attName.indexOf('=') >= 0 || attName.indexOf(':') >= 0 - || attName.indexOf(' ') >= 0) { + if (attName.indexOf('=') >= 0 || attName.indexOf(':') >= 0 || attName.indexOf(' ') >= 0) { continue; } @@ -114,8 +114,8 @@ public class MBeanDumper { Class<?> c = value.getClass(); if (c.isArray()) { int len = Array.getLength(value); - StringBuilder sb = new StringBuilder("Array[" - + c.getComponentType().getName() + "] of length " + len); + StringBuilder sb = + new StringBuilder("Array[" + c.getComponentType().getName() + "] of length " + len); if (len > 0) { sb.append(CRLF); } @@ -130,9 +130,8 @@ public class MBeanDumper { } else if (TabularData.class.isInstance(value)) { TabularData tab = TabularData.class.cast(value); StringJoiner joiner = new StringJoiner(CRLF); - joiner.add( - "TabularData[" + tab.getTabularType().getRowType().getTypeName() - + "] of length " + tab.size()); + joiner.add("TabularData[" + tab.getTabularType().getRowType().getTypeName() + + "] of length " + tab.size()); for (Object item : tab.values()) { joiner.add(tableItemToString(item)); } diff --git a/java/org/apache/catalina/mbeans/MBeanFactory.java b/java/org/apache/catalina/mbeans/MBeanFactory.java index 1ddbcbb5be..0990c3ece6 100644 --- a/java/org/apache/catalina/mbeans/MBeanFactory.java +++ b/java/org/apache/catalina/mbeans/MBeanFactory.java @@ -76,6 +76,7 @@ public class MBeanFactory { /** * Set the container that this factory was created for. + * * @param container The associated container */ public void setContainer(Object container) { @@ -84,10 +85,10 @@ public class MBeanFactory { /** - * Little convenience method to remove redundant code - * when retrieving the path string + * Little convenience method to remove redundant code when retrieving the path string * * @param t path string + * * @return empty string if t==null || t.equals("/") */ private String getPathStr(String t) { @@ -97,22 +98,20 @@ public class MBeanFactory { return t; } - /** - * Get Parent Container to add its child component - * from parent's ObjectName + /** + * Get Parent Container to add its child component from parent's ObjectName */ - private Container getParentContainerFromParent(ObjectName pname) - throws Exception { + private Container getParentContainerFromParent(ObjectName pname) throws Exception { String type = pname.getKeyProperty("type"); String j2eeType = pname.getKeyProperty("j2eeType"); Service service = getService(pname); StandardEngine engine = (StandardEngine) service.getContainer(); - if ((j2eeType!=null) && (j2eeType.equals("WebModule"))) { + if ((j2eeType != null) && (j2eeType.equals("WebModule"))) { String name = pname.getKeyProperty("name"); name = name.substring(2); int i = name.indexOf('/'); - String hostName = name.substring(0,i); + String hostName = name.substring(0, i); String path = name.substring(i); Container host = engine.findChild(hostName); String pathStr = getPathStr(path); @@ -133,11 +132,9 @@ public class MBeanFactory { /** - * Get Parent ContainerBase to add its child component - * from child component's ObjectName as a String + * Get Parent ContainerBase to add its child component from child component's ObjectName as a String */ - private Container getParentContainerFromChild(ObjectName oname) - throws Exception { + private Container getParentContainerFromChild(ObjectName oname) throws Exception { String hostName = oname.getKeyProperty("host"); String path = oname.getKeyProperty("path"); @@ -170,7 +167,7 @@ public class MBeanFactory { StandardService service = null; String domain = oname.getDomain(); if (container instanceof Server) { - Service[] services = ((Server)container).findServices(); + Service[] services = ((Server) container).findServices(); for (Service value : services) { service = (StandardService) value; if (domain.equals(service.getObjectName().getDomain())) { @@ -178,8 +175,7 @@ public class MBeanFactory { } } } - if (service == null || - !service.getObjectName().getDomain().equals(domain)) { + if (service == null || !service.getObjectName().getDomain().equals(domain)) { throw new Exception(sm.getString("mBeanFactory.noService", domain)); } return service; @@ -190,15 +186,15 @@ public class MBeanFactory { /** * Create a new AjpConnector * - * @param parent MBean Name of the associated parent component + * @param parent MBean Name of the associated parent component * @param address The IP address on which to bind - * @param port TCP port number to listen on + * @param port TCP port number to listen on + * * @return the object name of the created connector * * @exception Exception if an MBean cannot be created or registered */ - public String createAjpConnector(String parent, String address, int port) - throws Exception { + public String createAjpConnector(String parent, String address, int port) throws Exception { return createConnector(parent, address, port, true, false); } @@ -207,19 +203,20 @@ public class MBeanFactory { /** * Create a new DataSource Realm. * - * @param parent MBean Name of the associated parent component + * @param parent MBean Name of the associated parent component * @param dataSourceName the datasource name - * @param roleNameCol the column name for the role names - * @param userCredCol the column name for the user credentials - * @param userNameCol the column name for the user names - * @param userRoleTable the table name for the roles table - * @param userTable the table name for the users + * @param roleNameCol the column name for the role names + * @param userCredCol the column name for the user credentials + * @param userNameCol the column name for the user names + * @param userRoleTable the table name for the roles table + * @param userTable the table name for the users + * * @return the object name of the created realm + * * @exception Exception if an MBean cannot be created or registered */ - public String createDataSourceRealm(String parent, String dataSourceName, - String roleNameCol, String userCredCol, String userNameCol, - String userRoleTable, String userTable) throws Exception { + public String createDataSourceRealm(String parent, String dataSourceName, String roleNameCol, String userCredCol, + String userNameCol, String userRoleTable, String userTable) throws Exception { // Create a new DataSourceRealm instance DataSourceRealm realm = new DataSourceRealm(); @@ -259,15 +256,15 @@ public class MBeanFactory { /** * Create a new HttpConnector * - * @param parent MBean Name of the associated parent component + * @param parent MBean Name of the associated parent component * @param address The IP address on which to bind - * @param port TCP port number to listen on + * @param port TCP port number to listen on + * * @return the object name of the created connector * * @exception Exception if an MBean cannot be created or registered */ - public String createHttpConnector(String parent, String address, int port) - throws Exception { + public String createHttpConnector(String parent, String address, int port) throws Exception { return createConnector(parent, address, port, false, false); } @@ -275,20 +272,20 @@ public class MBeanFactory { /** * Create a new Connector * - * @param parent MBean Name of the associated parent component + * @param parent MBean Name of the associated parent component * @param address The IP address on which to bind - * @param port TCP port number to listen on - * @param isAjp Create a AJP/1.3 Connector - * @param isSSL Create a secure Connector + * @param port TCP port number to listen on + * @param isAjp Create a AJP/1.3 Connector + * @param isSSL Create a secure Connector * * @exception Exception if an MBean cannot be created or registered */ private String createConnector(String parent, String address, int port, boolean isAjp, boolean isSSL) - throws Exception { + throws Exception { // Set the protocol in the constructor String protocol = isAjp ? "AJP/1.3" : "HTTP/1.1"; Connector retobj = new Connector(protocol); - if ((address!=null) && (address.length()>0)) { + if ((address != null) && (address.length() > 0)) { retobj.setProperty("address", address); } // Set port number @@ -312,15 +309,15 @@ public class MBeanFactory { /** * Create a new HttpsConnector * - * @param parent MBean Name of the associated parent component + * @param parent MBean Name of the associated parent component * @param address The IP address on which to bind - * @param port TCP port number to listen on + * @param port TCP port number to listen on + * * @return the object name of the created connector * * @exception Exception if an MBean cannot be created or registered */ - public String createHttpsConnector(String parent, String address, int port) - throws Exception { + public String createHttpsConnector(String parent, String address, int port) throws Exception { return createConnector(parent, address, port, false, true); } @@ -329,13 +326,14 @@ public class MBeanFactory { * Create a new JNDI Realm. * * @param parent MBean Name of the associated parent component + * * @return the object name of the created realm * * @exception Exception if an MBean cannot be created or registered */ public String createJNDIRealm(String parent) throws Exception { - // Create a new JNDIRealm instance + // Create a new JNDIRealm instance JNDIRealm realm = new JNDIRealm(); // Add the new instance to its parent component @@ -347,13 +345,14 @@ public class MBeanFactory { * Create a new Memory Realm. * * @param parent MBean Name of the associated parent component + * * @return the object name of the created realm * * @exception Exception if an MBean cannot be created or registered */ public String createMemoryRealm(String parent) throws Exception { - // Create a new MemoryRealm instance + // Create a new MemoryRealm instance MemoryRealm realm = new MemoryRealm(); // Add the new instance to its parent component @@ -361,20 +360,18 @@ public class MBeanFactory { } - /** + /** * Create a new StandardContext. * - * @param parent MBean Name of the associated parent component - * @param path The context path for this Context + * @param parent MBean Name of the associated parent component + * @param path The context path for this Context * @param docBase Document base directory (or WAR) for this Context + * * @return the object name of the created context * * @exception Exception if an MBean cannot be created or registered */ - public String createStandardContext(String parent, - String path, - String docBase) - throws Exception { + public String createStandardContext(String parent, String path, String docBase) throws Exception { return createStandardContext(parent, path, docBase, false, false); } @@ -383,21 +380,18 @@ public class MBeanFactory { /** * Create a new StandardContext. * - * @param parent MBean Name of the associated parent component - * @param path The context path for this Context - * @param docBase Document base directory (or WAR) for this Context - * @param xmlValidation if XML descriptors should be validated + * @param parent MBean Name of the associated parent component + * @param path The context path for this Context + * @param docBase Document base directory (or WAR) for this Context + * @param xmlValidation if XML descriptors should be validated * @param xmlNamespaceAware if the XML processor should namespace aware + * * @return the object name of the created context * * @exception Exception if an MBean cannot be created or registered */ - public String createStandardContext(String parent, - String path, - String docBase, - boolean xmlValidation, - boolean xmlNamespaceAware) - throws Exception { + public String createStandardContext(String parent, String path, String docBase, boolean xmlValidation, + boolean xmlNamespaceAware) throws Exception { // Create a new StandardContext instance StandardContext context = new StandardContext(); @@ -412,32 +406,28 @@ public class MBeanFactory { // Add the new instance to its parent component ObjectName pname = new ObjectName(parent); - ObjectName deployer = new ObjectName(pname.getDomain()+ - ":type=Deployer,host="+ - pname.getKeyProperty("host")); - if(mserver.isRegistered(deployer)) { + ObjectName deployer = new ObjectName(pname.getDomain() + ":type=Deployer,host=" + pname.getKeyProperty("host")); + if (mserver.isRegistered(deployer)) { String contextName = context.getName(); - Boolean result = (Boolean) mserver.invoke(deployer, "tryAddServiced", - new Object [] {contextName}, - new String [] {"java.lang.String"}); + Boolean result = (Boolean) mserver.invoke(deployer, "tryAddServiced", new Object[] { contextName }, + new String[] { "java.lang.String" }); if (result.booleanValue()) { try { - String configPath = (String)mserver.getAttribute(deployer, "configBaseName"); + String configPath = (String) mserver.getAttribute(deployer, "configBaseName"); String baseName = context.getBaseName(); - File configFile = new File(new File(configPath), baseName+".xml"); + File configFile = new File(new File(configPath), baseName + ".xml"); if (configFile.isFile()) { context.setConfigFile(configFile.toURI().toURL()); } - mserver.invoke(deployer, "manageApp", - new Object[] {context}, - new String[] {"org.apache.catalina.Context"}); + mserver.invoke(deployer, "manageApp", new Object[] { context }, + new String[] { "org.apache.catalina.Context" }); } finally { - mserver.invoke(deployer, "removeServiced", - new Object [] {contextName}, - new String [] {"java.lang.String"}); + mserver.invoke(deployer, "removeServiced", new Object[] { contextName }, + new String[] { "java.lang.String" }); } } else { - throw new IllegalStateException(sm.getString("mBeanFactory.contextCreate.addServicedFail", contextName)); + throw new IllegalStateException( + sm.getString("mBeanFactory.contextCreate.addServicedFail", contextName)); } } else { log.warn(sm.getString("mBeanFactory.noDeployer", pname.getKeyProperty("host"))); @@ -455,24 +445,20 @@ public class MBeanFactory { /** * Create a new StandardHost. * - * @param parent MBean Name of the associated parent component - * @param name Unique name of this Host - * @param appBase Application base directory name - * @param autoDeploy Should we auto deploy? + * @param parent MBean Name of the associated parent component + * @param name Unique name of this Host + * @param appBase Application base directory name + * @param autoDeploy Should we auto deploy? * @param deployOnStartup Deploy on server startup? - * @param deployXML Should we deploy Context XML config files property? - * @param unpackWARs Should we unpack WARs when auto deploying? + * @param deployXML Should we deploy Context XML config files property? + * @param unpackWARs Should we unpack WARs when auto deploying? + * * @return the object name of the created host * * @exception Exception if an MBean cannot be created or registered */ - public String createStandardHost(String parent, String name, - String appBase, - boolean autoDeploy, - boolean deployOnStartup, - boolean deployXML, - boolean unpackWARs) - throws Exception { + public String createStandardHost(String parent, String name, String appBase, boolean autoDeploy, + boolean deployOnStartup, boolean deployXML, boolean unpackWARs) throws Exception { // Create a new StandardHost instance StandardHost host = new StandardHost(); @@ -502,15 +488,15 @@ public class MBeanFactory { /** * Creates a new StandardService and StandardEngine. * - * @param domain Domain name for the container instance - * @param defaultHost Name of the default host to be used in the Engine - * @param baseDir Base directory value for Engine + * @param domain Domain name for the container instance + * @param defaultHost Name of the default host to be used in the Engine + * @param baseDir Base directory value for Engine + * * @return the object name of the created service * * @exception Exception if an MBean cannot be created or registered */ - public String createStandardServiceEngine(String domain, - String defaultHost, String baseDir) throws Exception{ + public String createStandardServiceEngine(String domain, String defaultHost, String baseDir) throws Exception { if (!(container instanceof Server)) { throw new Exception(sm.getString("mBeanFactory.notServer")); @@ -535,12 +521,12 @@ public class MBeanFactory { * Create a new StandardManager. * * @param parent MBean Name of the associated parent component + * * @return the object name of the created manager * * @exception Exception if an MBean cannot be created or registered */ - public String createStandardManager(String parent) - throws Exception { + public String createStandardManager(String parent) throws Exception { // Create a new StandardManager instance StandardManager manager = new StandardManager(); @@ -564,19 +550,18 @@ public class MBeanFactory { /** - * Create a new UserDatabaseRealm. + * Create a new UserDatabaseRealm. + * + * @param parent MBean Name of the associated parent component + * @param resourceName Global JNDI resource name of the associated UserDatabase * - * @param parent MBean Name of the associated parent component - * @param resourceName Global JNDI resource name of the associated - * UserDatabase * @return the object name of the created realm * * @exception Exception if an MBean cannot be created or registered */ - public String createUserDatabaseRealm(String parent, String resourceName) - throws Exception { + public String createUserDatabaseRealm(String parent, String resourceName) throws Exception { - // Create a new UserDatabaseRealm instance + // Create a new UserDatabaseRealm instance UserDatabaseRealm realm = new UserDatabaseRealm(); realm.setResourceName(resourceName); @@ -588,18 +573,15 @@ public class MBeanFactory { /** * Create a new Valve and associate it with a {@link Container}. * - * @param className The fully qualified class name of the {@link Valve} to - * create - * @param parent The MBean name of the associated parent - * {@link Container}. + * @param className The fully qualified class name of the {@link Valve} to create + * @param parent The MBean name of the associated parent {@link Container}. + * + * @return The MBean name of the {@link Valve} that was created or <code>null</code> if the {@link Valve} does not + * implement {@link JmxEnabled}. * - * @return The MBean name of the {@link Valve} that was created or - * <code>null</code> if the {@link Valve} does not implement - * {@link JmxEnabled}. * @exception Exception if an MBean cannot be created or registered */ - public String createValve(String className, String parent) - throws Exception { + public String createValve(String className, String parent) throws Exception { // Look for the parent ObjectName parentName = new ObjectName(parent); @@ -625,12 +607,12 @@ public class MBeanFactory { * Create a new Web Application Loader. * * @param parent MBean Name of the associated parent component + * * @return the object name of the created loader * * @exception Exception if an MBean cannot be created or registered */ - public String createWebappLoader(String parent) - throws Exception { + public String createWebappLoader(String parent) throws Exception { // Create a new WebappLoader instance WebappLoader loader = new WebappLoader(); @@ -642,9 +624,8 @@ public class MBeanFactory { ((Context) container).setLoader(loader); } // FIXME add Loader.getObjectName - //ObjectName oname = loader.getObjectName(); - ObjectName oname = - MBeanUtils.createObjectName(pname.getDomain(), loader); + // ObjectName oname = loader.getObjectName(); + ObjectName oname = MBeanUtils.createObjectName(pname.getDomain(), loader); return oname.toString(); } @@ -686,8 +667,7 @@ public class MBeanFactory { conn.destroy(); break; } - } - else if (address.equals(connAddress) && port.equals(connPort)) { + } else if (address.equals(connAddress) && port.equals(connPort)) { service.removeConnector(conn); conn.destroy(); break; @@ -714,24 +694,20 @@ public class MBeanFactory { String name = oname.getKeyProperty("name"); name = name.substring(2); int i = name.indexOf('/'); - String hostName = name.substring(0,i); + String hostName = name.substring(0, i); String path = name.substring(i); - ObjectName deployer = new ObjectName(domain+":type=Deployer,host="+ - hostName); + ObjectName deployer = new ObjectName(domain + ":type=Deployer,host=" + hostName); String pathStr = getPathStr(path); - if(mserver.isRegistered(deployer)) { - Boolean result = (Boolean) mserver.invoke(deployer,"tryAddServiced", - new Object[]{pathStr}, - new String[] {"java.lang.String"}); + if (mserver.isRegistered(deployer)) { + Boolean result = (Boolean) mserver.invoke(deployer, "tryAddServiced", new Object[] { pathStr }, + new String[] { "java.lang.String" }); if (result.booleanValue()) { try { - mserver.invoke(deployer,"unmanageApp", - new Object[] {pathStr}, - new String[] {"java.lang.String"}); + mserver.invoke(deployer, "unmanageApp", new Object[] { pathStr }, + new String[] { "java.lang.String" }); } finally { - mserver.invoke(deployer,"removeServiced", - new Object[] {pathStr}, - new String[] {"java.lang.String"}); + mserver.invoke(deployer, "removeServiced", new Object[] { pathStr }, + new String[] { "java.lang.String" }); } } else { throw new IllegalStateException(sm.getString("mBeanFactory.removeContext.addServicedFail", pathStr)); @@ -742,12 +718,12 @@ public class MBeanFactory { Context context = (Context) host.findChild(pathStr); // Remove this component from its parent component host.removeChild(context); - if(context instanceof StandardContext) { + if (context instanceof StandardContext) { try { context.destroy(); } catch (Exception e) { log.warn(sm.getString("mBeanFactory.contextDestroyError"), e); - } + } } } @@ -771,7 +747,7 @@ public class MBeanFactory { Host host = (Host) engine.findChild(hostName); // Remove this component from its parent component - if(host!=null) { + if (host != null) { engine.removeChild(host); } } diff --git a/java/org/apache/catalina/mbeans/MBeanUtils.java b/java/org/apache/catalina/mbeans/MBeanUtils.java index 2ea660393d..8914cb0b06 100644 --- a/java/org/apache/catalina/mbeans/MBeanUtils.java +++ b/java/org/apache/catalina/mbeans/MBeanUtils.java @@ -54,24 +54,13 @@ public class MBeanUtils { protected static final StringManager sm = StringManager.getManager(MBeanUtils.class); /** - * The set of exceptions to the normal rules used by - * <code>createManagedBean()</code>. The first element of each pair - * is a class name, and the second element is the managed bean name. + * The set of exceptions to the normal rules used by <code>createManagedBean()</code>. The first element of each + * pair is a class name, and the second element is the managed bean name. */ - private static final String exceptions[][] = { - { "org.apache.catalina.users.MemoryGroup", - "Group" }, - { "org.apache.catalina.users.MemoryRole", - "Role" }, - { "org.apache.catalina.users.MemoryUser", - "User" }, - { "org.apache.catalina.users.GenericGroup", - "Group" }, - { "org.apache.catalina.users.GenericRole", - "Role" }, - { "org.apache.catalina.users.GenericUser", - "User" } - }; + private static final String exceptions[][] = { { "org.apache.catalina.users.MemoryGroup", "Group" }, + { "org.apache.catalina.users.MemoryRole", "Role" }, { "org.apache.catalina.users.MemoryUser", "User" }, + { "org.apache.catalina.users.GenericGroup", "Group" }, { "org.apache.catalina.users.GenericRole", "Role" }, + { "org.apache.catalina.users.GenericUser", "User" } }; /** @@ -89,8 +78,7 @@ public class MBeanUtils { // --------------------------------------------------------- Static Methods /** - * Create and return the name of the <code>ManagedBean</code> that - * corresponds to this Catalina component. + * Create and return the name of the <code>ManagedBean</code> that corresponds to this Catalina component. * * @param component The component for which to create a name */ @@ -115,15 +103,15 @@ public class MBeanUtils { /** - * Create, register, and return an MBean for this - * <code>ContextEnvironment</code> object. + * Create, register, and return an MBean for this <code>ContextEnvironment</code> object. * * @param environment The ContextEnvironment to be managed + * * @return a new MBean + * * @exception Exception if an MBean cannot be created or registered */ - public static DynamicMBean createMBean(ContextEnvironment environment) - throws Exception { + public static DynamicMBean createMBean(ContextEnvironment environment) throws Exception { String mname = createManagedName(environment); ManagedBean managed = registry.findManagedBean(mname); @@ -137,7 +125,7 @@ public class MBeanUtils { } DynamicMBean mbean = managed.createMBean(environment); ObjectName oname = createObjectName(domain, environment); - if( mserver.isRegistered( oname )) { + if (mserver.isRegistered(oname)) { mserver.unregisterMBean(oname); } mserver.registerMBean(mbean, oname); @@ -147,15 +135,15 @@ public class MBeanUtils { /** - * Create, register, and return an MBean for this - * <code>ContextResource</code> object. + * Create, register, and return an MBean for this <code>ContextResource</code> object. * * @param resource The ContextResource to be managed + * * @return a new MBean + * * @exception Exception if an MBean cannot be created or registered */ - public static DynamicMBean createMBean(ContextResource resource) - throws Exception { + public static DynamicMBean createMBean(ContextResource resource) throws Exception { String mname = createManagedName(resource); ManagedBean managed = registry.findManagedBean(mname); @@ -169,7 +157,7 @@ public class MBeanUtils { } DynamicMBean mbean = managed.createMBean(resource); ObjectName oname = createObjectName(domain, resource); - if( mserver.isRegistered( oname )) { + if (mserver.isRegistered(oname)) { mserver.unregisterMBean(oname); } mserver.registerMBean(mbean, oname); @@ -179,15 +167,15 @@ public class MBeanUtils { /** - * Create, register, and return an MBean for this - * <code>ContextResourceLink</code> object. + * Create, register, and return an MBean for this <code>ContextResourceLink</code> object. * * @param resourceLink The ContextResourceLink to be managed + * * @return a new MBean + * * @exception Exception if an MBean cannot be created or registered */ - public static DynamicMBean createMBean(ContextResourceLink resourceLink) - throws Exception { + public static DynamicMBean createMBean(ContextResourceLink resourceLink) throws Exception { String mname = createManagedName(resourceLink); ManagedBean managed = registry.findManagedBean(mname); @@ -201,7 +189,7 @@ public class MBeanUtils { } DynamicMBean mbean = managed.createMBean(resourceLink); ObjectName oname = createObjectName(domain, resourceLink); - if( mserver.isRegistered( oname )) { + if (mserver.isRegistered(oname)) { mserver.unregisterMBean(oname); } mserver.registerMBean(mbean, oname); @@ -211,15 +199,15 @@ public class MBeanUtils { /** - * Create, register, and return an MBean for this - * <code>Group</code> object. + * Create, register, and return an MBean for this <code>Group</code> object. * * @param group The Group to be managed + * * @return a new MBean + * * @exception Exception if an MBean cannot be created or registered */ - static DynamicMBean createMBean(Group group) - throws Exception { + static DynamicMBean createMBean(Group group) throws Exception { String mname = createManagedName(group); ManagedBean managed = registry.findManagedBean(mname); @@ -233,7 +221,7 @@ public class MBeanUtils { } DynamicMBean mbean = managed.createMBean(group); ObjectName oname = createObjectName(domain, group); - if( mserver.isRegistered( oname )) { + if (mserver.isRegistered(oname)) { mserver.unregisterMBean(oname); } mserver.registerMBean(mbean, oname); @@ -243,15 +231,15 @@ public class MBeanUtils { /** - * Create, register, and return an MBean for this - * <code>Role</code> object. + * Create, register, and return an MBean for this <code>Role</code> object. * * @param role The Role to be managed + * * @return a new MBean + * * @exception Exception if an MBean cannot be created or registered */ - static DynamicMBean createMBean(Role role) - throws Exception { + static DynamicMBean createMBean(Role role) throws Exception { String mname = createManagedName(role); ManagedBean managed = registry.findManagedBean(mname); @@ -265,7 +253,7 @@ public class MBeanUtils { } DynamicMBean mbean = managed.createMBean(role); ObjectName oname = createObjectName(domain, role); - if( mserver.isRegistered( oname )) { + if (mserver.isRegistered(oname)) { mserver.unregisterMBean(oname); } mserver.registerMBean(mbean, oname); @@ -275,15 +263,15 @@ public class MBeanUtils { /** - * Create, register, and return an MBean for this - * <code>User</code> object. + * Create, register, and return an MBean for this <code>User</code> object. * * @param user The User to be managed + * * @return a new MBean + * * @exception Exception if an MBean cannot be created or registered */ - static DynamicMBean createMBean(User user) - throws Exception { + static DynamicMBean createMBean(User user) throws Exception { String mname = createManagedName(user); ManagedBean managed = registry.findManagedBean(mname); @@ -297,7 +285,7 @@ public class MBeanUtils { } DynamicMBean mbean = managed.createMBean(user); ObjectName oname = createObjectName(domain, user); - if( mserver.isRegistered( oname )) { + if (mserver.isRegistered(oname)) { mserver.unregisterMBean(oname); } mserver.registerMBean(mbean, oname); @@ -307,15 +295,15 @@ public class MBeanUtils { /** - * Create, register, and return an MBean for this - * <code>UserDatabase</code> object. + * Create, register, and return an MBean for this <code>UserDatabase</code> object. * * @param userDatabase The UserDatabase to be managed + * * @return a new MBean + * * @exception Exception if an MBean cannot be created or registered */ - static DynamicMBean createMBean(UserDatabase userDatabase) - throws Exception { + static DynamicMBean createMBean(UserDatabase userDatabase) throws Exception { if (userDatabase.isSparse()) { // Register a sparse database bean as well @@ -330,7 +318,7 @@ public class MBeanUtils { } DynamicMBean mbean = managed.createMBean(userDatabase); ObjectName oname = createObjectName(domain, userDatabase); - if( mserver.isRegistered( oname )) { + if (mserver.isRegistered(oname)) { mserver.unregisterMBean(oname); } mserver.registerMBean(mbean, oname); @@ -348,7 +336,7 @@ public class MBeanUtils { } DynamicMBean mbean = managed.createMBean(userDatabase); ObjectName oname = createObjectName(domain, userDatabase); - if( mserver.isRegistered( oname )) { + if (mserver.isRegistered(oname)) { mserver.unregisterMBean(oname); } mserver.registerMBean(mbean, oname); @@ -358,32 +346,28 @@ public class MBeanUtils { /** - * Create an <code>ObjectName</code> for this - * <code>Service</code> object. + * Create an <code>ObjectName</code> for this <code>Service</code> object. * - * @param domain Domain in which this name is to be created + * @param domain Domain in which this name is to be created * @param environment The ContextEnvironment to be named + * * @return a new object name + * * @exception MalformedObjectNameException if a name cannot be created */ - public static ObjectName createObjectName(String domain, - ContextEnvironment environment) - throws MalformedObjectNameException { + public static ObjectName createObjectName(String domain, ContextEnvironment environment) + throws MalformedObjectNameException { ObjectName name = null; - Object container = - environment.getNamingResources().getContainer(); + Object container = environment.getNamingResources().getContainer(); if (container instanceof Server) { - name = new ObjectName(domain + ":type=Environment" + - ",resourcetype=Global,name=" + environment.getName()); + name = new ObjectName(domain + ":type=Environment" + ",resourcetype=Global,name=" + environment.getName()); } else if (container instanceof Context) { - Context context = ((Context)container); + Context context = ((Context) container); ContextName cn = new ContextName(context.getName(), false); Container host = context.getParent(); - name = new ObjectName(domain + ":type=Environment" + - ",resourcetype=Context,host=" + host.getName() + - ",context=" + cn.getDisplayName() + - ",name=" + environment.getName()); + name = new ObjectName(domain + ":type=Environment" + ",resourcetype=Context,host=" + host.getName() + + ",context=" + cn.getDisplayName() + ",name=" + environment.getName()); } return name; @@ -391,35 +375,30 @@ public class MBeanUtils { /** - * Create an <code>ObjectName</code> for this - * <code>ContextResource</code> object. + * Create an <code>ObjectName</code> for this <code>ContextResource</code> object. * - * @param domain Domain in which this name is to be created + * @param domain Domain in which this name is to be created * @param resource The ContextResource to be named + * * @return a new object name + * * @exception MalformedObjectNameException if a name cannot be created */ - public static ObjectName createObjectName(String domain, - ContextResource resource) - throws MalformedObjectNameException { + public static ObjectName createObjectName(String domain, ContextResource resource) + throws MalformedObjectNameException { ObjectName name = null; String quotedResourceName = ObjectName.quote(resource.getName()); - Object container = - resource.getNamingResources().getContainer(); + Object container = resource.getNamingResources().getContainer(); if (container instanceof Server) { - name = new ObjectName(domain + ":type=Resource" + - ",resourcetype=Global,class=" + resource.getType() + + name = new ObjectName(domain + ":type=Resource" + ",resourcetype=Global,class=" + resource.getType() + ",name=" + quotedResourceName); } else if (container instanceof Context) { - Context context = ((Context)container); + Context context = ((Context) container); ContextName cn = new ContextName(context.getName(), false); Container host = context.getParent(); - name = new ObjectName(domain + ":type=Resource" + - ",resourcetype=Context,host=" + host.getName() + - ",context=" + cn.getDisplayName() + - ",class=" + resource.getType() + - ",name=" + quotedResourceName); + name = new ObjectName(domain + ":type=Resource" + ",resourcetype=Context,host=" + host.getName() + + ",context=" + cn.getDisplayName() + ",class=" + resource.getType() + ",name=" + quotedResourceName); } return name; @@ -427,36 +406,31 @@ public class MBeanUtils { } - /** - * Create an <code>ObjectName</code> for this - * <code>ContextResourceLink</code> object. + /** + * Create an <code>ObjectName</code> for this <code>ContextResourceLink</code> object. * - * @param domain Domain in which this name is to be created + * @param domain Domain in which this name is to be created * @param resourceLink The ContextResourceLink to be named + * * @return a new object name + * * @exception MalformedObjectNameException if a name cannot be created */ - public static ObjectName createObjectName(String domain, - ContextResourceLink resourceLink) - throws MalformedObjectNameException { + public static ObjectName createObjectName(String domain, ContextResourceLink resourceLink) + throws MalformedObjectNameException { ObjectName name = null; - String quotedResourceLinkName - = ObjectName.quote(resourceLink.getName()); - Object container = - resourceLink.getNamingResources().getContainer(); + String quotedResourceLinkName = ObjectName.quote(resourceLink.getName()); + Object container = resourceLink.getNamingResources().getContainer(); if (container instanceof Server) { - name = new ObjectName(domain + ":type=ResourceLink" + - ",resourcetype=Global" + - ",name=" + quotedResourceLinkName); + name = new ObjectName( + domain + ":type=ResourceLink" + ",resourcetype=Global" + ",name=" + quotedResourceLinkName); } else if (container instanceof Context) { - Context context = ((Context)container); + Context context = ((Context) container); ContextName cn = new ContextName(context.getName(), false); Container host = context.getParent(); - name = new ObjectName(domain + ":type=ResourceLink" + - ",resourcetype=Context,host=" + host.getName() + - ",context=" + cn.getDisplayName() + - ",name=" + quotedResourceLinkName); + name = new ObjectName(domain + ":type=ResourceLink" + ",resourcetype=Context,host=" + host.getName() + + ",context=" + cn.getDisplayName() + ",name=" + quotedResourceLinkName); } return name; @@ -465,112 +439,105 @@ public class MBeanUtils { /** - * Create an <code>ObjectName</code> for this - * <code>Group</code> object. + * Create an <code>ObjectName</code> for this <code>Group</code> object. * * @param domain Domain in which this name is to be created - * @param group The Group to be named + * @param group The Group to be named + * * @return a new object name + * * @exception MalformedObjectNameException if a name cannot be created */ - static ObjectName createObjectName(String domain, - Group group) - throws MalformedObjectNameException { + static ObjectName createObjectName(String domain, Group group) throws MalformedObjectNameException { ObjectName name = null; - name = new ObjectName(domain + ":type=Group,groupname=" + - ObjectName.quote(group.getGroupname()) + - ",database=" + group.getUserDatabase().getId()); + name = new ObjectName(domain + ":type=Group,groupname=" + ObjectName.quote(group.getGroupname()) + + ",database=" + group.getUserDatabase().getId()); return name; } /** - * Create an <code>ObjectName</code> for this - * <code>Loader</code> object. + * Create an <code>ObjectName</code> for this <code>Loader</code> object. * * @param domain Domain in which this name is to be created * @param loader The Loader to be named + * * @return a new object name + * * @exception MalformedObjectNameException if a name cannot be created */ - static ObjectName createObjectName(String domain, Loader loader) - throws MalformedObjectNameException { + static ObjectName createObjectName(String domain, Loader loader) throws MalformedObjectNameException { ObjectName name = null; Context context = loader.getContext(); ContextName cn = new ContextName(context.getName(), false); Container host = context.getParent(); - name = new ObjectName(domain + ":type=Loader,host=" + host.getName() + - ",context=" + cn.getDisplayName()); + name = new ObjectName(domain + ":type=Loader,host=" + host.getName() + ",context=" + cn.getDisplayName()); return name; } /** - * Create an <code>ObjectName</code> for this - * <code>Role</code> object. + * Create an <code>ObjectName</code> for this <code>Role</code> object. * * @param domain Domain in which this name is to be created - * @param role The Role to be named + * @param role The Role to be named + * * @return a new object name + * * @exception MalformedObjectNameException if a name cannot be created */ - static ObjectName createObjectName(String domain, Role role) - throws MalformedObjectNameException { + static ObjectName createObjectName(String domain, Role role) throws MalformedObjectNameException { - ObjectName name = new ObjectName(domain + ":type=Role,rolename=" + - ObjectName.quote(role.getRolename()) + - ",database=" + role.getUserDatabase().getId()); + ObjectName name = new ObjectName(domain + ":type=Role,rolename=" + ObjectName.quote(role.getRolename()) + + ",database=" + role.getUserDatabase().getId()); return name; } /** - * Create an <code>ObjectName</code> for this - * <code>User</code> object. + * Create an <code>ObjectName</code> for this <code>User</code> object. * * @param domain Domain in which this name is to be created - * @param user The User to be named + * @param user The User to be named + * * @return a new object name + * * @exception MalformedObjectNameException if a name cannot be created */ - static ObjectName createObjectName(String domain, User user) - throws MalformedObjectNameException { + static ObjectName createObjectName(String domain, User user) throws MalformedObjectNameException { - ObjectName name = new ObjectName(domain + ":type=User,username=" + - ObjectName.quote(user.getUsername()) + + ObjectName name = new ObjectName(domain + ":type=User,username=" + ObjectName.quote(user.getUsername()) + ",database=" + user.getUserDatabase().getId()); return name; } /** - * Create an <code>ObjectName</code> for this - * <code>UserDatabase</code> object. + * Create an <code>ObjectName</code> for this <code>UserDatabase</code> object. * - * @param domain Domain in which this name is to be created + * @param domain Domain in which this name is to be created * @param userDatabase The UserDatabase to be named + * * @return a new object name + * * @exception MalformedObjectNameException if a name cannot be created */ - static ObjectName createObjectName(String domain, - UserDatabase userDatabase) - throws MalformedObjectNameException { + static ObjectName createObjectName(String domain, UserDatabase userDatabase) throws MalformedObjectNameException { ObjectName name = null; - name = new ObjectName(domain + ":type=UserDatabase,database=" + - userDatabase.getId()); + name = new ObjectName(domain + ":type=UserDatabase,database=" + userDatabase.getId()); return name; } /** - * Create and configure (if necessary) and return the registry of - * managed object descriptions. + * Create and configure (if necessary) and return the registry of managed object descriptions. + * * @return the singleton registry */ public static synchronized Registry createRegistry() { @@ -578,7 +545,7 @@ public class MBeanUtils { registry = Registry.getRegistry(null, null); ClassLoader cl = MBeanUtils.class.getClassLoader(); - registry.loadDescriptors("org.apache.catalina.mbeans", cl); + registry.loadDescriptors("org.apache.catalina.mbeans", cl); registry.loadDescriptors("org.apache.catalina.authenticator", cl); registry.loadDescriptors("org.apache.catalina.core", cl); registry.loadDescriptors("org.apache.catalina", cl); @@ -590,18 +557,18 @@ public class MBeanUtils { registry.loadDescriptors("org.apache.catalina.users", cl); registry.loadDescriptors("org.apache.catalina.ha", cl); registry.loadDescriptors("org.apache.catalina.connector", cl); - registry.loadDescriptors("org.apache.catalina.valves", cl); - registry.loadDescriptors("org.apache.catalina.storeconfig", cl); - registry.loadDescriptors("org.apache.tomcat.util.descriptor.web", cl); + registry.loadDescriptors("org.apache.catalina.valves", cl); + registry.loadDescriptors("org.apache.catalina.storeconfig", cl); + registry.loadDescriptors("org.apache.tomcat.util.descriptor.web", cl); } return registry; } /** - * Create and configure (if necessary) and return the - * <code>MBeanServer</code> with which we will be - * registering our <code>DynamicMBean</code> implementations. + * Create and configure (if necessary) and return the <code>MBeanServer</code> with which we will be registering our + * <code>DynamicMBean</code> implementations. + * * @return the singleton MBean server */ public static synchronized MBeanServer createServer() { @@ -613,15 +580,13 @@ public class MBeanUtils { /** - * Deregister the MBean for this - * <code>ContextEnvironment</code> object. + * Deregister the MBean for this <code>ContextEnvironment</code> object. * * @param environment The ContextEnvironment to be managed * * @exception Exception if an MBean cannot be deregistered */ - public static void destroyMBean(ContextEnvironment environment) - throws Exception { + public static void destroyMBean(ContextEnvironment environment) throws Exception { String mname = createManagedName(environment); ManagedBean managed = registry.findManagedBean(mname); @@ -633,7 +598,7 @@ public class MBeanUtils { domain = mserver.getDefaultDomain(); } ObjectName oname = createObjectName(domain, environment); - if( mserver.isRegistered(oname) ) { + if (mserver.isRegistered(oname)) { mserver.unregisterMBean(oname); } @@ -641,15 +606,13 @@ public class MBeanUtils { /** - * Deregister the MBean for this - * <code>ContextResource</code> object. + * Deregister the MBean for this <code>ContextResource</code> object. * * @param resource The ContextResource to be managed * * @exception Exception if an MBean cannot be deregistered */ - public static void destroyMBean(ContextResource resource) - throws Exception { + public static void destroyMBean(ContextResource resource) throws Exception { // If this is a user database resource need to destroy groups, roles, // users and UserDatabase mbean @@ -667,7 +630,7 @@ public class MBeanUtils { domain = mserver.getDefaultDomain(); } ObjectName oname = createObjectName(domain, resource); - if( mserver.isRegistered(oname )) { + if (mserver.isRegistered(oname)) { mserver.unregisterMBean(oname); } @@ -675,15 +638,13 @@ public class MBeanUtils { /** - * Deregister the MBean for this - * <code>ContextResourceLink</code> object. + * Deregister the MBean for this <code>ContextResourceLink</code> object. * * @param resourceLink The ContextResourceLink to be managed * * @exception Exception if an MBean cannot be deregistered */ - public static void destroyMBean(ContextResourceLink resourceLink) - throws Exception { + public static void destroyMBean(ContextResourceLink resourceLink) throws Exception { String mname = createManagedName(resourceLink); ManagedBean managed = registry.findManagedBean(mname); @@ -695,22 +656,20 @@ public class MBeanUtils { domain = mserver.getDefaultDomain(); } ObjectName oname = createObjectName(domain, resourceLink); - if( mserver.isRegistered(oname) ) { + if (mserver.isRegistered(oname)) { mserver.unregisterMBean(oname); } } /** - * Deregister the MBean for this - * <code>Group</code> object. + * Deregister the MBean for this <code>Group</code> object. * * @param group The Group to be managed * * @exception Exception if an MBean cannot be deregistered */ - static void destroyMBean(Group group) - throws Exception { + static void destroyMBean(Group group) throws Exception { String mname = createManagedName(group); ManagedBean managed = registry.findManagedBean(mname); @@ -722,7 +681,7 @@ public class MBeanUtils { domain = mserver.getDefaultDomain(); } ObjectName oname = createObjectName(domain, group); - if( mserver.isRegistered(oname) ) { + if (mserver.isRegistered(oname)) { mserver.unregisterMBean(oname); } @@ -730,15 +689,13 @@ public class MBeanUtils { /** - * Deregister the MBean for this - * <code>Role</code> object. + * Deregister the MBean for this <code>Role</code> object. * * @param role The Role to be managed * * @exception Exception if an MBean cannot be deregistered */ - static void destroyMBean(Role role) - throws Exception { + static void destroyMBean(Role role) throws Exception { String mname = createManagedName(role); ManagedBean managed = registry.findManagedBean(mname); @@ -750,7 +707,7 @@ public class MBeanUtils { domain = mserver.getDefaultDomain(); } ObjectName oname = createObjectName(domain, role); - if( mserver.isRegistered(oname) ) { + if (mserver.isRegistered(oname)) { mserver.unregisterMBean(oname); } @@ -758,15 +715,13 @@ public class MBeanUtils { /** - * Deregister the MBean for this - * <code>User</code> object. + * Deregister the MBean for this <code>User</code> object. * * @param user The User to be managed * * @exception Exception if an MBean cannot be deregistered */ - static void destroyMBean(User user) - throws Exception { + static void destroyMBean(User user) throws Exception { String mname = createManagedName(user); ManagedBean managed = registry.findManagedBean(mname); @@ -778,7 +733,7 @@ public class MBeanUtils { domain = mserver.getDefaultDomain(); } ObjectName oname = createObjectName(domain, user); - if( mserver.isRegistered(oname) ) { + if (mserver.isRegistered(oname)) { mserver.unregisterMBean(oname); } @@ -786,52 +741,45 @@ public class MBeanUtils { /** - * Deregister the MBean for the - * <code>UserDatabase</code> object with this name. + * Deregister the MBean for the <code>UserDatabase</code> object with this name. * * @param userDatabase The UserDatabase to be managed * * @exception Exception if an MBean cannot be deregistered */ - static void destroyMBeanUserDatabase(String userDatabase) - throws Exception { + static void destroyMBeanUserDatabase(String userDatabase) throws Exception { ObjectName query = null; Set<ObjectName> results = null; // Groups - query = new ObjectName( - "Users:type=Group,database=" + userDatabase + ",*"); + query = new ObjectName("Users:type=Group,database=" + userDatabase + ",*"); results = mserver.queryNames(query, null); - for(ObjectName result : results) { + for (ObjectName result : results) { mserver.unregisterMBean(result); } // Roles - query = new ObjectName( - "Users:type=Role,database=" + userDatabase + ",*"); + query = new ObjectName("Users:type=Role,database=" + userDatabase + ",*"); results = mserver.queryNames(query, null); - for(ObjectName result : results) { + for (ObjectName result : results) { mserver.unregisterMBean(result); } // Users - query = new ObjectName( - "Users:type=User,database=" + userDatabase + ",*"); + query = new ObjectName("Users:type=User,database=" + userDatabase + ",*"); results = mserver.queryNames(query, null); - for(ObjectName result : results) { + for (ObjectName result : results) { mserver.unregisterMBean(result); } // The database itself - ObjectName db = new ObjectName( - "Users:type=UserDatabase,database=" + userDatabase); - if( mserver.isRegistered(db) ) { + ObjectName db = new ObjectName("Users:type=UserDatabase,database=" + userDatabase); + if (mserver.isRegistered(db)) { mserver.unregisterMBean(db); } - db = new ObjectName( - "Catalina:type=UserDatabase,database=" + userDatabase); - if( mserver.isRegistered(db) ) { + db = new ObjectName("Catalina:type=UserDatabase,database=" + userDatabase); + if (mserver.isRegistered(db)) { mserver.unregisterMBean(db); } } diff --git a/java/org/apache/catalina/mbeans/MemoryUserDatabaseMBean.java b/java/org/apache/catalina/mbeans/MemoryUserDatabaseMBean.java index 7105cf84df..950a56741b 100644 --- a/java/org/apache/catalina/mbeans/MemoryUserDatabaseMBean.java +++ b/java/org/apache/catalina/mbeans/MemoryUserDatabaseMBean.java @@ -19,8 +19,10 @@ package org.apache.catalina.mbeans; import org.apache.tomcat.util.modeler.ManagedBean; /** - * <p>A <strong>ModelMBean</strong> implementation for the - * <code>org.apache.catalina.users.MemoryUserDatabase</code> component.</p> + * <p> + * A <strong>ModelMBean</strong> implementation for the <code>org.apache.catalina.users.MemoryUserDatabase</code> + * component. + * </p> * * @author Craig R. McClanahan */ diff --git a/java/org/apache/catalina/mbeans/NamingResourcesMBean.java b/java/org/apache/catalina/mbeans/NamingResourcesMBean.java index efd840c0e7..0a5c231fb9 100644 --- a/java/org/apache/catalina/mbeans/NamingResourcesMBean.java +++ b/java/org/apache/catalina/mbeans/NamingResourcesMBean.java @@ -32,8 +32,10 @@ import org.apache.tomcat.util.modeler.Registry; import org.apache.tomcat.util.res.StringManager; /** - * <p>A <strong>ModelMBean</strong> implementation for the - * <code>org.apache.catalina.deploy.NamingResourcesImpl</code> component.</p> + * <p> + * A <strong>ModelMBean</strong> implementation for the <code>org.apache.catalina.deploy.NamingResourcesImpl</code> + * component. + * </p> * * @author Amy Roh */ @@ -58,12 +60,12 @@ public class NamingResourcesMBean extends BaseModelMBean { // ------------------------------------------------------------- Attributes /** - * Return the MBean Names of the set of defined environment entries for - * this web application + * Return the MBean Names of the set of defined environment entries for this web application + * * @return an array of object names as strings */ public String[] getEnvironments() { - ContextEnvironment[] envs = ((NamingResourcesImpl)this.resource).findEnvironments(); + ContextEnvironment[] envs = ((NamingResourcesImpl) this.resource).findEnvironments(); List<String> results = new ArrayList<>(); for (ContextEnvironment env : envs) { try { @@ -79,12 +81,12 @@ public class NamingResourcesMBean extends BaseModelMBean { /** - * Return the MBean Names of all the defined resource references for this - * application. + * Return the MBean Names of all the defined resource references for this application. + * * @return an array of object names as strings */ public String[] getResources() { - ContextResource[] resources = ((NamingResourcesImpl)this.resource).findResources(); + ContextResource[] resources = ((NamingResourcesImpl) this.resource).findResources(); List<String> results = new ArrayList<>(); for (ContextResource contextResource : resources) { try { @@ -100,18 +102,16 @@ public class NamingResourcesMBean extends BaseModelMBean { /** - * Return the MBean Names of all the defined resource link references for - * this application. + * Return the MBean Names of all the defined resource link references for this application. + * * @return an array of object names as strings */ public String[] getResourceLinks() { - ContextResourceLink[] resourceLinks = - ((NamingResourcesImpl)this.resource).findResourceLinks(); + ContextResourceLink[] resourceLinks = ((NamingResourcesImpl) this.resource).findResourceLinks(); List<String> results = new ArrayList<>(); for (ContextResourceLink resourceLink : resourceLinks) { try { - ObjectName oname = - MBeanUtils.createObjectName(managed.getDomain(), resourceLink); + ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), resourceLink); results.add(oname.toString()); } catch (MalformedObjectNameException e) { throw new IllegalArgumentException( @@ -128,13 +128,14 @@ public class NamingResourcesMBean extends BaseModelMBean { * Add an environment entry for this web application. * * @param envName New environment entry name - * @param type The type of the new environment entry - * @param value The value of the new environment entry + * @param type The type of the new environment entry + * @param value The value of the new environment entry + * * @return the object name of the new environment entry + * * @throws MalformedObjectNameException if the object name was invalid */ - public String addEnvironment(String envName, String type, String value) - throws MalformedObjectNameException { + public String addEnvironment(String envName, String type, String value) throws MalformedObjectNameException { NamingResourcesImpl nresources = (NamingResourcesImpl) this.resource; if (nresources == null) { @@ -142,7 +143,8 @@ public class NamingResourcesMBean extends BaseModelMBean { } ContextEnvironment env = nresources.findEnvironment(envName); if (env != null) { - throw new IllegalArgumentException(sm.getString("namingResourcesMBean.addAlreadyExists.environment", envName)); + throw new IllegalArgumentException( + sm.getString("namingResourcesMBean.addAlreadyExists.environment", envName)); } env = new ContextEnvironment(); env.setName(envName); @@ -161,12 +163,13 @@ public class NamingResourcesMBean extends BaseModelMBean { * Add a resource reference for this web application. * * @param resourceName New resource reference name - * @param type New resource reference type + * @param type New resource reference type + * * @return the object name of the new resource + * * @throws MalformedObjectNameException if the object name was invalid */ - public String addResource(String resourceName, String type) - throws MalformedObjectNameException { + public String addResource(String resourceName, String type) throws MalformedObjectNameException { NamingResourcesImpl nresources = (NamingResourcesImpl) this.resource; if (nresources == null) { @@ -174,7 +177,8 @@ public class NamingResourcesMBean extends BaseModelMBean { } ContextResource resource = nresources.findResource(resourceName); if (resource != null) { - throw new IllegalArgumentException(sm.getString("namingResourcesMBean.addAlreadyExists.resource", resourceName)); + throw new IllegalArgumentException( + sm.getString("namingResourcesMBean.addAlreadyExists.resource", resourceName)); } resource = new ContextResource(); resource.setName(resourceName); @@ -192,21 +196,22 @@ public class NamingResourcesMBean extends BaseModelMBean { * Add a resource link reference for this web application. * * @param resourceLinkName New resource link reference name - * @param type New resource link reference type + * @param type New resource link reference type + * * @return the object name of the new resource link + * * @throws MalformedObjectNameException if the object name was invalid */ - public String addResourceLink(String resourceLinkName, String type) - throws MalformedObjectNameException { + public String addResourceLink(String resourceLinkName, String type) throws MalformedObjectNameException { NamingResourcesImpl nresources = (NamingResourcesImpl) this.resource; if (nresources == null) { return null; } - ContextResourceLink resourceLink = - nresources.findResourceLink(resourceLinkName); + ContextResourceLink resourceLink = nresources.findResourceLink(resourceLinkName); if (resourceLink != null) { - throw new IllegalArgumentException(sm.getString("namingResourcesMBean.addAlreadyExists.resourceLink", resourceLinkName)); + throw new IllegalArgumentException( + sm.getString("namingResourcesMBean.addAlreadyExists.resourceLink", resourceLinkName)); } resourceLink = new ContextResourceLink(); resourceLink.setName(resourceLinkName); @@ -232,7 +237,8 @@ public class NamingResourcesMBean extends BaseModelMBean { } ContextEnvironment env = nresources.findEnvironment(envName); if (env == null) { - throw new IllegalArgumentException(sm.getString("namingResourcesMBean.removeNotFound.environment", envName)); + throw new IllegalArgumentException( + sm.getString("namingResourcesMBean.removeNotFound.environment", envName)); } nresources.removeEnvironment(envName); } @@ -251,7 +257,8 @@ public class NamingResourcesMBean extends BaseModelMBean { } ContextResource resource = nresources.findResource(resourceName); if (resource == null) { - throw new IllegalArgumentException(sm.getString("namingResourcesMBean.removeNotFound.resource", resourceName)); + throw new IllegalArgumentException( + sm.getString("namingResourcesMBean.removeNotFound.resource", resourceName)); } nresources.removeResource(resourceName); } @@ -270,7 +277,8 @@ public class NamingResourcesMBean extends BaseModelMBean { } ContextResourceLink resourceLink = nresources.findResourceLink(resourceLinkName); if (resourceLink == null) { - throw new IllegalArgumentException(sm.getString("namingResourcesMBean.removeNotFound.resourceLink", resourceLinkName)); + throw new IllegalArgumentException( + sm.getString("namingResourcesMBean.removeNotFound.resourceLink", resourceLinkName)); } nresources.removeResourceLink(resourceLinkName); } diff --git a/java/org/apache/catalina/mbeans/RoleMBean.java b/java/org/apache/catalina/mbeans/RoleMBean.java index 41999d86b2..7ffd9f42bb 100644 --- a/java/org/apache/catalina/mbeans/RoleMBean.java +++ b/java/org/apache/catalina/mbeans/RoleMBean.java @@ -21,8 +21,9 @@ 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> + * <p> + * A <strong>ModelMBean</strong> implementation for the <code>org.apache.catalina.Role</code> component. + * </p> * * @author Craig R. McClanahan */ diff --git a/java/org/apache/catalina/mbeans/ServiceMBean.java b/java/org/apache/catalina/mbeans/ServiceMBean.java index 36102f77bf..719783d73a 100644 --- a/java/org/apache/catalina/mbeans/ServiceMBean.java +++ b/java/org/apache/catalina/mbeans/ServiceMBean.java @@ -25,13 +25,12 @@ import org.apache.catalina.connector.Connector; public class ServiceMBean extends BaseCatalinaMBean<Service> { /** - * Add a new Connector to the set of defined Connectors, and associate it - * with this Service's Container. + * Add a new Connector to the set of defined Connectors, and associate it with this Service's Container. * * @param address The IP address on which to bind - * @param port TCP port number to listen on - * @param isAjp Create a AJP/1.3 Connector - * @param isSSL Create a secure Connector + * @param port TCP port number to listen on + * @param isAjp Create a AJP/1.3 Connector + * @param isSSL Create a secure Connector * * @throws MBeanException error creating the connector */ @@ -40,7 +39,7 @@ public class ServiceMBean extends BaseCatalinaMBean<Service> { Service service = doGetManagedResource(); String protocol = isAjp ? "AJP/1.3" : "HTTP/1.1"; Connector connector = new Connector(protocol); - if ((address!=null) && (address.length()>0)) { + if ((address != null) && (address.length() > 0)) { connector.setProperty("address", address); } connector.setPort(port); @@ -53,7 +52,9 @@ public class ServiceMBean extends BaseCatalinaMBean<Service> { /** * Adds a named executor to the service + * * @param type Classname of the Executor to be added + * * @throws MBeanException error creating the executor */ public void addExecutor(String type) throws MBeanException { @@ -65,7 +66,9 @@ public class ServiceMBean extends BaseCatalinaMBean<Service> { /** * Find and return the set of Connectors associated with this Service. + * * @return an array of string representations of the connectors + * * @throws MBeanException error accessing the associated service */ public String[] findConnectors() throws MBeanException { @@ -75,7 +78,7 @@ public class ServiceMBean extends BaseCatalinaMBean<Service> { Connector[] connectors = service.findConnectors(); String[] str = new String[connectors.length]; - for(int i = 0; i < connectors.length; i++) { + for (int i = 0; i < connectors.length; i++) { str[i] = connectors[i].toString(); } @@ -85,7 +88,9 @@ public class ServiceMBean extends BaseCatalinaMBean<Service> { /** * Retrieves all executors. + * * @return an array of string representations of the executors + * * @throws MBeanException error accessing the associated service */ public String[] findExecutors() throws MBeanException { @@ -95,7 +100,7 @@ public class ServiceMBean extends BaseCatalinaMBean<Service> { Executor[] executors = service.findExecutors(); String[] str = new String[executors.length]; - for(int i = 0; i < executors.length; i++){ + for (int i = 0; i < executors.length; i++) { str[i] = executors[i].toString(); } @@ -105,11 +110,14 @@ public class ServiceMBean extends BaseCatalinaMBean<Service> { /** * Retrieves executor by name + * * @param name Name of the executor to be retrieved + * * @return a string representation of the executor + * * @throws MBeanException error accessing the associated service */ - public String getExecutor(String name) throws MBeanException{ + public String getExecutor(String name) throws MBeanException { Service service = doGetManagedResource(); Executor executor = service.getExecutor(name); if (executor != null) { diff --git a/java/org/apache/catalina/mbeans/SparseUserDatabaseMBean.java b/java/org/apache/catalina/mbeans/SparseUserDatabaseMBean.java index 3c5fe93a77..9f1a767944 100644 --- a/java/org/apache/catalina/mbeans/SparseUserDatabaseMBean.java +++ b/java/org/apache/catalina/mbeans/SparseUserDatabaseMBean.java @@ -34,12 +34,12 @@ import org.apache.tomcat.util.modeler.Registry; import org.apache.tomcat.util.res.StringManager; /** - * <p>A <strong>ModelMBean</strong> implementation for the - * <code>org.apache.catalina.users.SparseUserDatabase</code> component. - * The main difference is that the MBeans are created on demand (for example, - * the findUser method would register the corresponding user and make it - * available for management. All the MBeans created for users, groups and roles - * are then discarded when save is invoked.</p> + * <p> + * A <strong>ModelMBean</strong> implementation for the <code>org.apache.catalina.users.SparseUserDatabase</code> + * component. The main difference is that the MBeans are created on demand (for example, the findUser method would + * register the corresponding user and make it available for management. All the MBeans created for users, groups and + * roles are then discarded when save is invoked. + * </p> * * @author Craig R. McClanahan */ @@ -137,8 +137,9 @@ public class SparseUserDatabaseMBean extends BaseModelMBean { /** * Create a new Group and return the corresponding MBean Name. * - * @param groupname Group name of the new group + * @param groupname Group name of the new group * @param description Description of the new group + * * @return the new group object name */ public String createGroup(String groupname, String description) { @@ -156,8 +157,9 @@ public class SparseUserDatabaseMBean extends BaseModelMBean { /** * Create a new Role and return the corresponding MBean Name. * - * @param rolename Group name of the new group + * @param rolename Group name of the new group * @param description Description of the new group + * * @return the new role object name */ public String createRole(String rolename, String description) { @@ -178,6 +180,7 @@ public class SparseUserDatabaseMBean extends BaseModelMBean { * @param username User name of the new user * @param password Password for the new user * @param fullName Full name for the new user + * * @return the new user object name */ public String createUser(String username, String password, String fullName) { @@ -193,10 +196,10 @@ public class SparseUserDatabaseMBean extends BaseModelMBean { /** - * Return the MBean Name for the specified group name (if any); - * otherwise return <code>null</code>. + * Return the MBean Name for the specified group name (if any); otherwise return <code>null</code>. * * @param groupname Group name to look up + * * @return the group object name */ public String findGroup(String groupname) { @@ -218,10 +221,10 @@ public class SparseUserDatabaseMBean extends BaseModelMBean { /** - * Return the MBean Name for the specified role name (if any); - * otherwise return <code>null</code>. + * Return the MBean Name for the specified role name (if any); otherwise return <code>null</code>. * * @param rolename Role name to look up + * * @return the role object name */ public String findRole(String rolename) { @@ -244,10 +247,10 @@ public class SparseUserDatabaseMBean extends BaseModelMBean { /** - * Return the MBean Name for the specified user name (if any); - * otherwise return <code>null</code>. + * Return the MBean Name for the specified user name (if any); otherwise return <code>null</code>. * * @param username User name to look up + * * @return the user object name */ public String findUser(String username) { @@ -339,24 +342,21 @@ public class SparseUserDatabaseMBean extends BaseModelMBean { Set<ObjectName> results = null; // Groups - query = new ObjectName( - "Users:type=Group,database=" + database.getId() + ",*"); + query = new ObjectName("Users:type=Group,database=" + database.getId() + ",*"); results = mserver.queryNames(query, null); for (ObjectName result : results) { mserver.unregisterMBean(result); } // Roles - query = new ObjectName( - "Users:type=Role,database=" + database.getId() + ",*"); + query = new ObjectName("Users:type=Role,database=" + database.getId() + ",*"); results = mserver.queryNames(query, null); for (ObjectName result : results) { mserver.unregisterMBean(result); } // Users - query = new ObjectName( - "Users:type=User,database=" + database.getId() + ",*"); + query = new ObjectName("Users:type=User,database=" + database.getId() + ",*"); results = mserver.queryNames(query, null); for (ObjectName result : results) { mserver.unregisterMBean(result); diff --git a/java/org/apache/catalina/mbeans/UserMBean.java b/java/org/apache/catalina/mbeans/UserMBean.java index 47f4fb8885..5d9afa9494 100644 --- a/java/org/apache/catalina/mbeans/UserMBean.java +++ b/java/org/apache/catalina/mbeans/UserMBean.java @@ -32,8 +32,9 @@ import org.apache.tomcat.util.modeler.Registry; import org.apache.tomcat.util.res.StringManager; /** - * <p>A <strong>ModelMBean</strong> implementation for the - * <code>org.apache.catalina.User</code> component.</p> + * <p> + * A <strong>ModelMBean</strong> implementation for the <code>org.apache.catalina.User</code> component. + * </p> * * @author Craig R. McClanahan */ @@ -70,8 +71,7 @@ public class UserMBean extends BaseModelMBean { Group group = null; try { group = groups.next(); - ObjectName oname = - MBeanUtils.createObjectName(managed.getDomain(), group); + ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), group); results.add(oname.toString()); } catch (MalformedObjectNameException e) { throw new IllegalArgumentException(sm.getString("userMBean.createError.group", group), e); @@ -93,8 +93,7 @@ public class UserMBean extends BaseModelMBean { 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) { throw new IllegalArgumentException(sm.getString("userMBean.createError.role", role), e); --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org