This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 8.5.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit 0a218f971658bdfab307915201d679b51cb8f677 Author: Mark Thomas <ma...@apache.org> AuthorDate: Tue Sep 26 15:20:34 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 | 50 +-- .../catalina/mbeans/ContextResourceLinkMBean.java | 47 ++- .../catalina/mbeans/ContextResourceMBean.java | 60 ++-- .../mbeans/GlobalResourcesLifecycleListener.java | 31 +- java/org/apache/catalina/mbeans/GroupMBean.java | 5 +- java/org/apache/catalina/mbeans/MBeanDumper.java | 89 +++--- java/org/apache/catalina/mbeans/MBeanFactory.java | 277 ++++++++-------- java/org/apache/catalina/mbeans/MBeanUtils.java | 349 +++++++++------------ .../catalina/mbeans/MemoryUserDatabaseMBean.java | 25 +- .../catalina/mbeans/NamingResourcesMBean.java | 68 ++-- java/org/apache/catalina/mbeans/RoleMBean.java | 5 +- java/org/apache/catalina/mbeans/ServiceMBean.java | 26 +- java/org/apache/catalina/mbeans/UserMBean.java | 11 +- 18 files changed, 551 insertions(+), 641 deletions(-) diff --git a/java/org/apache/catalina/mbeans/BaseCatalinaMBean.java b/java/org/apache/catalina/mbeans/BaseCatalinaMBean.java index 7211e7fe3f..35b900cb97 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 2e94bf0ada..09f1c23859 100644 --- a/java/org/apache/catalina/mbeans/ConnectorMBean.java +++ b/java/org/apache/catalina/mbeans/ConnectorMBean.java @@ -26,8 +26,10 @@ import org.apache.catalina.connector.Connector; import org.apache.tomcat.util.IntrospectionUtils; /** - * <p>A <strong>ModelMBean</strong> implementation for the - * <code>org.apache.coyote.tomcat5.CoyoteConnector</code> component.</p> + * <p> + * A <strong>ModelMBean</strong> implementation for the <code>org.apache.coyote.tomcat5.CoyoteConnector</code> + * component. + * </p> * * @author Amy Roh */ @@ -38,21 +40,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("Attribute name is null"), + throw new RuntimeOperationsException(new IllegalArgumentException("Attribute name is null"), "Attribute name is null"); } @@ -64,30 +61,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( - "Attribute is null"), "Attribute is null"); + throw new RuntimeOperationsException(new IllegalArgumentException("Attribute is null"), + "Attribute is null"); } String name = attribute.getName(); Object value = attribute.getValue(); if (name == null) { - throw new RuntimeOperationsException( - new IllegalArgumentException("Attribute name is null"), + throw new RuntimeOperationsException(new IllegalArgumentException("Attribute name is null"), "Attribute name is null"); } 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 74d32b2801..5f97f80dd6 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,14 +90,15 @@ 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 - * @deprecated Unused. Will be removed in Tomcat 10. - * Use {@link #findErrorPage(Throwable)} instead. + * + * @deprecated Unused. Will be removed in Tomcat 10. Use {@link #findErrorPage(Throwable)} instead. */ @Deprecated public String findErrorPage(String exceptionType) throws MBeanException { @@ -104,11 +108,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 { @@ -123,9 +128,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 { @@ -143,11 +149,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 { @@ -165,8 +172,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 { @@ -185,7 +193,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 f6edc914b5..6f2ca1329e 100644 --- a/java/org/apache/catalina/mbeans/ContextResourceLinkMBean.java +++ b/java/org/apache/catalina/mbeans/ContextResourceLinkMBean.java @@ -26,8 +26,10 @@ import org.apache.tomcat.util.descriptor.web.ContextResourceLink; import org.apache.tomcat.util.descriptor.web.NamingResources; /** - * <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 */ @@ -38,21 +40,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("Attribute name is null"), + throw new RuntimeOperationsException(new IllegalArgumentException("Attribute name is null"), "Attribute name is null"); } @@ -81,32 +78,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("Attribute is null"), + throw new RuntimeOperationsException(new IllegalArgumentException("Attribute is null"), "Attribute is null"); } String name = attribute.getName(); Object value = attribute.getValue(); if (name == null) { - throw new RuntimeOperationsException( - new IllegalArgumentException("Attribute name is null"), + throw new RuntimeOperationsException(new IllegalArgumentException("Attribute name is null"), "Attribute name is null"); } @@ -124,7 +115,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 0edd7fa337..7ba6cc55bd 100644 --- a/java/org/apache/catalina/mbeans/ContextResourceMBean.java +++ b/java/org/apache/catalina/mbeans/ContextResourceMBean.java @@ -26,8 +26,10 @@ import org.apache.tomcat.util.descriptor.web.ContextResource; import org.apache.tomcat.util.descriptor.web.NamingResources; /** - * <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 */ @@ -38,21 +40,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("Attribute name is null"), + throw new RuntimeOperationsException(new IllegalArgumentException("Attribute name is null"), "Attribute name is null"); } @@ -72,8 +69,7 @@ public class ContextResourceMBean extends BaseCatalinaMBean<ContextResource> { } else { value = (String) cr.getProperty(name); if (value == null) { - throw new AttributeNotFoundException - ("Cannot find attribute [" + name + "]"); + throw new AttributeNotFoundException("Cannot find attribute [" + name + "]"); } } @@ -84,51 +80,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("Attribute is null"), + throw new RuntimeOperationsException(new IllegalArgumentException("Attribute is null"), "Attribute is null"); } String name = attribute.getName(); Object value = attribute.getValue(); if (name == null) { - throw new RuntimeOperationsException( - new IllegalArgumentException("Attribute name is null"), + throw new RuntimeOperationsException(new IllegalArgumentException("Attribute name is null"), "Attribute name is null"); } 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/GlobalResourcesLifecycleListener.java b/java/org/apache/catalina/mbeans/GlobalResourcesLifecycleListener.java index 4539b31c93..45bb5e9c13 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.modeler.Registry; /** - * 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 { @@ -117,10 +117,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 @@ -128,8 +127,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 { @@ -151,9 +149,9 @@ public class GlobalResourcesLifecycleListener implements LifecycleListener { } } } - } catch( RuntimeException ex) { + } catch (RuntimeException ex) { log.error("RuntimeException " + ex); - } catch( OperationNotSupportedException ex) { + } catch (OperationNotSupportedException ex) { log.error("Operation not supported " + ex); } } @@ -162,7 +160,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 @@ -176,9 +174,8 @@ public class GlobalResourcesLifecycleListener implements LifecycleListener { } try { MBeanUtils.createMBean(database); - } catch(Exception e) { - throw new IllegalArgumentException( - "Cannot create UserDatabase MBean for resource " + name, e); + } catch (Exception e) { + throw new IllegalArgumentException("Cannot create UserDatabase MBean for resource " + name, e); } // Create the MBeans for each defined Role @@ -205,8 +202,7 @@ public class GlobalResourcesLifecycleListener implements LifecycleListener { try { MBeanUtils.createMBean(group); } catch (Exception e) { - throw new IllegalArgumentException( - "Cannot create Group MBean for group " + group, e); + throw new IllegalArgumentException("Cannot create Group MBean for group " + group, e); } } @@ -220,8 +216,7 @@ public class GlobalResourcesLifecycleListener implements LifecycleListener { try { MBeanUtils.createMBean(user); } catch (Exception e) { - throw new IllegalArgumentException( - "Cannot create User MBean for user " + user, e); + throw new IllegalArgumentException("Cannot create User MBean for user " + user, e); } } } diff --git a/java/org/apache/catalina/mbeans/GroupMBean.java b/java/org/apache/catalina/mbeans/GroupMBean.java index a60aa37add..9721d6e013 100644 --- a/java/org/apache/catalina/mbeans/GroupMBean.java +++ b/java/org/apache/catalina/mbeans/GroupMBean.java @@ -30,8 +30,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.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 04f2ae907c..8aff1b133d 100644 --- a/java/org/apache/catalina/mbeans/MBeanDumper.java +++ b/java/org/apache/catalina/mbeans/MBeanDumper.java @@ -31,7 +31,6 @@ import org.apache.tomcat.util.ExceptionUtils; /** * General helper to dump MBean contents to the log. - * */ public class MBeanDumper { @@ -41,12 +40,13 @@ 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) - { + public static String dumpBeans(MBeanServer mbeanServer, Set<ObjectName> names) { StringBuilder buf = new StringBuilder(); for (ObjectName oname : names) { buf.append("Name: "); @@ -54,59 +54,53 @@ public class MBeanDumper { buf.append(CRLF); try { - MBeanInfo minfo=mbeanServer.getMBeanInfo(oname); + MBeanInfo minfo = mbeanServer.getMBeanInfo(oname); // can't be null - I think - String code=minfo.getClassName(); + String code = minfo.getClassName(); if ("org.apache.commons.modeler.BaseModelMBean".equals(code)) { - code=(String)mbeanServer.getAttribute(oname, "modelerType"); + code = (String) mbeanServer.getAttribute(oname, "modelerType"); } buf.append("modelerType: "); buf.append(code); buf.append(CRLF); - MBeanAttributeInfo attrs[]=minfo.getAttributes(); - Object value=null; + MBeanAttributeInfo attrs[] = minfo.getAttributes(); + Object value = null; - for (int i=0; i< attrs.length; i++) { - if (! attrs[i].isReadable()) { + for (int i = 0; i < attrs.length; i++) { + if (!attrs[i].isReadable()) { continue; } - String attName=attrs[i].getName(); + String attName = attrs[i].getName(); 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; } try { - value=mbeanServer.getAttribute(oname, attName); + value = mbeanServer.getAttribute(oname, attName); } catch (JMRuntimeException rme) { Throwable cause = rme.getCause(); if (cause instanceof UnsupportedOperationException) { if (log.isDebugEnabled()) { - log.debug("Error getting attribute " + oname - + " " + attName, rme); + log.debug("Error getting attribute " + oname + " " + attName, rme); } } else if (cause instanceof NullPointerException) { if (log.isDebugEnabled()) { - log.debug("Error getting attribute " + oname - + " " + attName, rme); + log.debug("Error getting attribute " + oname + " " + attName, rme); } } else { - log.error("Error getting attribute " + oname + - " " + attName, rme); + log.error("Error getting attribute " + oname + " " + attName, rme); } continue; } catch (Throwable t) { ExceptionUtils.handleThrowable(t); - log.error("Error getting attribute " + oname + - " " + attName, t); + log.error("Error getting attribute " + oname + " " + attName, t); continue; } - if (value==null) { + if (value == null) { continue; } String valueString; @@ -114,8 +108,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); } @@ -127,8 +121,7 @@ public class MBeanDumper { } else { try { sb.append(escape(item.toString())); - } - catch (Throwable t) { + } catch (Throwable t) { ExceptionUtils.handleThrowable(t); sb.append("NON-STRINGABLE VALUE"); } @@ -138,16 +131,14 @@ public class MBeanDumper { } } valueString = sb.toString(); - } - else { + } else { valueString = escape(value.toString()); } buf.append(attName); buf.append(": "); buf.append(valueString); buf.append(CRLF); - } - catch (Throwable t) { + } catch (Throwable t) { ExceptionUtils.handleThrowable(t); } } @@ -169,35 +160,35 @@ public class MBeanDumper { return value; } - int prev=0; - StringBuilder sb=new StringBuilder(); - while( idx >= 0 ) { + int prev = 0; + StringBuilder sb = new StringBuilder(); + while (idx >= 0) { appendHead(sb, value, prev, idx); - sb.append( "\\n\n "); - prev=idx+1; - if( idx==value.length() -1 ) { + sb.append("\\n\n "); + prev = idx + 1; + if (idx == value.length() - 1) { break; } - idx=value.indexOf('\n', idx+1); + idx = value.indexOf('\n', idx + 1); } - if( prev < value.length() ) { - appendHead( sb, value, prev, value.length()); + if (prev < value.length()) { + appendHead(sb, value, prev, value.length()); } return sb.toString(); } - private static void appendHead( StringBuilder sb, String value, int start, int end) { + private static void appendHead(StringBuilder sb, String value, int start, int end) { if (end < 1) { return; } - int pos=start; - while( end-pos > 78 ) { - sb.append( value.substring(pos, pos+78)); - sb.append( "\n "); - pos=pos+78; + int pos = start; + while (end - pos > 78) { + sb.append(value.substring(pos, pos + 78)); + sb.append("\n "); + pos = pos + 78; } - sb.append( value.substring(pos,end)); + sb.append(value.substring(pos, end)); } } diff --git a/java/org/apache/catalina/mbeans/MBeanFactory.java b/java/org/apache/catalina/mbeans/MBeanFactory.java index 9ebf2557a0..0efa1d5199 100644 --- a/java/org/apache/catalina/mbeans/MBeanFactory.java +++ b/java/org/apache/catalina/mbeans/MBeanFactory.java @@ -75,6 +75,7 @@ public class MBeanFactory { /** * Set the container that this factory was created for. + * * @param container The associated container */ public void setContainer(Object container) { @@ -83,10 +84,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) { @@ -96,22 +97,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); @@ -132,11 +131,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"); @@ -169,7 +166,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())) { @@ -177,8 +174,7 @@ public class MBeanFactory { } } } - if (service == null || - !service.getObjectName().getDomain().equals(domain)) { + if (service == null || !service.getObjectName().getDomain().equals(domain)) { throw new Exception("Service with the domain is not found"); } return service; @@ -189,15 +185,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); } @@ -206,19 +202,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(); @@ -250,15 +247,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); } @@ -266,20 +263,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 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 @@ -303,15 +300,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); } @@ -319,22 +316,21 @@ public class MBeanFactory { /** * Create a new JDBC Realm. * - * @param parent MBean Name of the associated parent component - * @param driverName JDBC driver name - * @param connectionName the user name for the connection + * @param parent MBean Name of the associated parent component + * @param driverName JDBC driver name + * @param connectionName the user name for the connection * @param connectionPassword the password for the connection - * @param connectionURL the connection URL to the database + * @param connectionURL the connection URL to the database + * * @return the object name of the created realm * * @exception Exception if an MBean cannot be created or registered * - * @deprecated This method will be removed in Tomcat 10. Use a - * DataSourceRealm instead. + * @deprecated This method will be removed in Tomcat 10. Use a DataSourceRealm instead. */ @Deprecated - public String createJDBCRealm(String parent, String driverName, - String connectionName, String connectionPassword, String connectionURL) - throws Exception { + public String createJDBCRealm(String parent, String driverName, String connectionName, String connectionPassword, + String connectionURL) throws Exception { // Create a new JDBCRealm instance org.apache.catalina.realm.JDBCRealm realm = new org.apache.catalina.realm.JDBCRealm(); @@ -363,13 +359,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 @@ -392,13 +389,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 @@ -416,20 +414,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); } @@ -438,21 +434,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(); @@ -467,35 +460,31 @@ 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("Deployer not found for "+pname.getKeyProperty("host")); + log.warn("Deployer not found for " + pname.getKeyProperty("host")); Service service = getService(pname); Engine engine = service.getContainer(); Host host = (Host) engine.findChild(pname.getKeyProperty("host")); @@ -510,24 +499,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(); @@ -557,15 +542,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("Container not Server"); @@ -590,12 +575,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(); @@ -619,19 +604,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); @@ -643,8 +627,8 @@ public class MBeanFactory { // Return the corresponding MBean name ObjectName oname = realm.getObjectName(); // FIXME getObjectName() returns null - //ObjectName oname = - // MBeanUtils.createObjectName(pname.getDomain(), realm); + // ObjectName oname = + // MBeanUtils.createObjectName(pname.getDomain(), realm); if (oname != null) { return (oname.toString()); } else { @@ -657,18 +641,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); @@ -695,12 +676,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(); @@ -712,9 +693,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(); } @@ -756,8 +736,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; @@ -784,40 +763,36 @@ 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)); } } else { - log.warn("Deployer not found for "+hostName); + log.warn("Deployer not found for " + hostName); Host host = (Host) engine.findChild(hostName); 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 { - ((StandardContext)context).destroy(); + ((StandardContext) context).destroy(); } catch (Exception e) { log.warn("Error during context [" + context.getName() + "] destroy ", e); - } + } } } @@ -841,7 +816,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 67dab6ff75..4e989e4c39 100644 --- a/java/org/apache/catalina/mbeans/MBeanUtils.java +++ b/java/org/apache/catalina/mbeans/MBeanUtils.java @@ -51,18 +51,11 @@ public class MBeanUtils { // ------------------------------------------------------- Static Variables /** - * 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" }, - }; + private static final String exceptions[][] = { { "org.apache.catalina.users.MemoryGroup", "Group" }, + { "org.apache.catalina.users.MemoryRole", "Role" }, { "org.apache.catalina.users.MemoryUser", "User" }, }; /** @@ -80,8 +73,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 */ @@ -106,20 +98,20 @@ 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); if (managed == null) { - Exception e = new Exception("ManagedBean is not found with "+mname); + Exception e = new Exception("ManagedBean is not found with " + mname); throw new MBeanException(e); } String domain = managed.getDomain(); @@ -128,7 +120,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); @@ -138,20 +130,20 @@ 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); if (managed == null) { - Exception e = new Exception("ManagedBean is not found with "+mname); + Exception e = new Exception("ManagedBean is not found with " + mname); throw new MBeanException(e); } String domain = managed.getDomain(); @@ -160,7 +152,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); @@ -170,20 +162,20 @@ 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); if (managed == null) { - Exception e = new Exception("ManagedBean is not found with "+mname); + Exception e = new Exception("ManagedBean is not found with " + mname); throw new MBeanException(e); } String domain = managed.getDomain(); @@ -192,7 +184,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); @@ -202,20 +194,20 @@ 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); if (managed == null) { - Exception e = new Exception("ManagedBean is not found with "+mname); + Exception e = new Exception("ManagedBean is not found with " + mname); throw new MBeanException(e); } String domain = managed.getDomain(); @@ -224,7 +216,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); @@ -234,20 +226,20 @@ 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); if (managed == null) { - Exception e = new Exception("ManagedBean is not found with "+mname); + Exception e = new Exception("ManagedBean is not found with " + mname); throw new MBeanException(e); } String domain = managed.getDomain(); @@ -256,7 +248,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); @@ -266,20 +258,20 @@ 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); if (managed == null) { - Exception e = new Exception("ManagedBean is not found with "+mname); + Exception e = new Exception("ManagedBean is not found with " + mname); throw new MBeanException(e); } String domain = managed.getDomain(); @@ -288,7 +280,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); @@ -298,20 +290,20 @@ 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 { String mname = createManagedName(userDatabase); ManagedBean managed = registry.findManagedBean(mname); if (managed == null) { - Exception e = new Exception("ManagedBean is not found with "+mname); + Exception e = new Exception("ManagedBean is not found with " + mname); throw new MBeanException(e); } String domain = managed.getDomain(); @@ -320,7 +312,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); @@ -330,32 +322,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; @@ -363,35 +351,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; @@ -399,36 +382,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; @@ -437,112 +415,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() { @@ -550,7 +521,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); @@ -562,18 +533,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() { @@ -585,15 +556,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); @@ -605,7 +574,7 @@ public class MBeanUtils { domain = mserver.getDefaultDomain(); } ObjectName oname = createObjectName(domain, environment); - if( mserver.isRegistered(oname) ) { + if (mserver.isRegistered(oname)) { mserver.unregisterMBean(oname); } @@ -613,15 +582,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 @@ -639,7 +606,7 @@ public class MBeanUtils { domain = mserver.getDefaultDomain(); } ObjectName oname = createObjectName(domain, resource); - if( mserver.isRegistered(oname )) { + if (mserver.isRegistered(oname)) { mserver.unregisterMBean(oname); } @@ -647,15 +614,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); @@ -667,22 +632,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); @@ -694,7 +657,7 @@ public class MBeanUtils { domain = mserver.getDefaultDomain(); } ObjectName oname = createObjectName(domain, group); - if( mserver.isRegistered(oname) ) { + if (mserver.isRegistered(oname)) { mserver.unregisterMBean(oname); } @@ -702,15 +665,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); @@ -722,7 +683,7 @@ public class MBeanUtils { domain = mserver.getDefaultDomain(); } ObjectName oname = createObjectName(domain, role); - if( mserver.isRegistered(oname) ) { + if (mserver.isRegistered(oname)) { mserver.unregisterMBean(oname); } @@ -730,15 +691,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); @@ -750,7 +709,7 @@ public class MBeanUtils { domain = mserver.getDefaultDomain(); } ObjectName oname = createObjectName(domain, user); - if( mserver.isRegistered(oname) ) { + if (mserver.isRegistered(oname)) { mserver.unregisterMBean(oname); } @@ -758,47 +717,41 @@ 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); } } diff --git a/java/org/apache/catalina/mbeans/MemoryUserDatabaseMBean.java b/java/org/apache/catalina/mbeans/MemoryUserDatabaseMBean.java index 34be739368..945dbb328b 100644 --- a/java/org/apache/catalina/mbeans/MemoryUserDatabaseMBean.java +++ b/java/org/apache/catalina/mbeans/MemoryUserDatabaseMBean.java @@ -31,8 +31,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.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 */ @@ -122,8 +124,9 @@ public class MemoryUserDatabaseMBean 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) { @@ -141,8 +144,9 @@ public class MemoryUserDatabaseMBean 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) { @@ -163,6 +167,7 @@ public class MemoryUserDatabaseMBean 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) { @@ -178,10 +183,10 @@ public class MemoryUserDatabaseMBean 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) { @@ -200,10 +205,10 @@ public class MemoryUserDatabaseMBean 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) { @@ -223,10 +228,10 @@ public class MemoryUserDatabaseMBean 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) { diff --git a/java/org/apache/catalina/mbeans/NamingResourcesMBean.java b/java/org/apache/catalina/mbeans/NamingResourcesMBean.java index afffbf1db8..b1bcbd5a02 100644 --- a/java/org/apache/catalina/mbeans/NamingResourcesMBean.java +++ b/java/org/apache/catalina/mbeans/NamingResourcesMBean.java @@ -31,8 +31,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.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 */ @@ -55,19 +57,19 @@ 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 { ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), env); results.add(oname.toString()); } catch (MalformedObjectNameException e) { - throw new IllegalArgumentException ("Cannot create object name for environment " + env, e); + throw new IllegalArgumentException("Cannot create object name for environment " + env, e); } } return results.toArray(new String[0]); @@ -75,12 +77,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 { @@ -95,18 +97,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("Cannot create object name for resource " + resourceLink, e); @@ -122,13 +122,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) { @@ -136,8 +137,7 @@ public class NamingResourcesMBean extends BaseModelMBean { } ContextEnvironment env = nresources.findEnvironment(envName); if (env != null) { - throw new IllegalArgumentException( - "Invalid environment name - already exists '" + envName + "'"); + throw new IllegalArgumentException("Invalid environment name - already exists '" + envName + "'"); } env = new ContextEnvironment(); env.setName(envName); @@ -156,12 +156,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) { @@ -169,8 +170,7 @@ public class NamingResourcesMBean extends BaseModelMBean { } ContextResource resource = nresources.findResource(resourceName); if (resource != null) { - throw new IllegalArgumentException( - "Invalid resource name - already exists'" + resourceName + "'"); + throw new IllegalArgumentException("Invalid resource name - already exists'" + resourceName + "'"); } resource = new ContextResource(); resource.setName(resourceName); @@ -188,22 +188,21 @@ 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( - "Invalid resource link name - already exists'" + resourceLinkName + "'"); + throw new IllegalArgumentException("Invalid resource link name - already exists'" + resourceLinkName + "'"); } resourceLink = new ContextResourceLink(); resourceLink.setName(resourceLinkName); @@ -267,8 +266,7 @@ public class NamingResourcesMBean extends BaseModelMBean { } ContextResourceLink resourceLink = nresources.findResourceLink(resourceLinkName); if (resourceLink == null) { - throw new IllegalArgumentException( - "Invalid resource Link name '" + resourceLinkName + "'"); + throw new IllegalArgumentException("Invalid resource Link name '" + resourceLinkName + "'"); } nresources.removeResourceLink(resourceLinkName); } 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/UserMBean.java b/java/org/apache/catalina/mbeans/UserMBean.java index 2d85ee1fc4..69e48bee12 100644 --- a/java/org/apache/catalina/mbeans/UserMBean.java +++ b/java/org/apache/catalina/mbeans/UserMBean.java @@ -30,8 +30,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.User</code> component.</p> + * <p> + * A <strong>ModelMBean</strong> implementation for the <code>org.apache.catalina.User</code> component. + * </p> * * @author Craig R. McClanahan */ @@ -67,8 +68,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("Cannot create object name for group " + group, e); @@ -90,8 +90,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("Cannot create object name for role " + role, e); --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org