This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit 16f3011acbeb32c7a1ec33384fe89b8580f1edce Author: Mark Thomas <ma...@apache.org> AuthorDate: Fri May 3 08:02:22 2024 +0100 Code clean-up - formatting. No functional change. --- .../catalina/storeconfig/CatalinaClusterSF.java | 12 +- .../storeconfig/CertificateStoreAppender.java | 5 +- .../org/apache/catalina/storeconfig/ChannelSF.java | 7 +- .../apache/catalina/storeconfig/ConnectorSF.java | 17 +-- .../storeconfig/ConnectorStoreAppender.java | 84 +++++------ .../catalina/storeconfig/CredentialHandlerSF.java | 20 +-- .../storeconfig/GlobalNamingResourcesSF.java | 17 +-- .../apache/catalina/storeconfig/IStoreConfig.java | 51 +++---- .../apache/catalina/storeconfig/IStoreFactory.java | 11 +- .../apache/catalina/storeconfig/InterceptorSF.java | 22 ++- .../apache/catalina/storeconfig/JarScannerSF.java | 8 +- java/org/apache/catalina/storeconfig/LoaderSF.java | 24 ++- .../org/apache/catalina/storeconfig/ManagerSF.java | 26 ++-- .../catalina/storeconfig/NamingResourcesSF.java | 11 +- .../apache/catalina/storeconfig/OpenSSLConfSF.java | 5 +- .../catalina/storeconfig/PersistentManagerSF.java | 5 +- java/org/apache/catalina/storeconfig/RealmSF.java | 26 ++-- .../catalina/storeconfig/SSLHostConfigSF.java | 8 +- java/org/apache/catalina/storeconfig/SenderSF.java | 7 +- .../catalina/storeconfig/StandardContextSF.java | 117 +++++++-------- .../catalina/storeconfig/StandardEngineSF.java | 11 +- .../catalina/storeconfig/StandardHostSF.java | 15 +- .../catalina/storeconfig/StandardServerSF.java | 22 ++- .../catalina/storeconfig/StandardServiceSF.java | 5 +- .../apache/catalina/storeconfig/StoreAppender.java | 164 ++++++++++----------- .../apache/catalina/storeconfig/StoreConfig.java | 76 ++++------ .../storeconfig/StoreConfigLifecycleListener.java | 29 ++-- .../catalina/storeconfig/StoreContextAppender.java | 78 +++++----- .../catalina/storeconfig/StoreDescription.java | 46 ++---- .../catalina/storeconfig/StoreFactoryBase.java | 72 ++++----- .../catalina/storeconfig/StoreFactoryRule.java | 46 +++--- .../catalina/storeconfig/StoreFileMover.java | 26 ++-- .../apache/catalina/storeconfig/StoreLoader.java | 62 +++----- .../apache/catalina/storeconfig/StoreRegistry.java | 31 ++-- .../catalina/storeconfig/WatchedResourceSF.java | 13 +- .../catalina/storeconfig/WebResourceRootSF.java | 29 ++-- .../catalina/storeconfig/WrapperLifecycleSF.java | 13 +- .../catalina/storeconfig/WrapperListenerSF.java | 16 +- 38 files changed, 544 insertions(+), 693 deletions(-) diff --git a/java/org/apache/catalina/storeconfig/CatalinaClusterSF.java b/java/org/apache/catalina/storeconfig/CatalinaClusterSF.java index ce1ef29eff..498eba23c3 100644 --- a/java/org/apache/catalina/storeconfig/CatalinaClusterSF.java +++ b/java/org/apache/catalina/storeconfig/CatalinaClusterSF.java @@ -30,18 +30,18 @@ import org.apache.catalina.ha.tcp.SimpleTcpCluster; import org.apache.catalina.tribes.Channel; /** - * Generate Cluster Element with Membership,Sender,Receiver,Deployer and - * ReplicationValve + * Generate Cluster Element with Membership,Sender,Receiver,Deployer and ReplicationValve */ public class CatalinaClusterSF extends StoreFactoryBase { /** * Store the specified Cluster children. + * <p> * {@inheritDoc} */ @Override - public void storeChildren(PrintWriter aWriter, int indent, Object aCluster, - StoreDescription parentDesc) throws Exception { + public void storeChildren(PrintWriter aWriter, int indent, Object aCluster, StoreDescription parentDesc) + throws Exception { if (aCluster instanceof CatalinaCluster) { CatalinaCluster cluster = (CatalinaCluster) aCluster; if (cluster instanceof SimpleTcpCluster) { @@ -69,10 +69,10 @@ public class CatalinaClusterSF extends StoreFactoryBase { if (aCluster instanceof SimpleTcpCluster) { // Store nested <Listener> elements - LifecycleListener listeners[] = ((SimpleTcpCluster)cluster).findLifecycleListeners(); + LifecycleListener listeners[] = ((SimpleTcpCluster) cluster).findLifecycleListeners(); storeElementArray(aWriter, indent, listeners); // Store nested <ClusterListener> elements - ClusterListener mlisteners[] = ((SimpleTcpCluster)cluster).findClusterListeners(); + ClusterListener mlisteners[] = ((SimpleTcpCluster) cluster).findClusterListeners(); List<ClusterListener> clusterListeners = new ArrayList<>(); for (ClusterListener clusterListener : mlisteners) { if (clusterListener != deployer) { diff --git a/java/org/apache/catalina/storeconfig/CertificateStoreAppender.java b/java/org/apache/catalina/storeconfig/CertificateStoreAppender.java index 50bc71716f..9a5c235029 100644 --- a/java/org/apache/catalina/storeconfig/CertificateStoreAppender.java +++ b/java/org/apache/catalina/storeconfig/CertificateStoreAppender.java @@ -26,9 +26,8 @@ import org.apache.tomcat.util.IntrospectionUtils; public class CertificateStoreAppender extends StoreAppender { @Override - protected Object checkAttribute(StoreDescription desc, - PropertyDescriptor descriptor, String attributeName, Object bean, - Object bean2) { + protected Object checkAttribute(StoreDescription desc, PropertyDescriptor descriptor, String attributeName, + Object bean, Object bean2) { if (attributeName.equals("type")) { return IntrospectionUtils.getProperty(bean, descriptor.getName()); } else { diff --git a/java/org/apache/catalina/storeconfig/ChannelSF.java b/java/org/apache/catalina/storeconfig/ChannelSF.java index f511337d6d..f1395c1cfa 100644 --- a/java/org/apache/catalina/storeconfig/ChannelSF.java +++ b/java/org/apache/catalina/storeconfig/ChannelSF.java @@ -33,11 +33,12 @@ public class ChannelSF extends StoreFactoryBase { /** * Store the specified Channel children. + * <p> * {@inheritDoc} */ @Override - public void storeChildren(PrintWriter aWriter, int indent, Object aChannel, - StoreDescription parentDesc) throws Exception { + public void storeChildren(PrintWriter aWriter, int indent, Object aChannel, StoreDescription parentDesc) + throws Exception { if (aChannel instanceof Channel) { Channel channel = (Channel) aChannel; if (channel instanceof ManagedChannel) { @@ -63,6 +64,6 @@ public class ChannelSF extends StoreFactoryBase { storeElement(aWriter, indent, interceptor); } } - } + } } } \ No newline at end of file diff --git a/java/org/apache/catalina/storeconfig/ConnectorSF.java b/java/org/apache/catalina/storeconfig/ConnectorSF.java index eb7b337dc5..1a223149a1 100644 --- a/java/org/apache/catalina/storeconfig/ConnectorSF.java +++ b/java/org/apache/catalina/storeconfig/ConnectorSF.java @@ -29,8 +29,8 @@ import org.apache.tomcat.util.net.SSLHostConfig; public class ConnectorSF extends StoreFactoryBase { @Override - public void storeChildren(PrintWriter aWriter, int indent, Object aConnector, - StoreDescription parentDesc) throws Exception { + public void storeChildren(PrintWriter aWriter, int indent, Object aConnector, StoreDescription parentDesc) + throws Exception { if (aConnector instanceof Connector) { Connector connector = (Connector) aConnector; @@ -48,24 +48,21 @@ public class ConnectorSF extends StoreFactoryBase { } } - protected void printOpenTag(PrintWriter aWriter, int indent, Object bean, - StoreDescription aDesc) throws Exception { + protected void printOpenTag(PrintWriter aWriter, int indent, Object bean, StoreDescription aDesc) throws Exception { aWriter.print("<"); aWriter.print(aDesc.getTag()); storeConnectorAttributes(aWriter, indent, bean, aDesc); aWriter.println(">"); } - protected void storeConnectorAttributes(PrintWriter aWriter, int indent, - Object bean, StoreDescription aDesc) throws Exception { + protected void storeConnectorAttributes(PrintWriter aWriter, int indent, Object bean, StoreDescription aDesc) + throws Exception { if (aDesc.isAttributes()) { - getStoreAppender().printAttributes(aWriter, indent, false, bean, - aDesc); + getStoreAppender().printAttributes(aWriter, indent, false, bean, aDesc); } } - protected void printTag(PrintWriter aWriter, int indent, Object bean, - StoreDescription aDesc) throws Exception { + protected void printTag(PrintWriter aWriter, int indent, Object bean, StoreDescription aDesc) throws Exception { aWriter.print("<"); aWriter.print(aDesc.getTag()); storeConnectorAttributes(aWriter, indent, bean, aDesc); diff --git a/java/org/apache/catalina/storeconfig/ConnectorStoreAppender.java b/java/org/apache/catalina/storeconfig/ConnectorStoreAppender.java index 686844d2e0..e108729705 100644 --- a/java/org/apache/catalina/storeconfig/ConnectorStoreAppender.java +++ b/java/org/apache/catalina/storeconfig/ConnectorStoreAppender.java @@ -36,14 +36,13 @@ import org.apache.tomcat.util.IntrospectionUtils; import org.apache.tomcat.util.net.SocketProperties; /** - * Store the Connector attributes. Connector has really special design. A - * Connector is only a startup Wrapper for a ProtocolHandler. This meant that - * ProtocolHandler get all there attributes from the Connector attribute map. - * Strange is that some attributes change their name. + * Store the Connector attributes. Connector has really special design. A Connector is only a startup Wrapper for a + * ProtocolHandler. This meant that ProtocolHandler get all there attributes from the Connector attribute map. Strange + * is that some attributes change their name. */ public class ConnectorStoreAppender extends StoreAppender { - protected static final HashMap<String, String> replacements = new HashMap<>(); + protected static final HashMap<String,String> replacements = new HashMap<>(); protected static final Set<String> internalExecutorAttributes = new HashSet<>(); static { replacements.put("timeout", "connectionUploadTimeout"); @@ -55,8 +54,7 @@ public class ConnectorStoreAppender extends StoreAppender { } @Override - public void printAttributes(PrintWriter writer, int indent, - boolean include, Object bean, StoreDescription desc) + public void printAttributes(PrintWriter writer, int indent, boolean include, Object bean, StoreDescription desc) throws Exception { // Render a className attribute if requested @@ -70,7 +68,7 @@ public class ConnectorStoreAppender extends StoreAppender { String protocol = connector.getProtocol(); List<String> propertyKeys = getPropertyKeys(connector); // Create blank instance - Object bean2 = new Connector(protocol);//defaultInstance(bean); + Object bean2 = new Connector(protocol);// defaultInstance(bean); for (String key : propertyKeys) { Object value = IntrospectionUtils.getProperty(bean, key); if (desc.isTransientAttribute(key)) { @@ -105,17 +103,17 @@ public class ConnectorStoreAppender extends StoreAppender { * Get all properties from Connector and current ProtocolHandler. * * @param bean The connector + * * @return List of Connector property names + * * @throws IntrospectionException Error introspecting connector */ - protected List<String> getPropertyKeys(Connector bean) - throws IntrospectionException { + protected List<String> getPropertyKeys(Connector bean) throws IntrospectionException { List<String> propertyKeys = new ArrayList<>(); // Acquire the list of properties for this bean ProtocolHandler protocolHandler = bean.getProtocolHandler(); // Acquire the list of properties for this bean - PropertyDescriptor descriptors[] = Introspector.getBeanInfo( - bean.getClass()).getPropertyDescriptors(); + PropertyDescriptor descriptors[] = Introspector.getBeanInfo(bean.getClass()).getPropertyDescriptors(); if (descriptors == null) { descriptors = new PropertyDescriptor[0]; } @@ -123,21 +121,17 @@ public class ConnectorStoreAppender extends StoreAppender { if (descriptor instanceof IndexedPropertyDescriptor) { continue; // Indexed properties are not persisted } - if (!isPersistable(descriptor.getPropertyType()) - || (descriptor.getReadMethod() == null) - || (descriptor.getWriteMethod() == null)) { + if (!isPersistable(descriptor.getPropertyType()) || (descriptor.getReadMethod() == null) || + (descriptor.getWriteMethod() == null)) { continue; // Must be a read-write primitive or String } - if ("protocol".equals(descriptor.getName()) - || "protocolHandlerClassName".equals(descriptor - .getName())) { + if ("protocol".equals(descriptor.getName()) || "protocolHandlerClassName".equals(descriptor.getName())) { continue; } propertyKeys.add(descriptor.getName()); } // Add the properties of the protocol handler - descriptors = Introspector.getBeanInfo( - protocolHandler.getClass()).getPropertyDescriptors(); + descriptors = Introspector.getBeanInfo(protocolHandler.getClass()).getPropertyDescriptors(); if (descriptors == null) { descriptors = new PropertyDescriptor[0]; } @@ -145,9 +139,8 @@ public class ConnectorStoreAppender extends StoreAppender { if (descriptor instanceof IndexedPropertyDescriptor) { continue; // Indexed properties are not persisted } - if (!isPersistable(descriptor.getPropertyType()) - || (descriptor.getReadMethod() == null) - || (descriptor.getWriteMethod() == null)) { + if (!isPersistable(descriptor.getPropertyType()) || (descriptor.getReadMethod() == null) || + (descriptor.getWriteMethod() == null)) { continue; // Must be a read-write primitive or String } String key = descriptor.getName(); @@ -164,8 +157,7 @@ public class ConnectorStoreAppender extends StoreAppender { } // Add the properties for the socket final String socketName = "socket."; - descriptors = Introspector.getBeanInfo( - SocketProperties.class).getPropertyDescriptors(); + descriptors = Introspector.getBeanInfo(SocketProperties.class).getPropertyDescriptors(); if (descriptors == null) { descriptors = new PropertyDescriptor[0]; } @@ -173,9 +165,8 @@ public class ConnectorStoreAppender extends StoreAppender { if (descriptor instanceof IndexedPropertyDescriptor) { continue; // Indexed properties are not persisted } - if (!isPersistable(descriptor.getPropertyType()) - || (descriptor.getReadMethod() == null) - || (descriptor.getWriteMethod() == null)) { + if (!isPersistable(descriptor.getPropertyType()) || (descriptor.getReadMethod() == null) || + (descriptor.getWriteMethod() == null)) { continue; // Must be a read-write primitive or String } String key = descriptor.getName(); @@ -195,21 +186,21 @@ public class ConnectorStoreAppender extends StoreAppender { * Print Attributes for the connector * * @param aWriter Current writer - * @param indent Indentation level - * @param bean The connector bean - * @param aDesc The connector description + * @param indent Indentation level + * @param bean The connector bean + * @param aDesc The connector description + * * @throws Exception Store error occurred */ - protected void storeConnectorAttributes(PrintWriter aWriter, int indent, - Object bean, StoreDescription aDesc) throws Exception { + protected void storeConnectorAttributes(PrintWriter aWriter, int indent, Object bean, StoreDescription aDesc) + throws Exception { if (aDesc.isAttributes()) { printAttributes(aWriter, indent, false, bean, aDesc); } } @Override - public void printOpenTag(PrintWriter aWriter, int indent, Object bean, - StoreDescription aDesc) throws Exception { + public void printOpenTag(PrintWriter aWriter, int indent, Object bean, StoreDescription aDesc) throws Exception { aWriter.print("<"); aWriter.print(aDesc.getTag()); storeConnectorAttributes(aWriter, indent, bean, aDesc); @@ -217,8 +208,7 @@ public class ConnectorStoreAppender extends StoreAppender { } @Override - public void printTag(PrintWriter aWriter, int indent, Object bean, - StoreDescription aDesc) throws Exception { + public void printTag(PrintWriter aWriter, int indent, Object bean, StoreDescription aDesc) throws Exception { aWriter.print("<"); aWriter.print(aDesc.getTag()); storeConnectorAttributes(aWriter, indent, bean, aDesc); @@ -226,8 +216,7 @@ public class ConnectorStoreAppender extends StoreAppender { } @Override - public void printValue(PrintWriter writer, int indent, String name, - Object value) { + public void printValue(PrintWriter writer, int indent, String name, Object value) { String repl = name; if (replacements.get(name) != null) { repl = replacements.get(name); @@ -236,22 +225,23 @@ public class ConnectorStoreAppender extends StoreAppender { } /** - * Print Connector Values. <ul><li> Special handling to default jkHome. - * </li><li> Don't save catalina.base path at server.xml</li><li></ul> + * Print Connector Values. + * <ul> + * <li>Special handling to default jkHome.</li> + * <li>Don't save catalina.base path at server.xml</li> + * <li> + * </ul> * - * @see org.apache.catalina.storeconfig.StoreAppender#isPrintValue(Object, - * Object, String, StoreDescription) + * @see org.apache.catalina.storeconfig.StoreAppender#isPrintValue(Object, Object, String, StoreDescription) */ @Override - public boolean isPrintValue(Object bean, Object bean2, String attrName, - StoreDescription desc) { + public boolean isPrintValue(Object bean, Object bean2, String attrName, StoreDescription desc) { boolean isPrint = super.isPrintValue(bean, bean2, attrName, desc); if (isPrint) { if ("jkHome".equals(attrName)) { Connector connector = (Connector) bean; File catalinaBase = getCatalinaBase(); - File jkHomeBase = getJkHomeBase((String) connector - .getProperty("jkHome"), catalinaBase); + File jkHomeBase = getJkHomeBase((String) connector.getProperty("jkHome"), catalinaBase); isPrint = !catalinaBase.equals(jkHomeBase); } diff --git a/java/org/apache/catalina/storeconfig/CredentialHandlerSF.java b/java/org/apache/catalina/storeconfig/CredentialHandlerSF.java index 8685b72c5e..852e0eafaf 100644 --- a/java/org/apache/catalina/storeconfig/CredentialHandlerSF.java +++ b/java/org/apache/catalina/storeconfig/CredentialHandlerSF.java @@ -31,27 +31,22 @@ public class CredentialHandlerSF extends StoreFactoryBase { private static Log log = LogFactory.getLog(CredentialHandlerSF.class); @Override - public void store(PrintWriter aWriter, int indent, Object aElement) - throws Exception { + public void store(PrintWriter aWriter, int indent, Object aElement) throws Exception { if (aElement instanceof NestedCredentialHandler) { - StoreDescription elementDesc = getRegistry().findDescription( - aElement.getClass()); + StoreDescription elementDesc = getRegistry().findDescription(aElement.getClass()); if (elementDesc != null) { if (log.isTraceEnabled()) { - log.trace(sm.getString("factory.storeTag", - elementDesc.getTag(), aElement)); + log.trace(sm.getString("factory.storeTag", elementDesc.getTag(), aElement)); } getStoreAppender().printIndent(aWriter, indent + 2); - getStoreAppender().printOpenTag(aWriter, indent + 2, aElement, - elementDesc); + getStoreAppender().printOpenTag(aWriter, indent + 2, aElement, elementDesc); storeChildren(aWriter, indent + 2, aElement, elementDesc); getStoreAppender().printIndent(aWriter, indent + 2); getStoreAppender().printCloseTag(aWriter, elementDesc); } else { if (log.isWarnEnabled()) { - log.warn(sm.getString("factory.storeNoDescriptor", - aElement.getClass())); + log.warn(sm.getString("factory.storeNoDescriptor", aElement.getClass())); } } } else { @@ -61,11 +56,12 @@ public class CredentialHandlerSF extends StoreFactoryBase { /** * Store the specified CredentialHandler properties and child (CredentialHandler) + * <p> * {@inheritDoc} */ @Override - public void storeChildren(PrintWriter aWriter, int indent, Object aCredentialHandler, - StoreDescription parentDesc) throws Exception { + public void storeChildren(PrintWriter aWriter, int indent, Object aCredentialHandler, StoreDescription parentDesc) + throws Exception { if (aCredentialHandler instanceof NestedCredentialHandler) { NestedCredentialHandler nestedCredentialHandler = (NestedCredentialHandler) aCredentialHandler; diff --git a/java/org/apache/catalina/storeconfig/GlobalNamingResourcesSF.java b/java/org/apache/catalina/storeconfig/GlobalNamingResourcesSF.java index 1a7ca97245..25ac3bd73b 100644 --- a/java/org/apache/catalina/storeconfig/GlobalNamingResourcesSF.java +++ b/java/org/apache/catalina/storeconfig/GlobalNamingResourcesSF.java @@ -29,25 +29,20 @@ public class GlobalNamingResourcesSF extends StoreFactoryBase { private static Log log = LogFactory.getLog(GlobalNamingResourcesSF.class); @Override - public void store(PrintWriter aWriter, int indent, Object aElement) - throws Exception { + public void store(PrintWriter aWriter, int indent, Object aElement) throws Exception { if (aElement instanceof NamingResourcesImpl) { - StoreDescription elementDesc = getRegistry().findDescription( - NamingResourcesImpl.class.getName() - + ".[GlobalNamingResources]"); + StoreDescription elementDesc = + getRegistry().findDescription(NamingResourcesImpl.class.getName() + ".[GlobalNamingResources]"); if (elementDesc != null) { getStoreAppender().printIndent(aWriter, indent + 2); - getStoreAppender().printOpenTag(aWriter, indent + 2, aElement, - elementDesc); + getStoreAppender().printOpenTag(aWriter, indent + 2, aElement, elementDesc); NamingResourcesImpl resources = (NamingResourcesImpl) aElement; - StoreDescription resourcesdesc = getRegistry().findDescription( - NamingResourcesImpl.class.getName()); + StoreDescription resourcesdesc = getRegistry().findDescription(NamingResourcesImpl.class.getName()); if (resourcesdesc != null) { - resourcesdesc.getStoreFactory().store(aWriter, indent + 2, - resources); + resourcesdesc.getStoreFactory().store(aWriter, indent + 2, resources); } else { log.warn(sm.getString("globalNamingResourcesSF.noFactory")); } diff --git a/java/org/apache/catalina/storeconfig/IStoreConfig.java b/java/org/apache/catalina/storeconfig/IStoreConfig.java index 2d96b47ea2..a6a9e7698d 100644 --- a/java/org/apache/catalina/storeconfig/IStoreConfig.java +++ b/java/org/apache/catalina/storeconfig/IStoreConfig.java @@ -35,8 +35,7 @@ public interface IStoreConfig { /** * Set Configuration Registry * - * @param aRegistry - * aregistry that handle the store operations + * @param aRegistry aregistry that handle the store operations */ void setRegistry(StoreRegistry aRegistry); @@ -60,10 +59,10 @@ public interface IStoreConfig { void storeConfig(); /** - * Write the configuration information for this entire <code>Server</code> - * out to the server.xml configuration file. + * Write the configuration information for this entire <code>Server</code> out to the server.xml configuration file. * * @param aServer Server instance + * * @return <code>true</code> if the store operation was successful */ boolean store(Server aServer); @@ -71,12 +70,10 @@ public interface IStoreConfig { /** * Store the specified Server properties. * - * @param aWriter - * PrintWriter to which we are storing - * @param indent - * Number of spaces to indent this element - * @param aServer - * Object to be stored + * @param aWriter PrintWriter to which we are storing + * @param indent Number of spaces to indent this element + * @param aServer Object to be stored + * * @throws Exception Store error occurred */ void store(PrintWriter aWriter, int indent, Server aServer) throws Exception; @@ -84,12 +81,10 @@ public interface IStoreConfig { /** * Store the specified Service properties. * - * @param aWriter - * PrintWriter to which we are storing - * @param indent - * Number of spaces to indent this element - * @param aService - * Object to be stored + * @param aWriter PrintWriter to which we are storing + * @param indent Number of spaces to indent this element + * @param aService Object to be stored + * * @throws Exception Store error occurred */ void store(PrintWriter aWriter, int indent, Service aService) throws Exception; @@ -97,12 +92,10 @@ public interface IStoreConfig { /** * Store the specified Host properties. * - * @param aWriter - * PrintWriter to which we are storing - * @param indent - * Number of spaces to indent this element - * @param aHost - * Object to be stored + * @param aWriter PrintWriter to which we are storing + * @param indent Number of spaces to indent this element + * @param aHost Object to be stored + * * @throws Exception Store error occurred */ void store(PrintWriter aWriter, int indent, Host aHost) throws Exception; @@ -110,8 +103,8 @@ public interface IStoreConfig { /** * Store the specified Context properties. * - * @param aContext - * Object to be stored + * @param aContext Object to be stored + * * @return <code>true</code> if the store operation was successful */ boolean store(Context aContext); @@ -119,12 +112,10 @@ public interface IStoreConfig { /** * Store the specified Context properties. * - * @param aWriter - * PrintWriter to which we are storing - * @param indent - * Number of spaces to indent this element - * @param aContext - * Object to be stored + * @param aWriter PrintWriter to which we are storing + * @param indent Number of spaces to indent this element + * @param aContext Object to be stored + * * @throws Exception Store error occurred */ void store(PrintWriter aWriter, int indent, Context aContext) throws Exception; diff --git a/java/org/apache/catalina/storeconfig/IStoreFactory.java b/java/org/apache/catalina/storeconfig/IStoreFactory.java index 6f1d95bdd4..678092d4db 100644 --- a/java/org/apache/catalina/storeconfig/IStoreFactory.java +++ b/java/org/apache/catalina/storeconfig/IStoreFactory.java @@ -27,12 +27,14 @@ public interface IStoreFactory { /** * Set the store appender. + * * @param storeWriter the writer */ void setStoreAppender(StoreAppender storeWriter); /** * Set the registry. + * * @param aRegistry the registry to be associated with */ void setRegistry(StoreRegistry aRegistry); @@ -45,16 +47,17 @@ public interface IStoreFactory { /** * Store a server.xml element with attributes and children. * - * @param aWriter the writer to write to - * @param indent the indentation + * @param aWriter the writer to write to + * @param indent the indentation * @param aElement the element to write + * * @throws Exception if an error occurs */ - void store(PrintWriter aWriter, int indent, Object aElement) - throws Exception; + void store(PrintWriter aWriter, int indent, Object aElement) throws Exception; /** * Store XML header. + * * @param aWriter the writer to write to */ void storeXMLHead(PrintWriter aWriter); diff --git a/java/org/apache/catalina/storeconfig/InterceptorSF.java b/java/org/apache/catalina/storeconfig/InterceptorSF.java index 06b155d43d..08b231b1f5 100644 --- a/java/org/apache/catalina/storeconfig/InterceptorSF.java +++ b/java/org/apache/catalina/storeconfig/InterceptorSF.java @@ -31,27 +31,22 @@ public class InterceptorSF extends StoreFactoryBase { private static Log log = LogFactory.getLog(InterceptorSF.class); @Override - public void store(PrintWriter aWriter, int indent, Object aElement) - throws Exception { + public void store(PrintWriter aWriter, int indent, Object aElement) throws Exception { if (aElement instanceof StaticMembershipInterceptor) { - StoreDescription elementDesc = getRegistry().findDescription( - aElement.getClass()); + StoreDescription elementDesc = getRegistry().findDescription(aElement.getClass()); if (elementDesc != null) { if (log.isTraceEnabled()) { - log.trace(sm.getString("factory.storeTag", - elementDesc.getTag(), aElement)); + log.trace(sm.getString("factory.storeTag", elementDesc.getTag(), aElement)); } getStoreAppender().printIndent(aWriter, indent + 2); - getStoreAppender().printOpenTag(aWriter, indent + 2, aElement, - elementDesc); + getStoreAppender().printOpenTag(aWriter, indent + 2, aElement, elementDesc); storeChildren(aWriter, indent + 2, aElement, elementDesc); getStoreAppender().printIndent(aWriter, indent + 2); getStoreAppender().printCloseTag(aWriter, elementDesc); } else { if (log.isWarnEnabled()) { - log.warn(sm.getString("factory.storeNoDescriptor", - aElement.getClass())); + log.warn(sm.getString("factory.storeNoDescriptor", aElement.getClass())); } } } else { @@ -61,15 +56,16 @@ public class InterceptorSF extends StoreFactoryBase { /** * Store the specified Interceptor child. + * <p> * {@inheritDoc} */ @Override - public void storeChildren(PrintWriter aWriter, int indent, Object aInterceptor, - StoreDescription parentDesc) throws Exception { + public void storeChildren(PrintWriter aWriter, int indent, Object aInterceptor, StoreDescription parentDesc) + throws Exception { if (aInterceptor instanceof StaticMembershipInterceptor) { ChannelInterceptor interceptor = (ChannelInterceptor) aInterceptor; // Store nested <Member> elements storeElementArray(aWriter, indent + 2, interceptor.getMembers()); - } + } } } \ No newline at end of file diff --git a/java/org/apache/catalina/storeconfig/JarScannerSF.java b/java/org/apache/catalina/storeconfig/JarScannerSF.java index f863e49e2f..78e949a141 100644 --- a/java/org/apache/catalina/storeconfig/JarScannerSF.java +++ b/java/org/apache/catalina/storeconfig/JarScannerSF.java @@ -27,13 +27,13 @@ import org.apache.tomcat.JarScanner; public class JarScannerSF extends StoreFactoryBase { /** - * Store the specified JarScanner properties and children - * (JarScannerFilter) + * Store the specified JarScanner properties and children (JarScannerFilter) + * <p> * {@inheritDoc} */ @Override - public void storeChildren(PrintWriter aWriter, int indent, Object aJarScanner, - StoreDescription parentDesc) throws Exception { + public void storeChildren(PrintWriter aWriter, int indent, Object aJarScanner, StoreDescription parentDesc) + throws Exception { if (aJarScanner instanceof JarScanner) { JarScanner jarScanner = (JarScanner) aJarScanner; // Store nested <JarScanFilter> element diff --git a/java/org/apache/catalina/storeconfig/LoaderSF.java b/java/org/apache/catalina/storeconfig/LoaderSF.java index dae8acd114..be19e094a3 100644 --- a/java/org/apache/catalina/storeconfig/LoaderSF.java +++ b/java/org/apache/catalina/storeconfig/LoaderSF.java @@ -31,10 +31,8 @@ public class LoaderSF extends StoreFactoryBase { private static Log log = LogFactory.getLog(LoaderSF.class); @Override - public void store(PrintWriter aWriter, int indent, Object aElement) - throws Exception { - StoreDescription elementDesc = getRegistry().findDescription( - aElement.getClass()); + public void store(PrintWriter aWriter, int indent, Object aElement) throws Exception { + StoreDescription elementDesc = getRegistry().findDescription(aElement.getClass()); if (elementDesc != null) { Loader loader = (Loader) aElement; if (!isDefaultLoader(loader)) { @@ -42,25 +40,22 @@ public class LoaderSF extends StoreFactoryBase { log.trace("store " + elementDesc.getTag() + "( " + aElement + " )"); } getStoreAppender().printIndent(aWriter, indent + 2); - getStoreAppender().printTag(aWriter, indent + 2, loader, - elementDesc); + getStoreAppender().printTag(aWriter, indent + 2, loader, elementDesc); } } else { if (log.isWarnEnabled()) { if (log.isWarnEnabled()) { - log.warn(sm.getString("factory.storeNoDescriptor", aElement - .getClass())); + log.warn(sm.getString("factory.storeNoDescriptor", aElement.getClass())); } } } } /** - * Is this an instance of the default <code>Loader</code> configuration, - * with all-default properties? + * Is this an instance of the default <code>Loader</code> configuration, with all-default properties? + * + * @param loader Loader to be tested * - * @param loader - * Loader to be tested * @return <code>true</code> if this is an instance of the default loader */ protected boolean isDefaultLoader(Loader loader) { @@ -69,9 +64,8 @@ public class LoaderSF extends StoreFactoryBase { return false; } WebappLoader wloader = (WebappLoader) loader; - if ((wloader.getDelegate() != false) - || !wloader.getLoaderClass().equals( - "org.apache.catalina.loader.WebappClassLoader")) { + if ((wloader.getDelegate() != false) || + !wloader.getLoaderClass().equals("org.apache.catalina.loader.WebappClassLoader")) { return false; } return true; diff --git a/java/org/apache/catalina/storeconfig/ManagerSF.java b/java/org/apache/catalina/storeconfig/ManagerSF.java index 3d4781929b..06397f6576 100644 --- a/java/org/apache/catalina/storeconfig/ManagerSF.java +++ b/java/org/apache/catalina/storeconfig/ManagerSF.java @@ -32,17 +32,14 @@ public class ManagerSF extends StoreFactoryBase { private static Log log = LogFactory.getLog(ManagerSF.class); @Override - public void store(PrintWriter aWriter, int indent, Object aElement) - throws Exception { - StoreDescription elementDesc = getRegistry().findDescription( - aElement.getClass()); + public void store(PrintWriter aWriter, int indent, Object aElement) throws Exception { + StoreDescription elementDesc = getRegistry().findDescription(aElement.getClass()); if (elementDesc != null) { if (aElement instanceof StandardManager) { StandardManager manager = (StandardManager) aElement; if (!isDefaultManager(manager)) { if (log.isTraceEnabled()) { - log.trace(sm.getString("factory.storeTag", elementDesc - .getTag(), aElement)); + log.trace(sm.getString("factory.storeTag", elementDesc.getTag(), aElement)); } super.store(aWriter, indent, aElement); } @@ -51,24 +48,21 @@ public class ManagerSF extends StoreFactoryBase { } } else { if (log.isWarnEnabled()) { - log.warn(sm.getString("factory.storeNoDescriptor", aElement - .getClass())); + log.warn(sm.getString("factory.storeNoDescriptor", aElement.getClass())); } } } /** - * Is this an instance of the default <code>Manager</code> configuration, - * with all-default properties? + * Is this an instance of the default <code>Manager</code> configuration, with all-default properties? + * + * @param smanager Manager to be tested * - * @param smanager - * Manager to be tested * @return <code>true</code> if this is an instance of the default manager */ protected boolean isDefaultManager(StandardManager smanager) { - if (!"SESSIONS.ser".equals(smanager.getPathname()) - || (smanager.getMaxActiveSessions() != -1)) { + if (!"SESSIONS.ser".equals(smanager.getPathname()) || (smanager.getMaxActiveSessions() != -1)) { return false; } return true; @@ -76,8 +70,8 @@ public class ManagerSF extends StoreFactoryBase { } @Override - public void storeChildren(PrintWriter aWriter, int indent, Object aManager, - StoreDescription parentDesc) throws Exception { + public void storeChildren(PrintWriter aWriter, int indent, Object aManager, StoreDescription parentDesc) + throws Exception { if (aManager instanceof Manager) { Manager manager = (Manager) aManager; // Store nested <SessionIdGenerator> element; diff --git a/java/org/apache/catalina/storeconfig/NamingResourcesSF.java b/java/org/apache/catalina/storeconfig/NamingResourcesSF.java index 1a33aa58e4..f7f610bc02 100644 --- a/java/org/apache/catalina/storeconfig/NamingResourcesSF.java +++ b/java/org/apache/catalina/storeconfig/NamingResourcesSF.java @@ -35,10 +35,8 @@ public class NamingResourcesSF extends StoreFactoryBase { private static Log log = LogFactory.getLog(NamingResourcesSF.class); @Override - public void store(PrintWriter aWriter, int indent, Object aElement) - throws Exception { - StoreDescription elementDesc = getRegistry().findDescription( - aElement.getClass()); + public void store(PrintWriter aWriter, int indent, Object aElement) throws Exception { + StoreDescription elementDesc = getRegistry().findDescription(aElement.getClass()); if (elementDesc != null) { if (log.isTraceEnabled()) { log.trace("store " + elementDesc.getTag() + "( " + aElement + " )"); @@ -51,11 +49,12 @@ public class NamingResourcesSF extends StoreFactoryBase { /** * Store the specified NamingResources properties. + * <p> * {@inheritDoc} */ @Override - public void storeChildren(PrintWriter aWriter, int indent, Object aElement, - StoreDescription elementDesc) throws Exception { + public void storeChildren(PrintWriter aWriter, int indent, Object aElement, StoreDescription elementDesc) + throws Exception { if (aElement instanceof NamingResourcesImpl) { NamingResourcesImpl resources = (NamingResourcesImpl) aElement; diff --git a/java/org/apache/catalina/storeconfig/OpenSSLConfSF.java b/java/org/apache/catalina/storeconfig/OpenSSLConfSF.java index 8fcd6e729b..b0362757fa 100644 --- a/java/org/apache/catalina/storeconfig/OpenSSLConfSF.java +++ b/java/org/apache/catalina/storeconfig/OpenSSLConfSF.java @@ -28,11 +28,12 @@ public class OpenSSLConfSF extends StoreFactoryBase { /** * Store nested OpenSSLConfCmd elements. + * <p> * {@inheritDoc} */ @Override - public void storeChildren(PrintWriter aWriter, int indent, Object aOpenSSLConf, - StoreDescription parentDesc) throws Exception { + public void storeChildren(PrintWriter aWriter, int indent, Object aOpenSSLConf, StoreDescription parentDesc) + throws Exception { if (aOpenSSLConf instanceof OpenSSLConf) { OpenSSLConf openSslConf = (OpenSSLConf) aOpenSSLConf; // Store nested <OpenSSLConfCmd> elements diff --git a/java/org/apache/catalina/storeconfig/PersistentManagerSF.java b/java/org/apache/catalina/storeconfig/PersistentManagerSF.java index 88129d31c2..6e237871f1 100644 --- a/java/org/apache/catalina/storeconfig/PersistentManagerSF.java +++ b/java/org/apache/catalina/storeconfig/PersistentManagerSF.java @@ -29,11 +29,12 @@ public class PersistentManagerSF extends StoreFactoryBase { /** * Store the specified PersistentManager properties. + * <p> * {@inheritDoc} */ @Override - public void storeChildren(PrintWriter aWriter, int indent, Object aManager, - StoreDescription parentDesc) throws Exception { + public void storeChildren(PrintWriter aWriter, int indent, Object aManager, StoreDescription parentDesc) + throws Exception { if (aManager instanceof PersistentManager) { PersistentManager manager = (PersistentManager) aManager; diff --git a/java/org/apache/catalina/storeconfig/RealmSF.java b/java/org/apache/catalina/storeconfig/RealmSF.java index 84ce263cae..7afdf02c3c 100644 --- a/java/org/apache/catalina/storeconfig/RealmSF.java +++ b/java/org/apache/catalina/storeconfig/RealmSF.java @@ -32,27 +32,22 @@ public class RealmSF extends StoreFactoryBase { private static Log log = LogFactory.getLog(RealmSF.class); @Override - public void store(PrintWriter aWriter, int indent, Object aElement) - throws Exception { + public void store(PrintWriter aWriter, int indent, Object aElement) throws Exception { if (aElement instanceof CombinedRealm) { - StoreDescription elementDesc = getRegistry().findDescription( - aElement.getClass()); + StoreDescription elementDesc = getRegistry().findDescription(aElement.getClass()); if (elementDesc != null) { if (log.isTraceEnabled()) { - log.trace(sm.getString("factory.storeTag", - elementDesc.getTag(), aElement)); + log.trace(sm.getString("factory.storeTag", elementDesc.getTag(), aElement)); } getStoreAppender().printIndent(aWriter, indent + 2); - getStoreAppender().printOpenTag(aWriter, indent + 2, aElement, - elementDesc); + getStoreAppender().printOpenTag(aWriter, indent + 2, aElement, elementDesc); storeChildren(aWriter, indent + 2, aElement, elementDesc); getStoreAppender().printIndent(aWriter, indent + 2); getStoreAppender().printCloseTag(aWriter, elementDesc); } else { if (log.isWarnEnabled()) { - log.warn(sm.getString("factory.storeNoDescriptor", - aElement.getClass())); + log.warn(sm.getString("factory.storeNoDescriptor", aElement.getClass())); } } } else { @@ -61,12 +56,11 @@ public class RealmSF extends StoreFactoryBase { } /** - * Store the specified Realm properties and child (Realm) - * {@inheritDoc} + * Store the specified Realm properties and child (Realm) {@inheritDoc} */ @Override - public void storeChildren(PrintWriter aWriter, int indent, Object aRealm, - StoreDescription parentDesc) throws Exception { + public void storeChildren(PrintWriter aWriter, int indent, Object aRealm, StoreDescription parentDesc) + throws Exception { if (aRealm instanceof CombinedRealm) { CombinedRealm combinedRealm = (CombinedRealm) aRealm; @@ -76,8 +70,8 @@ public class RealmSF extends StoreFactoryBase { } // Store nested <CredentialHandler> element CredentialHandler credentialHandler = ((Realm) aRealm).getCredentialHandler(); - if (credentialHandler != null - && !(credentialHandler.getClass().getName().equals("org.apache.catalina.realm.CombinedRealm$CombinedRealmCredentialHandler"))) { + if (credentialHandler != null && !(credentialHandler.getClass().getName() + .equals("org.apache.catalina.realm.CombinedRealm$CombinedRealmCredentialHandler"))) { storeElement(aWriter, indent, credentialHandler); } } diff --git a/java/org/apache/catalina/storeconfig/SSLHostConfigSF.java b/java/org/apache/catalina/storeconfig/SSLHostConfigSF.java index 2efdc050f0..44bad1d973 100644 --- a/java/org/apache/catalina/storeconfig/SSLHostConfigSF.java +++ b/java/org/apache/catalina/storeconfig/SSLHostConfigSF.java @@ -31,15 +31,17 @@ public class SSLHostConfigSF extends StoreFactoryBase { /** * Store nested SSLHostConfigCertificate elements. + * <p> * {@inheritDoc} */ @Override - public void storeChildren(PrintWriter aWriter, int indent, Object aSSLHostConfig, - StoreDescription parentDesc) throws Exception { + public void storeChildren(PrintWriter aWriter, int indent, Object aSSLHostConfig, StoreDescription parentDesc) + throws Exception { if (aSSLHostConfig instanceof SSLHostConfig) { SSLHostConfig sslHostConfig = (SSLHostConfig) aSSLHostConfig; // Store nested <SSLHostConfigCertificate> elements - SSLHostConfigCertificate[] hostConfigsCertificates = sslHostConfig.getCertificates().toArray(new SSLHostConfigCertificate[0]); + SSLHostConfigCertificate[] hostConfigsCertificates = + sslHostConfig.getCertificates().toArray(new SSLHostConfigCertificate[0]); // Remove a possible default UNDEFINED certificate if (hostConfigsCertificates.length > 1) { ArrayList<SSLHostConfigCertificate> certificates = new ArrayList<>(); diff --git a/java/org/apache/catalina/storeconfig/SenderSF.java b/java/org/apache/catalina/storeconfig/SenderSF.java index 7ce5e1e5ab..58c9d74714 100644 --- a/java/org/apache/catalina/storeconfig/SenderSF.java +++ b/java/org/apache/catalina/storeconfig/SenderSF.java @@ -28,11 +28,12 @@ public class SenderSF extends StoreFactoryBase { /** * Store the specified Sender child. + * <p> * {@inheritDoc} */ @Override - public void storeChildren(PrintWriter aWriter, int indent, Object aSender, - StoreDescription parentDesc) throws Exception { + public void storeChildren(PrintWriter aWriter, int indent, Object aSender, StoreDescription parentDesc) + throws Exception { if (aSender instanceof ReplicationTransmitter) { ReplicationTransmitter transmitter = (ReplicationTransmitter) aSender; // Store nested <Transport> element @@ -40,6 +41,6 @@ public class SenderSF extends StoreFactoryBase { if (transport != null) { storeElement(aWriter, indent, transport); } - } + } } } \ No newline at end of file diff --git a/java/org/apache/catalina/storeconfig/StandardContextSF.java b/java/org/apache/catalina/storeconfig/StandardContextSF.java index 1c3a41ddc7..cb826a7f69 100644 --- a/java/org/apache/catalina/storeconfig/StandardContextSF.java +++ b/java/org/apache/catalina/storeconfig/StandardContextSF.java @@ -59,29 +59,24 @@ public class StandardContextSF extends StoreFactoryBase { private static Log log = LogFactory.getLog(StandardContextSF.class); /** - * Store a Context as Separate file as configFile value from context exists. - * filename can be relative to catalina.base. + * Store a Context as Separate file as configFile value from context exists. filename can be relative to + * catalina.base. * - * @see org.apache.catalina.storeconfig.IStoreFactory#store(java.io.PrintWriter, - * int, java.lang.Object) + * @see org.apache.catalina.storeconfig.IStoreFactory#store(java.io.PrintWriter, int, java.lang.Object) */ @Override - public void store(PrintWriter aWriter, int indent, Object aContext) - throws Exception { + public void store(PrintWriter aWriter, int indent, Object aContext) throws Exception { if (aContext instanceof StandardContext) { - StoreDescription desc = getRegistry().findDescription( - aContext.getClass()); + StoreDescription desc = getRegistry().findDescription(aContext.getClass()); if (desc != null && desc.isStoreSeparate()) { - URL configFile = ((StandardContext) aContext) - .getConfigFile(); + URL configFile = ((StandardContext) aContext).getConfigFile(); if (configFile != null) { if (desc.isExternalAllowed()) { if (desc.isBackup()) { storeWithBackup((StandardContext) aContext); } else { - storeContextSeparate(aWriter, indent, - (StandardContext) aContext); + storeContextSeparate(aWriter, indent, (StandardContext) aContext); } return; } @@ -97,8 +92,7 @@ public class StandardContextSF extends StoreFactoryBase { if (desc.isBackup()) { storeWithBackup((StandardContext) aContext); } else { - storeContextSeparate(aWriter, indent, - (StandardContext) aContext); + storeContextSeparate(aWriter, indent, (StandardContext) aContext); } return; } @@ -109,32 +103,29 @@ public class StandardContextSF extends StoreFactoryBase { } /** - * Store a Context without backup add separate file or when configFile = - * null a aWriter. + * Store a Context without backup add separate file or when configFile = null a aWriter. * - * @param aWriter Current output writer - * @param indent Indentation level + * @param aWriter Current output writer + * @param indent Indentation level * @param aContext The context which will be stored + * * @throws Exception Configuration storing error */ - protected void storeContextSeparate(PrintWriter aWriter, int indent, - StandardContext aContext) throws Exception { + protected void storeContextSeparate(PrintWriter aWriter, int indent, StandardContext aContext) throws Exception { URL configFile = aContext.getConfigFile(); if (configFile != null) { File config = new File(configFile.toURI()); if (!config.isAbsolute()) { - config = new File(System.getProperty(Globals.CATALINA_BASE_PROP), - config.getPath()); + config = new File(System.getProperty(Globals.CATALINA_BASE_PROP), config.getPath()); } - if( (!config.isFile()) || (!config.canWrite())) { + if ((!config.isFile()) || (!config.canWrite())) { throw new IOException(sm.getString("standardContextSF.cannotWriteFile", configFile)); } if (log.isInfoEnabled()) { log.info(sm.getString("standardContextSF.storeContext", aContext.getPath(), config)); } try (FileOutputStream fos = new FileOutputStream(config); - PrintWriter writer = new PrintWriter(new OutputStreamWriter( - fos , getRegistry().getEncoding()))) { + PrintWriter writer = new PrintWriter(new OutputStreamWriter(fos, getRegistry().getEncoding()))) { storeXMLHead(writer); super.store(writer, -2, aContext); } @@ -147,16 +138,15 @@ public class StandardContextSF extends StoreFactoryBase { * Store the Context with a Backup. * * @param aContext The context which will be stored + * * @throws Exception Configuration storing error */ protected void storeWithBackup(StandardContext aContext) throws Exception { StoreFileMover mover = getConfigFileWriter(aContext); if (mover != null) { // Bugzilla 37781 Check to make sure we can write this output file - if ((mover.getConfigOld() == null) - || (mover.getConfigOld().isDirectory()) - || (mover.getConfigOld().exists() && - !mover.getConfigOld().canWrite())) { + if ((mover.getConfigOld() == null) || (mover.getConfigOld().isDirectory()) || + (mover.getConfigOld().exists() && !mover.getConfigOld().canWrite())) { throw new IOException(sm.getString("standardContextSF.moveFailed", mover.getConfigOld())); } File dir = mover.getConfigSave().getParentFile(); @@ -164,8 +154,8 @@ public class StandardContextSF extends StoreFactoryBase { throw new IOException(sm.getString("standardContextSF.cannotWriteFile", mover.getConfigSave())); } if (log.isInfoEnabled()) { - log.info(sm.getString("standardContextSF.storeContextWithBackup", - aContext.getPath(), mover.getConfigSave())); + log.info(sm.getString("standardContextSF.storeContextWithBackup", aContext.getPath(), + mover.getConfigSave())); } try (PrintWriter writer = mover.getWriter()) { storeXMLHead(writer); @@ -179,33 +169,33 @@ public class StandardContextSF extends StoreFactoryBase { * Get explicit writer for context (context.getConfigFile()). * * @param context The context which will be stored + * * @return The file mover + * * @throws Exception Error getting a writer for the configuration file */ - protected StoreFileMover getConfigFileWriter(Context context) - throws Exception { + protected StoreFileMover getConfigFileWriter(Context context) throws Exception { URL configFile = context.getConfigFile(); StoreFileMover mover = null; if (configFile != null) { File config = new File(configFile.toURI()); if (!config.isAbsolute()) { - config = new File(System.getProperty(Globals.CATALINA_BASE_PROP), - config.getPath()); + config = new File(System.getProperty(Globals.CATALINA_BASE_PROP), config.getPath()); } // Open an output writer for the new configuration file - mover = new StoreFileMover("", config.getCanonicalPath(), - getRegistry().getEncoding()); + mover = new StoreFileMover("", config.getCanonicalPath(), getRegistry().getEncoding()); } return mover; } /** * Store the specified context element children. + * <p> * {@inheritDoc} */ @Override - public void storeChildren(PrintWriter aWriter, int indent, Object aContext, - StoreDescription parentDesc) throws Exception { + public void storeChildren(PrintWriter aWriter, int indent, Object aContext, StoreDescription parentDesc) + throws Exception { if (aContext instanceof StandardContext) { StandardContext context = (StandardContext) aContext; // Store nested <Listener> elements @@ -250,16 +240,13 @@ public class StandardContextSF extends StoreFactoryBase { // Store nested <WrapperListener> elements String wLifecycles[] = context.findWrapperLifecycles(); - getStoreAppender().printTagArray(aWriter, "WrapperListener", - indent + 2, wLifecycles); + getStoreAppender().printTagArray(aWriter, "WrapperListener", indent + 2, wLifecycles); // Store nested <WrapperLifecycle> elements String wListeners[] = context.findWrapperListeners(); - getStoreAppender().printTagArray(aWriter, "WrapperLifecycle", - indent + 2, wListeners); + getStoreAppender().printTagArray(aWriter, "WrapperLifecycle", indent + 2, wListeners); // Store nested <Parameter> elements - ApplicationParameter[] appParams = context - .findApplicationParameters(); + ApplicationParameter[] appParams = context.findApplicationParameters(); storeElementArray(aWriter, indent, appParams); // Store nested naming resources elements (EJB,Resource,...) @@ -269,8 +256,7 @@ public class StandardContextSF extends StoreFactoryBase { // Store nested watched resources <WatchedResource> String[] wresources = context.findWatchedResources(); wresources = filterWatchedResources(context, wresources); - getStoreAppender().printTagArray(aWriter, "WatchedResource", - indent + 2, wresources); + getStoreAppender().printTagArray(aWriter, "WatchedResource", indent + 2, wresources); // Store nested <JarScanner> elements JarScanner jarScanner = context.getJarScanner(); @@ -283,9 +269,10 @@ public class StandardContextSF extends StoreFactoryBase { } /** - * Return a File object representing the "configuration root" directory for - * our associated Host. + * Return a File object representing the "configuration root" directory for our associated Host. + * * @param context The context instance + * * @return a file to the configuration base path */ protected File configBase(Context context) { @@ -311,26 +298,30 @@ public class StandardContextSF extends StoreFactoryBase { /** * Filter out the default watched resources, to remove standard ones. - * - * @param context The context instance - * @param wresources The raw watched resources list - * @return The filtered watched resources - * @throws Exception Configuration storing error + * <p> * TODO relative watched resources + * <p> * TODO absolute handling configFile + * <p> * TODO Filename case handling for Windows? + * <p> * TODO digester variable substitution $catalina.base, $catalina.home + * + * @param context The context instance + * @param wresources The raw watched resources list + * + * @return The filtered watched resources + * + * @throws Exception Configuration storing error */ - protected String[] filterWatchedResources(StandardContext context, - String[] wresources) throws Exception { + protected String[] filterWatchedResources(StandardContext context, String[] wresources) throws Exception { File configBase = configBase(context); - String confContext = new File(System.getProperty(Globals.CATALINA_BASE_PROP), - "conf/context.xml").getCanonicalPath(); - String confWeb = new File(System.getProperty(Globals.CATALINA_BASE_PROP), - "conf/web.xml").getCanonicalPath(); - String confHostDefault = new File(configBase, "context.xml.default") - .getCanonicalPath(); - String configFile = (context.getConfigFile() != null ? new File(context.getConfigFile().toURI()).getCanonicalPath() : null); + String confContext = + new File(System.getProperty(Globals.CATALINA_BASE_PROP), "conf/context.xml").getCanonicalPath(); + String confWeb = new File(System.getProperty(Globals.CATALINA_BASE_PROP), "conf/web.xml").getCanonicalPath(); + String confHostDefault = new File(configBase, "context.xml.default").getCanonicalPath(); + String configFile = + (context.getConfigFile() != null ? new File(context.getConfigFile().toURI()).getCanonicalPath() : null); String webxml = "WEB-INF/web.xml"; String tomcatwebxml = "WEB-INF/tomcat-web.xml"; diff --git a/java/org/apache/catalina/storeconfig/StandardEngineSF.java b/java/org/apache/catalina/storeconfig/StandardEngineSF.java index 5b7fabaa7c..806de0f4d3 100644 --- a/java/org/apache/catalina/storeconfig/StandardEngineSF.java +++ b/java/org/apache/catalina/storeconfig/StandardEngineSF.java @@ -35,11 +35,12 @@ public class StandardEngineSF extends StoreFactoryBase { /** * Store the specified Engine properties. + * <p> * {@inheritDoc} */ @Override - public void storeChildren(PrintWriter aWriter, int indent, Object aEngine, - StoreDescription parentDesc) throws Exception { + public void storeChildren(PrintWriter aWriter, int indent, Object aEngine, StoreDescription parentDesc) + throws Exception { if (aEngine instanceof StandardEngine) { StandardEngine engine = (StandardEngine) aEngine; // Store nested <Listener> elements @@ -60,8 +61,8 @@ public class StandardEngineSF extends StoreFactoryBase { // Store nested <Valve> elements Valve valves[] = engine.getPipeline().getValves(); - if(valves != null && valves.length > 0 ) { - List<Valve> engineValves = new ArrayList<>() ; + if (valves != null && valves.length > 0) { + List<Valve> engineValves = new ArrayList<>(); for (Valve valve : valves) { if (!(valve instanceof ClusterValve)) { engineValves.add(valve); @@ -79,6 +80,6 @@ public class StandardEngineSF extends StoreFactoryBase { Container children[] = engine.findChildren(); storeElementArray(aWriter, indent, children); - } + } } } \ No newline at end of file diff --git a/java/org/apache/catalina/storeconfig/StandardHostSF.java b/java/org/apache/catalina/storeconfig/StandardHostSF.java index f6b610c4e4..7c51c47b31 100644 --- a/java/org/apache/catalina/storeconfig/StandardHostSF.java +++ b/java/org/apache/catalina/storeconfig/StandardHostSF.java @@ -34,13 +34,13 @@ import org.apache.catalina.ha.ClusterValve; public class StandardHostSF extends StoreFactoryBase { /** - * Store the specified Host properties and children - * (Listener,Alias,Realm,Valve,Cluster, Context) + * Store the specified Host properties and children (Listener,Alias,Realm,Valve,Cluster, Context) + * <p> * {@inheritDoc} */ @Override - public void storeChildren(PrintWriter aWriter, int indent, Object aHost, - StoreDescription parentDesc) throws Exception { + public void storeChildren(PrintWriter aWriter, int indent, Object aHost, StoreDescription parentDesc) + throws Exception { if (aHost instanceof StandardHost) { StandardHost host = (StandardHost) aHost; // Store nested <Listener> elements @@ -49,8 +49,7 @@ public class StandardHostSF extends StoreFactoryBase { // Store nested <Alias> elements String aliases[] = host.findAliases(); - getStoreAppender().printTagArray(aWriter, "Alias", indent + 2, - aliases); + getStoreAppender().printTagArray(aWriter, "Alias", indent + 2, aliases); // Store nested <Realm> element Realm realm = host.getRealm(); @@ -66,8 +65,8 @@ public class StandardHostSF extends StoreFactoryBase { // Store nested <Valve> elements Valve valves[] = host.getPipeline().getValves(); - if(valves != null && valves.length > 0 ) { - List<Valve> hostValves = new ArrayList<>() ; + if (valves != null && valves.length > 0) { + List<Valve> hostValves = new ArrayList<>(); for (Valve valve : valves) { if (!(valve instanceof ClusterValve)) { hostValves.add(valve); diff --git a/java/org/apache/catalina/storeconfig/StandardServerSF.java b/java/org/apache/catalina/storeconfig/StandardServerSF.java index e1133f3921..213cfb3730 100644 --- a/java/org/apache/catalina/storeconfig/StandardServerSF.java +++ b/java/org/apache/catalina/storeconfig/StandardServerSF.java @@ -24,39 +24,35 @@ import org.apache.catalina.core.StandardServer; import org.apache.catalina.deploy.NamingResourcesImpl; /** - * Store server.xml Server element and children ( - * Listener,GlobalNamingResource,Service) + * Store server.xml Server element and children ( Listener,GlobalNamingResource,Service) */ public class StandardServerSF extends StoreFactoryBase { @Override - public void store(PrintWriter aWriter, int indent, Object aServer) - throws Exception { + public void store(PrintWriter aWriter, int indent, Object aServer) throws Exception { storeXMLHead(aWriter); super.store(aWriter, indent, aServer); } /** * Store the specified server element children. + * <p> * {@inheritDoc} */ @Override - public void storeChildren(PrintWriter aWriter, int indent, Object aObject, - StoreDescription parentDesc) throws Exception { + public void storeChildren(PrintWriter aWriter, int indent, Object aObject, StoreDescription parentDesc) + throws Exception { if (aObject instanceof StandardServer) { StandardServer server = (StandardServer) aObject; // Store nested <Listener> elements LifecycleListener listeners[] = server.findLifecycleListeners(); storeElementArray(aWriter, indent, listeners); // Store nested <GlobalNamingResources> element - NamingResourcesImpl globalNamingResources = server - .getGlobalNamingResources(); - StoreDescription elementDesc = getRegistry().findDescription( - NamingResourcesImpl.class.getName() - + ".[GlobalNamingResources]"); + NamingResourcesImpl globalNamingResources = server.getGlobalNamingResources(); + StoreDescription elementDesc = + getRegistry().findDescription(NamingResourcesImpl.class.getName() + ".[GlobalNamingResources]"); if (elementDesc != null) { - elementDesc.getStoreFactory().store(aWriter, indent, - globalNamingResources); + elementDesc.getStoreFactory().store(aWriter, indent, globalNamingResources); } // Store nested <Service> elements Service services[] = server.findServices(); diff --git a/java/org/apache/catalina/storeconfig/StandardServiceSF.java b/java/org/apache/catalina/storeconfig/StandardServiceSF.java index b069e7b29f..907e76bb0b 100644 --- a/java/org/apache/catalina/storeconfig/StandardServiceSF.java +++ b/java/org/apache/catalina/storeconfig/StandardServiceSF.java @@ -31,11 +31,12 @@ public class StandardServiceSF extends StoreFactoryBase { /** * Store the specified service element children. + * <p> * {@inheritDoc} */ @Override - public void storeChildren(PrintWriter aWriter, int indent, Object aService, - StoreDescription parentDesc) throws Exception { + public void storeChildren(PrintWriter aWriter, int indent, Object aService, StoreDescription parentDesc) + throws Exception { if (aService instanceof StandardService) { StandardService service = (StandardService) aService; // Store nested <Listener> elements diff --git a/java/org/apache/catalina/storeconfig/StoreAppender.java b/java/org/apache/catalina/storeconfig/StoreAppender.java index 2dba031215..5c830fce56 100644 --- a/java/org/apache/catalina/storeconfig/StoreAppender.java +++ b/java/org/apache/catalina/storeconfig/StoreAppender.java @@ -35,11 +35,9 @@ public class StoreAppender { /** * The set of classes that represent persistable properties. */ - private static Class<?> persistables[] = { String.class, Integer.class, - Integer.TYPE, Boolean.class, Boolean.TYPE, Byte.class, Byte.TYPE, - Character.class, Character.TYPE, Double.class, Double.TYPE, - Float.class, Float.TYPE, Long.class, Long.TYPE, Short.class, - Short.TYPE, InetAddress.class }; + private static Class<?> persistables[] = { String.class, Integer.class, Integer.TYPE, Boolean.class, Boolean.TYPE, + Byte.class, Byte.TYPE, Character.class, Character.TYPE, Double.class, Double.TYPE, Float.class, Float.TYPE, + Long.class, Long.TYPE, Short.class, Short.TYPE, InetAddress.class }; private int pos = 0; @@ -47,11 +45,11 @@ public class StoreAppender { * Print the closing tag. * * @param aWriter The output writer - * @param aDesc Store description of the current element + * @param aDesc Store description of the current element + * * @throws Exception A store error occurred */ - public void printCloseTag(PrintWriter aWriter, StoreDescription aDesc) - throws Exception { + public void printCloseTag(PrintWriter aWriter, StoreDescription aDesc) throws Exception { aWriter.print("</"); aWriter.print(aDesc.getTag()); aWriter.println(">"); @@ -61,13 +59,13 @@ public class StoreAppender { * Print only the open tag with all attributes. * * @param aWriter The output writer - * @param indent Indentation level - * @param bean The current bean that is stored - * @param aDesc Store description of the current element + * @param indent Indentation level + * @param bean The current bean that is stored + * @param aDesc Store description of the current element + * * @throws Exception A store error occurred */ - public void printOpenTag(PrintWriter aWriter, int indent, Object bean, - StoreDescription aDesc) throws Exception { + public void printOpenTag(PrintWriter aWriter, int indent, Object bean, StoreDescription aDesc) throws Exception { aWriter.print("<"); aWriter.print(aDesc.getTag()); if (aDesc.isAttributes() && bean != null) { @@ -80,13 +78,13 @@ public class StoreAppender { * Print tag with all attributes * * @param aWriter The output writer - * @param indent Indentation level - * @param bean The current bean that is stored - * @param aDesc Store description of the current element + * @param indent Indentation level + * @param bean The current bean that is stored + * @param aDesc Store description of the current element + * * @throws Exception A store error occurred */ - public void printTag(PrintWriter aWriter, int indent, Object bean, - StoreDescription aDesc) throws Exception { + public void printTag(PrintWriter aWriter, int indent, Object bean, StoreDescription aDesc) throws Exception { aWriter.print("<"); aWriter.print(aDesc.getTag()); if (aDesc.isAttributes() && bean != null) { @@ -99,12 +97,12 @@ public class StoreAppender { * Print the value from tag as content. * * @param aWriter The output writer - * @param tag The element name + * @param tag The element name * @param content Element content + * * @throws Exception A store error occurred */ - public void printTagContent(PrintWriter aWriter, String tag, String content) - throws Exception { + public void printTagContent(PrintWriter aWriter, String tag, String content) throws Exception { aWriter.print("<"); aWriter.print(tag); aWriter.print(">"); @@ -117,13 +115,12 @@ public class StoreAppender { /** * Print an array of values. * - * @param aWriter The output writer - * @param tag The element name - * @param indent Indentation level + * @param aWriter The output writer + * @param tag The element name + * @param indent Indentation level * @param elements Array of element values */ - public void printTagValueArray(PrintWriter aWriter, String tag, int indent, - String[] elements) { + public void printTagValueArray(PrintWriter aWriter, String tag, int indent, String[] elements) { if (elements != null && elements.length > 0) { printIndent(aWriter, indent + 2); aWriter.print("<"); @@ -146,14 +143,14 @@ public class StoreAppender { /** * Print an array of elements. * - * @param aWriter The output writer - * @param tag The element name - * @param indent Indentation level + * @param aWriter The output writer + * @param tag The element name + * @param indent Indentation level * @param elements Array of elements + * * @throws Exception Store error occurred */ - public void printTagArray(PrintWriter aWriter, String tag, int indent, - String[] elements) throws Exception { + public void printTagArray(PrintWriter aWriter, String tag, int indent, String[] elements) throws Exception { if (elements != null) { for (String element : elements) { printIndent(aWriter, indent); @@ -166,7 +163,7 @@ public class StoreAppender { * Print some spaces. * * @param aWriter The output writer - * @param indent The number of spaces + * @param indent The number of spaces */ public void printIndent(PrintWriter aWriter, int indent) { for (int i = 0; i < indent; i++) { @@ -176,21 +173,17 @@ public class StoreAppender { } /** - * Store the relevant attributes of the specified JavaBean, plus a - * <code>className</code> attribute defining the fully qualified Java - * class name of the bean. + * Store the relevant attributes of the specified JavaBean, plus a <code>className</code> attribute defining the + * fully qualified Java class name of the bean. * * @param writer PrintWriter to which we are storing * @param indent Indentation level - * @param bean - * Bean whose properties are to be rendered as attributes, - * @param desc Store description of the current element + * @param bean Bean whose properties are to be rendered as attributes, + * @param desc Store description of the current element * - * @exception Exception - * if an exception occurs while storing + * @exception Exception if an exception occurs while storing */ - public void printAttributes(PrintWriter writer, int indent, Object bean, - StoreDescription desc) throws Exception { + public void printAttributes(PrintWriter writer, int indent, Object bean, StoreDescription desc) throws Exception { printAttributes(writer, indent, true, bean, desc); @@ -199,20 +192,15 @@ public class StoreAppender { /** * Store the relevant attributes of the specified JavaBean. * - * @param writer PrintWriter to which we are storing - * @param indent Indentation level - * @param include - * Should we include a <code>className</code> attribute? - * @param bean - * Bean whose properties are to be rendered as attributes, - * @param desc - * RegistryDescriptor from this bean + * @param writer PrintWriter to which we are storing + * @param indent Indentation level + * @param include Should we include a <code>className</code> attribute? + * @param bean Bean whose properties are to be rendered as attributes, + * @param desc RegistryDescriptor from this bean * - * @exception Exception - * if an exception occurs while storing + * @exception Exception if an exception occurs while storing */ - public void printAttributes(PrintWriter writer, int indent, - boolean include, Object bean, StoreDescription desc) + public void printAttributes(PrintWriter writer, int indent, boolean include, Object bean, StoreDescription desc) throws Exception { // Render a className attribute if requested @@ -223,8 +211,7 @@ public class StoreAppender { } // Acquire the list of properties for this bean - PropertyDescriptor descriptors[] = Introspector.getBeanInfo( - bean.getClass()).getPropertyDescriptors(); + PropertyDescriptor descriptors[] = Introspector.getBeanInfo(bean.getClass()).getPropertyDescriptors(); if (descriptors == null) { descriptors = new PropertyDescriptor[0]; } @@ -257,20 +244,22 @@ public class StoreAppender { /** * Check if the attribute should be printed. - * @param desc RegistryDescriptor from this bean - * @param descriptor PropertyDescriptor from this bean property + * + * @param desc RegistryDescriptor from this bean + * @param descriptor PropertyDescriptor from this bean property * @param attributeName The attribute name to store - * @param bean The current bean - * @param bean2 A default instance of the bean for comparison + * @param bean The current bean + * @param bean2 A default instance of the bean for comparison + * * @return null if the value should be skipped, the value to print otherwise */ - protected Object checkAttribute(StoreDescription desc, PropertyDescriptor descriptor, String attributeName, Object bean, Object bean2) { + protected Object checkAttribute(StoreDescription desc, PropertyDescriptor descriptor, String attributeName, + Object bean, Object bean2) { if (descriptor instanceof IndexedPropertyDescriptor) { return null; // Indexed properties are not persisted } - if (!isPersistable(descriptor.getPropertyType()) - || (descriptor.getReadMethod() == null) - || (descriptor.getWriteMethod() == null)) { + if (!isPersistable(descriptor.getPropertyType()) || (descriptor.getReadMethod() == null) || + (descriptor.getWriteMethod() == null)) { return null; // Must be a read-write primitive or String } if (desc.isTransientAttribute(descriptor.getName())) { @@ -291,15 +280,16 @@ public class StoreAppender { /** * Store the specified of the specified JavaBean. * - * @param writer PrintWriter to which we are storing - * @param indent Indentation level - * @param bean The current bean - * @param desc RegistryDescriptor from this bean + * @param writer PrintWriter to which we are storing + * @param indent Indentation level + * @param bean The current bean + * @param desc RegistryDescriptor from this bean * @param attributeName The attribute name to store - * @param bean2 A default instance of the bean for comparison - * @param value The attribute value + * @param bean2 A default instance of the bean for comparison + * @param value The attribute value */ - protected void printAttribute(PrintWriter writer, int indent, Object bean, StoreDescription desc, String attributeName, Object bean2, Object value) { + protected void printAttribute(PrintWriter writer, int indent, Object bean, StoreDescription desc, + String attributeName, Object bean2, Object value) { if (isPrintValue(bean, bean2, attributeName, desc)) { printValue(writer, indent, attributeName, value); } @@ -308,18 +298,14 @@ public class StoreAppender { /** * Determine if the attribute value needs to be stored. * - * @param bean - * original bean - * @param bean2 - * default bean - * @param attrName - * attribute name - * @param desc - * StoreDescription from bean + * @param bean original bean + * @param bean2 default bean + * @param attrName attribute name + * @param desc StoreDescription from bean + * * @return <code>true</code> if the value should be stored */ - public boolean isPrintValue(Object bean, Object bean2, String attrName, - StoreDescription desc) { + public boolean isPrintValue(Object bean, Object bean2, String attrName, StoreDescription desc) { return true; } @@ -327,7 +313,9 @@ public class StoreAppender { * Generate default Instance for the specified bean. * * @param bean The bean + * * @return an object from same class as bean parameter + * * @throws ReflectiveOperationException Error creating a new instance */ public Object defaultInstance(Object bean) throws ReflectiveOperationException { @@ -339,11 +327,10 @@ public class StoreAppender { * * @param writer PrintWriter to which we are storing * @param indent Indentation level - * @param name Attribute name - * @param value Attribute value + * @param name Attribute name + * @param value Attribute value */ - public void printValue(PrintWriter writer, int indent, String name, - Object value) { + public void printValue(PrintWriter writer, int indent, String name, Object value) { // Convert IP addresses to strings so they will be persisted if (value instanceof InetAddress) { value = ((InetAddress) value).getHostAddress(); @@ -367,11 +354,10 @@ public class StoreAppender { /** - * Is the specified property type one for which we should generate a - * persistence attribute? + * Is the specified property type one for which we should generate a persistence attribute? + * + * @param clazz Java class to be tested * - * @param clazz - * Java class to be tested * @return <code>true</code> if the specified class should be stored */ protected boolean isPersistable(Class<?> clazz) { diff --git a/java/org/apache/catalina/storeconfig/StoreConfig.java b/java/org/apache/catalina/storeconfig/StoreConfig.java index e7c0e1eb0a..61d82a2dba 100644 --- a/java/org/apache/catalina/storeconfig/StoreConfig.java +++ b/java/org/apache/catalina/storeconfig/StoreConfig.java @@ -35,13 +35,11 @@ import org.apache.juli.logging.LogFactory; import org.apache.tomcat.util.res.StringManager; /** - * Store Server/Service/Host/Context at file or PrintWriter. Default server.xml - * is at $catalina.base/conf/server.xml + * Store Server/Service/Host/Context at file or PrintWriter. Default server.xml is at $catalina.base/conf/server.xml */ public class StoreConfig implements IStoreConfig { private static Log log = LogFactory.getLog(StoreConfig.class); - protected static final StringManager sm = StringManager - .getManager(Constants.Package); + protected static final StringManager sm = StringManager.getManager(Constants.Package); private String serverFilename = "conf/server.xml"; @@ -95,16 +93,15 @@ public class StoreConfig implements IStoreConfig { /** * Store Server from Object Name (Catalina:type=Server). * - * @param aServerName Server ObjectName - * @param backup <code>true</code> to backup existing configuration files - * before rewriting them - * @param externalAllowed <code>true</code> to allow saving webapp - * configuration for webapps that are not inside the host's app - * directory + * @param aServerName Server ObjectName + * @param backup <code>true</code> to backup existing configuration files before rewriting them + * @param externalAllowed <code>true</code> to allow saving webapp configuration for webapps that are not inside the + * host's app directory + * * @throws MalformedObjectNameException Bad MBean name */ - public synchronized void storeServer(String aServerName, boolean backup, - boolean externalAllowed) throws MalformedObjectNameException { + public synchronized void storeServer(String aServerName, boolean backup, boolean externalAllowed) + throws MalformedObjectNameException { if (aServerName == null || aServerName.length() == 0) { log.error(sm.getString("config.emptyObjectName")); return; @@ -113,8 +110,7 @@ public class StoreConfig implements IStoreConfig { ObjectName objectName = new ObjectName(aServerName); if (mserver.isRegistered(objectName)) { try { - Server aServer = (Server) mserver.getAttribute(objectName, - "managedResource"); + Server aServer = (Server) mserver.getAttribute(objectName, "managedResource"); StoreDescription desc = null; desc = getRegistry().findDescription(StandardContext.class); if (desc != null) { @@ -145,16 +141,15 @@ public class StoreConfig implements IStoreConfig { /** * Store a Context from ObjectName. * - * @param aContextName MBean ObjectName - * @param backup <code>true</code> to backup existing configuration files - * before rewriting them - * @param externalAllowed <code>true</code> to allow saving webapp - * configuration for webapps that are not inside the host's app - * directory + * @param aContextName MBean ObjectName + * @param backup <code>true</code> to backup existing configuration files before rewriting them + * @param externalAllowed <code>true</code> to allow saving webapp configuration for webapps that are not inside the + * host's app directory + * * @throws MalformedObjectNameException Bad MBean name */ - public synchronized void storeContext(String aContextName, boolean backup, - boolean externalAllowed) throws MalformedObjectNameException { + public synchronized void storeContext(String aContextName, boolean backup, boolean externalAllowed) + throws MalformedObjectNameException { if (aContextName == null || aContextName.length() == 0) { log.error(sm.getString("config.emptyObjectName")); return; @@ -163,24 +158,20 @@ public class StoreConfig implements IStoreConfig { ObjectName objectName = new ObjectName(aContextName); if (mserver.isRegistered(objectName)) { try { - Context aContext = (Context) mserver.getAttribute(objectName, - "managedResource"); + Context aContext = (Context) mserver.getAttribute(objectName, "managedResource"); URL configFile = aContext.getConfigFile(); if (configFile != null) { StoreDescription desc = null; - desc = getRegistry().findDescription( - aContext.getClass()); + desc = getRegistry().findDescription(aContext.getClass()); if (desc != null) { boolean oldSeparate = desc.isStoreSeparate(); boolean oldBackup = desc.isBackup(); - boolean oldExternalAllowed = desc - .isExternalAllowed(); + boolean oldExternalAllowed = desc.isExternalAllowed(); try { desc.setStoreSeparate(true); desc.setBackup(backup); desc.setExternalAllowed(externalAllowed); - desc.getStoreFactory() - .store(null, -2, aContext); + desc.getStoreFactory().store(null, -2, aContext); } finally { desc.setStoreSeparate(oldSeparate); desc.setBackup(oldBackup); @@ -200,8 +191,8 @@ public class StoreConfig implements IStoreConfig { @Override public synchronized boolean store(Server aServer) { - StoreFileMover mover = new StoreFileMover(Bootstrap.getCatalinaBase(), - getServerFilename(), getRegistry().getEncoding()); + StoreFileMover mover = + new StoreFileMover(Bootstrap.getCatalinaBase(), getServerFilename(), getRegistry().getEncoding()); // Open an output writer for the new configuration file try { try (PrintWriter writer = mover.getWriter()) { @@ -237,8 +228,7 @@ public class StoreConfig implements IStoreConfig { } @Override - public void store(PrintWriter aWriter, int indent, - Context aContext) throws Exception { + public void store(PrintWriter aWriter, int indent, Context aContext) throws Exception { boolean oldSeparate = true; StoreDescription desc = null; try { @@ -258,10 +248,8 @@ public class StoreConfig implements IStoreConfig { } @Override - public void store(PrintWriter aWriter, int indent, Host aHost) - throws Exception { - StoreDescription desc = getRegistry().findDescription( - aHost.getClass()); + public void store(PrintWriter aWriter, int indent, Host aHost) throws Exception { + StoreDescription desc = getRegistry().findDescription(aHost.getClass()); if (desc != null) { desc.getStoreFactory().store(aWriter, indent, aHost); } else { @@ -270,10 +258,8 @@ public class StoreConfig implements IStoreConfig { } @Override - public void store(PrintWriter aWriter, int indent, - Service aService) throws Exception { - StoreDescription desc = getRegistry().findDescription( - aService.getClass()); + public void store(PrintWriter aWriter, int indent, Service aService) throws Exception { + StoreDescription desc = getRegistry().findDescription(aService.getClass()); if (desc != null) { desc.getStoreFactory().store(aWriter, indent, aService); } else { @@ -282,10 +268,8 @@ public class StoreConfig implements IStoreConfig { } @Override - public void store(PrintWriter writer, int indent, - Server aServer) throws Exception { - StoreDescription desc = getRegistry().findDescription( - aServer.getClass()); + public void store(PrintWriter writer, int indent, Server aServer) throws Exception { + StoreDescription desc = getRegistry().findDescription(aServer.getClass()); if (desc != null) { desc.getStoreFactory().store(writer, indent, aServer); } else { diff --git a/java/org/apache/catalina/storeconfig/StoreConfigLifecycleListener.java b/java/org/apache/catalina/storeconfig/StoreConfigLifecycleListener.java index a55c8c99a4..384498a44a 100644 --- a/java/org/apache/catalina/storeconfig/StoreConfigLifecycleListener.java +++ b/java/org/apache/catalina/storeconfig/StoreConfigLifecycleListener.java @@ -31,8 +31,7 @@ import org.apache.tomcat.util.modeler.Registry; import org.apache.tomcat.util.res.StringManager; /** - * Loads and registers a StoreConfig MBean with the name - * <i>Catalina:type=StoreConfig</i>. + * Loads and registers a StoreConfig MBean with the name <i>Catalina:type=StoreConfig</i>. * <p> * This listener must only be nested within {@link Server} elements. */ @@ -65,8 +64,8 @@ public class StoreConfigLifecycleListener implements LifecycleListener { if (event.getSource() instanceof Server) { createMBean((Server) event.getSource()); } else { - log.warn(sm.getString("storeConfigListener.notServer", - event.getLifecycle().getClass().getSimpleName())); + log.warn( + sm.getString("storeConfigListener.notServer", event.getLifecycle().getClass().getSimpleName())); } } else if (Lifecycle.AFTER_STOP_EVENT.equals(event.getType())) { if (oname != null) { @@ -74,18 +73,17 @@ public class StoreConfigLifecycleListener implements LifecycleListener { oname = null; } } - } + } /** - * Create StoreConfig MBean and load StoreRegistry MBeans name is - * <code>Catalina:type=StoreConfig</code>. + * Create StoreConfig MBean and load StoreRegistry MBeans name is <code>Catalina:type=StoreConfig</code>. + * * @param server The Server instance */ protected void createMBean(Server server) { StoreLoader loader = new StoreLoader(); try { - Class<?> clazz = Class.forName(getStoreConfigClass(), true, this - .getClass().getClassLoader()); + Class<?> clazz = Class.forName(getStoreConfigClass(), true, this.getClass().getClassLoader()); storeConfig = (IStoreConfig) clazz.getConstructor().newInstance(); loader.load(getStoreRegistry()); // use the loader Registry @@ -97,7 +95,7 @@ public class StoreConfigLifecycleListener implements LifecycleListener { } try { // Note: Hard-coded domain used since this object is per Server/JVM - oname = new ObjectName("Catalina:type=StoreConfig" ); + oname = new ObjectName("Catalina:type=StoreConfig"); registry.registerComponent(storeConfig, oname, "StoreConfig"); } catch (Exception ex) { log.error(sm.getString("storeConfigListener.registerError"), ex); @@ -108,7 +106,9 @@ public class StoreConfigLifecycleListener implements LifecycleListener { * Create a ManagedBean (StoreConfig). * * @param object The object to manage + * * @return an MBean wrapping the object + * * @throws Exception if an error occurred */ protected DynamicMBean getManagedBean(Object object) throws Exception { @@ -124,8 +124,7 @@ public class StoreConfigLifecycleListener implements LifecycleListener { } /** - * @param storeConfig - * The storeConfig to set. + * @param storeConfig The storeConfig to set. */ public void setStoreConfig(IStoreConfig storeConfig) { this.storeConfig = storeConfig; @@ -139,8 +138,7 @@ public class StoreConfigLifecycleListener implements LifecycleListener { } /** - * @param storeConfigClass - * The storeConfigClass to set. + * @param storeConfigClass The storeConfigClass to set. */ public void setStoreConfigClass(String storeConfigClass) { this.storeConfigClass = storeConfigClass; @@ -154,8 +152,7 @@ public class StoreConfigLifecycleListener implements LifecycleListener { } /** - * @param storeRegistry - * The storeRegistry to set. + * @param storeRegistry The storeRegistry to set. */ public void setStoreRegistry(String storeRegistry) { this.storeRegistry = storeRegistry; diff --git a/java/org/apache/catalina/storeconfig/StoreContextAppender.java b/java/org/apache/catalina/storeconfig/StoreContextAppender.java index f313d79409..502c700353 100644 --- a/java/org/apache/catalina/storeconfig/StoreContextAppender.java +++ b/java/org/apache/catalina/storeconfig/StoreContextAppender.java @@ -31,17 +31,17 @@ import org.apache.catalina.core.StandardHost; public class StoreContextAppender extends StoreAppender { /** - * {@inheritDoc} - * Adds special handling for <code>docBase</code>. + * {@inheritDoc} Adds special handling for <code>docBase</code>. */ @Override - protected void printAttribute(PrintWriter writer, int indent, Object bean, StoreDescription desc, String attributeName, Object bean2, Object value) { + protected void printAttribute(PrintWriter writer, int indent, Object bean, StoreDescription desc, + String attributeName, Object bean2, Object value) { if (isPrintValue(bean, bean2, attributeName, desc)) { - if(attributeName.equals("docBase")) { - if(bean instanceof StandardContext) { - String docBase = ((StandardContext)bean).getOriginalDocBase() ; - if(docBase != null) { - value = docBase ; + if (attributeName.equals("docBase")) { + if (bean instanceof StandardContext) { + String docBase = ((StandardContext) bean).getOriginalDocBase(); + if (docBase != null) { + value = docBase; } } } @@ -50,14 +50,17 @@ public class StoreContextAppender extends StoreAppender { } /** - * Print Context Values. <ul><li> Special handling to default workDir. - * </li><li> Don't save path at external context.xml </li><li> Don't - * generate docBase for host.appBase webapps <LI></ul> + * Print Context Values. + * <ul> + * <li>Special handling to default workDir.</li> + * <li>Don't save path at external context.xml</li> + * <li>Don't generate docBase for host.appBase webapps + * <LI> + * </ul> * {@inheritDoc} */ @Override - public boolean isPrintValue(Object bean, Object bean2, String attrName, - StoreDescription desc) { + public boolean isPrintValue(Object bean, Object bean2, String attrName, StoreDescription desc) { boolean isPrint = super.isPrintValue(bean, bean2, attrName, desc); if (isPrint) { StandardContext context = ((StandardContext) bean); @@ -67,14 +70,12 @@ public class StoreContextAppender extends StoreAppender { isPrint = !defaultWorkDir.equals(context.getWorkDir()); } } else if ("path".equals(attrName)) { - isPrint = desc.isStoreSeparate() - && desc.isExternalAllowed() - && context.getConfigFile() == null; + isPrint = desc.isStoreSeparate() && desc.isExternalAllowed() && context.getConfigFile() == null; } else if ("docBase".equals(attrName)) { Container host = context.getParent(); if (host instanceof StandardHost) { File appBase = getAppBase(((StandardHost) host)); - File docBase = getDocBase(context,appBase); + File docBase = getDocBase(context, appBase); isPrint = !appBase.equals(docBase.getParentFile()); } } @@ -87,8 +88,7 @@ public class StoreContextAppender extends StoreAppender { File appBase; File file = new File(host.getAppBase()); if (!file.isAbsolute()) { - file = new File(System.getProperty(Globals.CATALINA_BASE_PROP), host - .getAppBase()); + file = new File(System.getProperty(Globals.CATALINA_BASE_PROP), host.getAppBase()); } try { appBase = file.getCanonicalFile(); @@ -101,9 +101,9 @@ public class StoreContextAppender extends StoreAppender { protected File getDocBase(StandardContext context, File appBase) { File docBase; - String contextDocBase = context.getOriginalDocBase() ; - if(contextDocBase == null) { - contextDocBase = context.getDocBase() ; + String contextDocBase = context.getOriginalDocBase(); + if (contextDocBase == null) { + contextDocBase = context.getDocBase(); } File file = new File(contextDocBase); if (!file.isAbsolute()) { @@ -121,6 +121,7 @@ public class StoreContextAppender extends StoreAppender { * Make default Work Dir. * * @param context The context + * * @return The default working directory for the context. */ protected String getDefaultWorkDir(StandardContext context) { @@ -141,19 +142,21 @@ public class StoreContextAppender extends StoreAppender { } else { String engineName = context.getParent().getParent().getName(); String hostName = context.getParent().getName(); - defaultWorkDir = "work" + File.separator + engineName - + File.separator + hostName + File.separator - + contextWorkDir; + defaultWorkDir = "work" + File.separator + engineName + File.separator + hostName + File.separator + + contextWorkDir; } } return defaultWorkDir; } /** - * Generate a real default StandardContext TODO read and interpret the - * default context.xml and context.xml.default TODO Cache a Default - * StandardContext ( with reloading strategy) TODO remove really all - * elements, but detection is hard... To Listener or Valve from same class? + * Generate a real default StandardContext + * <p> + * TODO read and interpret the default context.xml and context.xml.default + * <p> + * TODO Cache a Default StandardContext ( with reloading strategy) + * <p> + * TODO remove really all elements, but detection is hard... To Listener or Valve from same class? * * @see org.apache.catalina.storeconfig.StoreAppender#defaultInstance(java.lang.Object) */ @@ -161,17 +164,18 @@ public class StoreContextAppender extends StoreAppender { public Object defaultInstance(Object bean) throws ReflectiveOperationException { if (bean instanceof StandardContext) { StandardContext defaultContext = new StandardContext(); + // @formatter:off /* * if (!((StandardContext) bean).getOverride()) { - * defaultContext.setParent(((StandardContext)bean).getParent()); - * ContextConfig contextConfig = new ContextConfig(); - * defaultContext.addLifecycleListener(contextConfig); - * contextConfig.setContext(defaultContext); - * contextConfig.processContextConfig(new File(contextConfig - * .getBaseDir(), "conf/context.xml")); - * contextConfig.processContextConfig(new File(contextConfig - * .getConfigBase(), "context.xml.default")); } + * defaultContext.setParent(((StandardContext)bean).getParent()); + * ContextConfig contextConfig = new ContextConfig(); + * defaultContext.addLifecycleListener(contextConfig); + * contextConfig.setContext(defaultContext); + * contextConfig.processContextConfig(new File(contextConfig.getBaseDir(), "conf/context.xml")); + * contextConfig.processContextConfig(new File(contextConfig.getConfigBase(), "context.xml.default")); + * } */ + // @formatter:on return defaultContext; } else { return super.defaultInstance(bean); diff --git a/java/org/apache/catalina/storeconfig/StoreDescription.java b/java/org/apache/catalina/storeconfig/StoreDescription.java index d308a59ec5..f5378aa2e9 100644 --- a/java/org/apache/catalina/storeconfig/StoreDescription.java +++ b/java/org/apache/catalina/storeconfig/StoreDescription.java @@ -50,8 +50,6 @@ import java.util.List; * <TransientAttribute>startupTime</TransientAttribute> * <TransientAttribute>tldScanTime</TransientAttribute> * </Description> - * - * * </pre> */ public class StoreDescription { @@ -96,8 +94,7 @@ public class StoreDescription { } /** - * @param external - * The external to set. + * @param external The external to set. */ public void setExternalAllowed(boolean external) { this.externalAllowed = external; @@ -119,8 +116,7 @@ public class StoreDescription { } /** - * @param standard - * The standard to set. + * @param standard The standard to set. */ public void setStandard(boolean standard) { this.standard = standard; @@ -134,8 +130,7 @@ public class StoreDescription { } /** - * @param backup - * The backup to set. + * @param backup The backup to set. */ public void setBackup(boolean backup) { this.backup = backup; @@ -149,8 +144,7 @@ public class StoreDescription { } /** - * @param aDefault - * The myDefault to set. + * @param aDefault The myDefault to set. */ public void setDefault(boolean aDefault) { this.myDefault = aDefault; @@ -164,8 +158,7 @@ public class StoreDescription { } /** - * @param storeFactoryClass - * The storeFactory to set. + * @param storeFactoryClass The storeFactory to set. */ public void setStoreFactoryClass(String storeFactoryClass) { this.storeFactoryClass = storeFactoryClass; @@ -179,8 +172,7 @@ public class StoreDescription { } /** - * @param storeFactory - * The storeFactory to set. + * @param storeFactory The storeFactory to set. */ public void setStoreFactory(IStoreFactory storeFactory) { this.storeFactory = storeFactory; @@ -194,8 +186,7 @@ public class StoreDescription { } /** - * @param storeWriterClass - * The storeWriterClass to set. + * @param storeWriterClass The storeWriterClass to set. */ public void setStoreWriterClass(String storeWriterClass) { this.storeWriterClass = storeWriterClass; @@ -209,8 +200,7 @@ public class StoreDescription { } /** - * @param tag - * The tag to set. + * @param tag The tag to set. */ public void setTag(String tag) { this.tag = tag; @@ -224,8 +214,7 @@ public class StoreDescription { } /** - * @param tagClass - * The tagClass to set. + * @param tagClass The tagClass to set. */ public void setTagClass(String tagClass) { this.tagClass = tagClass; @@ -239,8 +228,7 @@ public class StoreDescription { } /** - * @param transientAttributes - * The transientAttributes to set. + * @param transientAttributes The transientAttributes to set. */ public void setTransientAttributes(List<String> transientAttributes) { this.transientAttributes = transientAttributes; @@ -267,8 +255,7 @@ public class StoreDescription { } /** - * @param transientChildren - * The transientChildren to set. + * @param transientChildren The transientChildren to set. */ public void setTransientChildren(List<String> transientChildren) { this.transientChildren = transientChildren; @@ -291,6 +278,7 @@ public class StoreDescription { * Is child transient, please don't save this. * * @param classname The class name to check + * * @return is classname attribute? */ public boolean isTransientChild(String classname) { @@ -304,6 +292,7 @@ public class StoreDescription { * Is attribute transient, please don't save this. * * @param attribute The attribute name to check + * * @return is transient attribute? */ public boolean isTransientAttribute(String attribute) { @@ -327,8 +316,7 @@ public class StoreDescription { } /** - * @param id - * The id to set. + * @param id The id to set. */ public void setId(String id) { this.id = id; @@ -342,8 +330,7 @@ public class StoreDescription { } /** - * @param attributes - * The attributes to set. + * @param attributes The attributes to set. */ public void setAttributes(boolean attributes) { this.attributes = attributes; @@ -368,8 +355,7 @@ public class StoreDescription { } /** - * @param children - * The children to set. + * @param children The children to set. */ public void setChildren(boolean children) { this.children = children; diff --git a/java/org/apache/catalina/storeconfig/StoreFactoryBase.java b/java/org/apache/catalina/storeconfig/StoreFactoryBase.java index 0aba266da1..fff7ca0f77 100644 --- a/java/org/apache/catalina/storeconfig/StoreFactoryBase.java +++ b/java/org/apache/catalina/storeconfig/StoreFactoryBase.java @@ -24,8 +24,7 @@ import org.apache.juli.logging.LogFactory; import org.apache.tomcat.util.res.StringManager; /** - * StoreFactory saves special elements. - * Output was generate with StoreAppenders. + * StoreFactory saves special elements. Output was generate with StoreAppenders. */ public class StoreFactoryBase implements IStoreFactory { private static Log log = LogFactory.getLog(StoreFactoryBase.class); @@ -37,8 +36,7 @@ public class StoreFactoryBase implements IStoreFactory { /** * The string manager for this package. */ - protected static final StringManager sm = StringManager - .getManager(Constants.Package); + protected static final StringManager sm = StringManager.getManager(Constants.Package); /** * The descriptive information string for this implementation. @@ -46,9 +44,8 @@ public class StoreFactoryBase implements IStoreFactory { private static final String info = "org.apache.catalina.config.StoreFactoryBase/1.0"; /** - * @return descriptive information about this Factory implementation and the - * corresponding version number, in the format - * <code><description>/<version></code>. + * @return descriptive information about this Factory implementation and the corresponding version number, in the + * format <code><description>/<version></code>. */ public String getInfo() { return info; @@ -85,89 +82,80 @@ public class StoreFactoryBase implements IStoreFactory { } @Override - public void store(PrintWriter aWriter, int indent, Object aElement) - throws Exception { + public void store(PrintWriter aWriter, int indent, Object aElement) throws Exception { - StoreDescription elementDesc = getRegistry().findDescription( - aElement.getClass()); + StoreDescription elementDesc = getRegistry().findDescription(aElement.getClass()); if (elementDesc != null) { if (log.isTraceEnabled()) { - log.trace(sm.getString("factory.storeTag", - elementDesc.getTag(), aElement)); + log.trace(sm.getString("factory.storeTag", elementDesc.getTag(), aElement)); } getStoreAppender().printIndent(aWriter, indent + 2); if (!elementDesc.isChildren()) { - getStoreAppender().printTag(aWriter, indent, aElement, - elementDesc); + getStoreAppender().printTag(aWriter, indent, aElement, elementDesc); } else { - getStoreAppender().printOpenTag(aWriter, indent + 2, aElement, - elementDesc); + getStoreAppender().printOpenTag(aWriter, indent + 2, aElement, elementDesc); storeChildren(aWriter, indent + 2, aElement, elementDesc); getStoreAppender().printIndent(aWriter, indent + 2); getStoreAppender().printCloseTag(aWriter, elementDesc); } } else { - log.warn(sm.getString("factory.storeNoDescriptor", aElement - .getClass())); + log.warn(sm.getString("factory.storeNoDescriptor", aElement.getClass())); } } /** * Must Implement at subclass for custom store children handling. * - * @param aWriter Current output writer - * @param indent Indentation level - * @param aElement Current element + * @param aWriter Current output writer + * @param indent Indentation level + * @param aElement Current element * @param elementDesc The element description + * * @throws Exception Configuration storing error */ - public void storeChildren(PrintWriter aWriter, int indent, Object aElement, - StoreDescription elementDesc) throws Exception { + public void storeChildren(PrintWriter aWriter, int indent, Object aElement, StoreDescription elementDesc) + throws Exception { } /** - * Store only elements from storeChildren methods that are not a transient - * child. + * Store only elements from storeChildren methods that are not a transient child. * - * @param aWriter Current output writer - * @param indent Indentation level + * @param aWriter Current output writer + * @param indent Indentation level * @param aTagElement Current element + * * @throws Exception Configuration storing error */ - protected void storeElement(PrintWriter aWriter, int indent, - Object aTagElement) throws Exception { + protected void storeElement(PrintWriter aWriter, int indent, Object aTagElement) throws Exception { if (aTagElement != null) { - IStoreFactory elementFactory = getRegistry().findStoreFactory( - aTagElement.getClass()); + IStoreFactory elementFactory = getRegistry().findStoreFactory(aTagElement.getClass()); if (elementFactory != null) { - StoreDescription desc = getRegistry().findDescription( - aTagElement.getClass()); + StoreDescription desc = getRegistry().findDescription(aTagElement.getClass()); if (desc != null) { if (!desc.isTransientChild(aTagElement.getClass().getName())) { elementFactory.store(aWriter, indent, aTagElement); } } else { - log.warn(sm.getString("factory.storeNoDescriptor", aTagElement - .getClass())); + log.warn(sm.getString("factory.storeNoDescriptor", aTagElement.getClass())); } } else { - log.warn(sm.getString("factory.storeNoDescriptor", aTagElement - .getClass())); + log.warn(sm.getString("factory.storeNoDescriptor", aTagElement.getClass())); } } } /** * Save an array of elements. - * @param aWriter Current output writer - * @param indent Indentation level + * + * @param aWriter Current output writer + * @param indent Indentation level * @param elements Array of elements + * * @throws Exception Configuration storing error */ - protected void storeElementArray(PrintWriter aWriter, int indent, - Object[] elements) throws Exception { + protected void storeElementArray(PrintWriter aWriter, int indent, Object[] elements) throws Exception { if (elements != null) { for (Object element : elements) { try { diff --git a/java/org/apache/catalina/storeconfig/StoreFactoryRule.java b/java/org/apache/catalina/storeconfig/StoreFactoryRule.java index fcd08b1a93..9dec68e612 100644 --- a/java/org/apache/catalina/storeconfig/StoreFactoryRule.java +++ b/java/org/apache/catalina/storeconfig/StoreFactoryRule.java @@ -21,9 +21,8 @@ import org.xml.sax.Attributes; /** * <p> - * Rule that creates a new <code>IStoreFactory</code> instance, and associates - * it with the top object on the stack (which must implement - * <code>IStoreFactory</code>). + * Rule that creates a new <code>IStoreFactory</code> instance, and associates it with the top object on the stack + * (which must implement <code>IStoreFactory</code>). * </p> */ @@ -34,18 +33,14 @@ public class StoreFactoryRule extends Rule { /** * Construct a new instance of this Rule. * - * @param storeFactoryClass - * Default name of the StoreFactory implementation class to be - * created - * @param attributeName - * Name of the attribute that optionally includes an override - * name of the IStoreFactory class - * @param storeAppenderClass The store appender class - * @param appenderAttributeName The attribute name for the store - * appender class + * @param storeFactoryClass Default name of the StoreFactory implementation class to be created + * @param attributeName Name of the attribute that optionally includes an override name of the IStoreFactory + * class + * @param storeAppenderClass The store appender class + * @param appenderAttributeName The attribute name for the store appender class */ - public StoreFactoryRule(String storeFactoryClass, String attributeName, - String storeAppenderClass, String appenderAttributeName) { + public StoreFactoryRule(String storeFactoryClass, String attributeName, String storeAppenderClass, + String appenderAttributeName) { this.storeFactoryClass = storeFactoryClass; this.attributeName = attributeName; @@ -57,8 +52,7 @@ public class StoreFactoryRule extends Rule { // ----------------------------------------------------- Instance Variables /** - * The attribute name of an attribute that can override the implementation - * class name. + * The attribute name of an attribute that can override the implementation class name. */ private String attributeName; @@ -74,13 +68,11 @@ public class StoreFactoryRule extends Rule { // --------------------------------------------------------- Public Methods @Override - public void begin(String namespace, String name, Attributes attributes) - throws Exception { + public void begin(String namespace, String name, Attributes attributes) throws Exception { - IStoreFactory factory = (IStoreFactory) newInstance(attributeName, - storeFactoryClass, attributes); - StoreAppender storeAppender = (StoreAppender) newInstance( - appenderAttributeName, storeAppenderClass, attributes); + IStoreFactory factory = (IStoreFactory) newInstance(attributeName, storeFactoryClass, attributes); + StoreAppender storeAppender = + (StoreAppender) newInstance(appenderAttributeName, storeAppenderClass, attributes); factory.setStoreAppender(storeAppender); // Add this StoreFactory to our associated component @@ -94,14 +86,16 @@ public class StoreFactoryRule extends Rule { /** * Create new instance from attribute className! * - * @param attr class Name attribute + * @param attr class Name attribute * @param defaultName Default Class - * @param attributes current digester attribute elements + * @param attributes current digester attribute elements + * * @return new configured object instance + * * @throws ReflectiveOperationException Error creating an instance */ - protected Object newInstance(String attr, String defaultName, - Attributes attributes) throws ReflectiveOperationException { + protected Object newInstance(String attr, String defaultName, Attributes attributes) + throws ReflectiveOperationException { String className = defaultName; if (attr != null) { String value = attributes.getValue(attr); diff --git a/java/org/apache/catalina/storeconfig/StoreFileMover.java b/java/org/apache/catalina/storeconfig/StoreFileMover.java index 9d68e1c1c2..9e245f5fc0 100644 --- a/java/org/apache/catalina/storeconfig/StoreFileMover.java +++ b/java/org/apache/catalina/storeconfig/StoreFileMover.java @@ -28,7 +28,7 @@ import org.apache.tomcat.util.res.StringManager; /** * Move server.xml or context.xml as backup - * + * <p> * TODO Get Encoding from Registry */ public class StoreFileMover { @@ -76,8 +76,7 @@ public class StoreFileMover { } /** - * @param basename - * The basename to set. + * @param basename The basename to set. */ public void setBasename(String basename) { this.basename = basename; @@ -113,6 +112,7 @@ public class StoreFileMover { /** * Calculate file objects for the old and new configuration files. + * * @param basename The base path * @param encoding The encoding of the file * @param filename The file name @@ -165,18 +165,18 @@ public class StoreFileMover { if (configOld.renameTo(configSave)) { if (!configNew.renameTo(configOld)) { configSave.renameTo(configOld); - throw new IOException(sm.getString("storeFileMover.renameError", - configNew.getAbsolutePath(), configOld.getAbsolutePath())); + throw new IOException(sm.getString("storeFileMover.renameError", configNew.getAbsolutePath(), + configOld.getAbsolutePath())); } } else { if (!configOld.exists()) { if (!configNew.renameTo(configOld)) { - throw new IOException(sm.getString("storeFileMover.renameError", - configNew.getAbsolutePath(), configOld.getAbsolutePath())); + throw new IOException(sm.getString("storeFileMover.renameError", configNew.getAbsolutePath(), + configOld.getAbsolutePath())); } } else { - throw new IOException(sm.getString("storeFileMover.renameError", - configOld.getAbsolutePath(), configSave.getAbsolutePath())); + throw new IOException(sm.getString("storeFileMover.renameError", configOld.getAbsolutePath(), + configSave.getAbsolutePath())); } } } @@ -185,11 +185,11 @@ public class StoreFileMover { * Open an output writer for the new configuration file. * * @return The writer + * * @throws IOException Failed opening a writer to the new file */ public PrintWriter getWriter() throws IOException { - return new PrintWriter(new OutputStreamWriter( - new FileOutputStream(configNew), getEncoding())); + return new PrintWriter(new OutputStreamWriter(new FileOutputStream(configNew), getEncoding())); } /** @@ -199,8 +199,8 @@ public class StoreFileMover { */ protected String getTimeTag() { String ts = (new Timestamp(System.currentTimeMillis())).toString(); - // yyyy-mm-dd hh:mm:ss - // 0123456789012345678 + // yyyy-mm-dd hh:mm:ss + // 0123456789012345678 StringBuilder sb = new StringBuilder("."); sb.append(ts, 0, 10); sb.append('.'); diff --git a/java/org/apache/catalina/storeconfig/StoreLoader.java b/java/org/apache/catalina/storeconfig/StoreLoader.java index bbbfdfc988..832433338c 100644 --- a/java/org/apache/catalina/storeconfig/StoreLoader.java +++ b/java/org/apache/catalina/storeconfig/StoreLoader.java @@ -48,11 +48,9 @@ import org.apache.tomcat.util.file.ConfigurationSource.Resource; * } * </pre> * - * * Convention: * <ul> - * <li>Factories at subpackage <i>org.apache.catalina.core.storeconfig.xxxSF - * </i>.</li> + * <li>Factories at subpackage <i>org.apache.catalina.core.storeconfig.xxxSF </i>.</li> * <li>Element name are the unique Class name</li> * <li>SF for StoreFactory</li> * <li>standard implementation is false</li> @@ -61,12 +59,9 @@ import org.apache.tomcat.util.file.ConfigurationSource.Resource; * <ul> * <li>Registry XML format is a very good option</li> * <li>Store format is not fix</li> - * <li>We hope with the parent declaration we can build recursive child store - * operation //dream</li> - * <li>Problem is to access child data from array,collections or normal detail - * object</li> - * <li>Default definitions for Listener, Valve Resource? - Based on interface - * type!</li> + * <li>We hope with the parent declaration we can build recursive child store operation //dream</li> + * <li>Problem is to access child data from array,collections or normal detail object</li> + * <li>Default definitions for Listener, Valve Resource? - Based on interface type!</li> * </ul> */ public class StoreLoader { @@ -78,7 +73,7 @@ public class StoreLoader { private StoreRegistry registry; - private URL registryResource ; + private URL registryResource; /** * @return Returns the registry. @@ -88,16 +83,15 @@ public class StoreLoader { } /** - * @param registry - * The registry to set. + * @param registry The registry to set. */ public void setRegistry(StoreRegistry registry) { this.registry = registry; } /** - * Create and configure the Digester we will be using for setup store - * registry. + * Create and configure the Digester we will be using for setup store registry. + * * @return the XML digester that will be used to parse the configuration */ protected static Digester createDigester() { @@ -107,24 +101,18 @@ public class StoreLoader { digester.setClassLoader(StoreRegistry.class.getClassLoader()); // Configure the actions we will be using - digester.addObjectCreate("Registry", - "org.apache.catalina.storeconfig.StoreRegistry", "className"); + digester.addObjectCreate("Registry", "org.apache.catalina.storeconfig.StoreRegistry", "className"); digester.addSetProperties("Registry"); - digester.addObjectCreate("Registry/Description", - "org.apache.catalina.storeconfig.StoreDescription", - "className"); + digester.addObjectCreate("Registry/Description", "org.apache.catalina.storeconfig.StoreDescription", + "className"); digester.addSetProperties("Registry/Description"); - digester.addRule("Registry/Description", new StoreFactoryRule( - "org.apache.catalina.storeconfig.StoreFactoryBase", - "storeFactoryClass", - "org.apache.catalina.storeconfig.StoreAppender", - "storeAppenderClass")); + digester.addRule("Registry/Description", + new StoreFactoryRule("org.apache.catalina.storeconfig.StoreFactoryBase", "storeFactoryClass", + "org.apache.catalina.storeconfig.StoreAppender", "storeAppenderClass")); digester.addSetNext("Registry/Description", "registerDescription", "org.apache.catalina.storeconfig.StoreDescription"); - digester.addCallMethod("Registry/Description/TransientAttribute", - "addTransientAttribute", 0); - digester.addCallMethod("Registry/Description/TransientChild", - "addTransientChild", 0); + digester.addCallMethod("Registry/Description/TransientAttribute", "addTransientAttribute", 0); + digester.addCallMethod("Registry/Description/TransientChild", "addTransientChild", 0); return digester; @@ -133,26 +121,24 @@ public class StoreLoader { /** * Load registry configuration. * - * @param path Path to the configuration file, may be null to use the default - * name server-registry.xml + * @param path Path to the configuration file, may be null to use the default name server-registry.xml + * * @throws Exception when the configuration file isn't found or a parse error occurs */ public void load(String path) throws Exception { - try (Resource resource = (path == null) ? - ConfigFileLoader.getSource().getConfResource("server-registry.xml") - : ConfigFileLoader.getSource().getResource(path); - InputStream is = resource.getInputStream()) { + try (Resource resource = (path == null) ? ConfigFileLoader.getSource().getConfResource("server-registry.xml") : + ConfigFileLoader.getSource().getResource(path); InputStream is = resource.getInputStream()) { registryResource = resource.getURI().toURL(); synchronized (digester) { registry = (StoreRegistry) digester.parse(is); } } catch (IOException e) { // Try default classloader location - try (InputStream is = StoreLoader.class - .getResourceAsStream("/org/apache/catalina/storeconfig/server-registry.xml")) { + try (InputStream is = + StoreLoader.class.getResourceAsStream("/org/apache/catalina/storeconfig/server-registry.xml")) { if (is != null) { - registryResource = StoreLoader.class - .getResource("/org/apache/catalina/storeconfig/server-registry.xml"); + registryResource = + StoreLoader.class.getResource("/org/apache/catalina/storeconfig/server-registry.xml"); synchronized (digester) { registry = (StoreRegistry) digester.parse(is); } diff --git a/java/org/apache/catalina/storeconfig/StoreRegistry.java b/java/org/apache/catalina/storeconfig/StoreRegistry.java index 4865171d14..5829cac982 100644 --- a/java/org/apache/catalina/storeconfig/StoreRegistry.java +++ b/java/org/apache/catalina/storeconfig/StoreRegistry.java @@ -52,7 +52,7 @@ public class StoreRegistry { private static Log log = LogFactory.getLog(StoreRegistry.class); private static StringManager sm = StringManager.getManager(StoreRegistry.class); - private Map<String, StoreDescription> descriptors = new HashMap<>(); + private Map<String,StoreDescription> descriptors = new HashMap<>(); private String encoding = "UTF-8"; @@ -61,15 +61,11 @@ public class StoreRegistry { private String version; // Access Information - private static Class<?> interfaces[] = { CatalinaCluster.class, - ChannelSender.class, ChannelReceiver.class, Channel.class, - MembershipService.class, ClusterDeployer.class, Realm.class, - Manager.class, DirContext.class, LifecycleListener.class, - Valve.class, ClusterListener.class, MessageListener.class, - DataSender.class, ChannelInterceptor.class, Member.class, - WebResourceRoot.class, WebResourceSet.class, - CredentialHandler.class, UpgradeProtocol.class, - CookieProcessor.class }; + private static Class<?> interfaces[] = { CatalinaCluster.class, ChannelSender.class, ChannelReceiver.class, + Channel.class, MembershipService.class, ClusterDeployer.class, Realm.class, Manager.class, DirContext.class, + LifecycleListener.class, Valve.class, ClusterListener.class, MessageListener.class, DataSender.class, + ChannelInterceptor.class, Member.class, WebResourceRoot.class, WebResourceSet.class, + CredentialHandler.class, UpgradeProtocol.class, CookieProcessor.class }; /** * @return the name @@ -100,10 +96,10 @@ public class StoreRegistry { } /** - * Find a description for id. Handle interface search when no direct match - * found. + * Find a description for id. Handle interface search when no direct match found. * * @param id The class name + * * @return the description */ public StoreDescription findDescription(String id) { @@ -129,8 +125,7 @@ public class StoreRegistry { } if (log.isDebugEnabled()) { if (desc != null) { - log.trace("find descriptor " + id + "#" + desc.getTag() + "#" - + desc.getStoreFactoryClass()); + log.trace("find descriptor " + id + "#" + desc.getTag() + "#" + desc.getStoreFactoryClass()); } else { log.debug(sm.getString("registry.noDescriptor", id)); } @@ -142,6 +137,7 @@ public class StoreRegistry { * Find Description by class. * * @param aClass The class + * * @return the description */ public StoreDescription findDescription(Class<?> aClass) { @@ -152,6 +148,7 @@ public class StoreRegistry { * Find factory from class name. * * @param aClassName The class name + * * @return the factory */ public IStoreFactory findStoreFactory(String aClassName) { @@ -168,6 +165,7 @@ public class StoreRegistry { * Find factory from class. * * @param aClass The class + * * @return the factory */ public IStoreFactory findStoreFactory(Class<?> aClass) { @@ -186,8 +184,7 @@ public class StoreRegistry { } descriptors.put(key, desc); if (log.isTraceEnabled()) { - log.trace("register store descriptor " + key + "#" + desc.getTag() - + "#" + desc.getTagClass()); + log.trace("register store descriptor " + key + "#" + desc.getTag() + "#" + desc.getTagClass()); } } @@ -195,6 +192,7 @@ public class StoreRegistry { * Unregister a description. * * @param desc The description + * * @return the description, or <code>null</code> if it was not registered */ public StoreDescription unregisterDescription(StoreDescription desc) { @@ -216,6 +214,7 @@ public class StoreRegistry { /** * Set the encoding to use when writing the configuration files. + * * @param string The encoding */ public void setEncoding(String string) { diff --git a/java/org/apache/catalina/storeconfig/WatchedResourceSF.java b/java/org/apache/catalina/storeconfig/WatchedResourceSF.java index a27c3e4965..a402f10343 100644 --- a/java/org/apache/catalina/storeconfig/WatchedResourceSF.java +++ b/java/org/apache/catalina/storeconfig/WatchedResourceSF.java @@ -26,19 +26,16 @@ public class WatchedResourceSF extends StoreFactoryBase { private static Log log = LogFactory.getLog(WatchedResourceSF.class); @Override - public void store(PrintWriter aWriter, int indent, Object aElement) - throws Exception { + public void store(PrintWriter aWriter, int indent, Object aElement) throws Exception { if (aElement instanceof StandardContext) { - StoreDescription elementDesc = getRegistry().findDescription( - aElement.getClass().getName() + ".[WatchedResource]"); - String[] resources = ((StandardContext) aElement) - .findWatchedResources(); + StoreDescription elementDesc = + getRegistry().findDescription(aElement.getClass().getName() + ".[WatchedResource]"); + String[] resources = ((StandardContext) aElement).findWatchedResources(); if (elementDesc != null) { if (log.isTraceEnabled()) { log.trace("store " + elementDesc.getTag() + "( " + aElement + " )"); } - getStoreAppender().printTagArray(aWriter, "WatchedResource", - indent, resources); + getStoreAppender().printTagArray(aWriter, "WatchedResource", indent, resources); } } else { log.warn(sm.getString("storeFactory.noDescriptor", aElement.getClass(), "WatchedResource")); diff --git a/java/org/apache/catalina/storeconfig/WebResourceRootSF.java b/java/org/apache/catalina/storeconfig/WebResourceRootSF.java index a226faaf6c..6d03aab62f 100644 --- a/java/org/apache/catalina/storeconfig/WebResourceRootSF.java +++ b/java/org/apache/catalina/storeconfig/WebResourceRootSF.java @@ -28,47 +28,42 @@ public class WebResourceRootSF extends StoreFactoryBase { /** * Store the specified Resources children. + * <p> * {@inheritDoc} */ @Override - public void storeChildren(PrintWriter aWriter, int indent, Object aResourceRoot, - StoreDescription parentDesc) throws Exception { + public void storeChildren(PrintWriter aWriter, int indent, Object aResourceRoot, StoreDescription parentDesc) + throws Exception { if (aResourceRoot instanceof WebResourceRoot) { WebResourceRoot resourceRoot = (WebResourceRoot) aResourceRoot; // Store nested <PreResources> elements WebResourceSet[] preResourcesArray = resourceRoot.getPreResources(); - StoreDescription preResourcesElementDesc = getRegistry().findDescription( - WebResourceSet.class.getName() - + ".[PreResources]"); + StoreDescription preResourcesElementDesc = + getRegistry().findDescription(WebResourceSet.class.getName() + ".[PreResources]"); if (preResourcesElementDesc != null) { for (WebResourceSet preResources : preResourcesArray) { - preResourcesElementDesc.getStoreFactory().store(aWriter, indent, - preResources); + preResourcesElementDesc.getStoreFactory().store(aWriter, indent, preResources); } } // Store nested <JarResources> elements WebResourceSet[] jarResourcesArray = resourceRoot.getJarResources(); - StoreDescription jarResourcesElementDesc = getRegistry().findDescription( - WebResourceSet.class.getName() - + ".[JarResources]"); + StoreDescription jarResourcesElementDesc = + getRegistry().findDescription(WebResourceSet.class.getName() + ".[JarResources]"); if (jarResourcesElementDesc != null) { for (WebResourceSet jarResources : jarResourcesArray) { - jarResourcesElementDesc.getStoreFactory().store(aWriter, indent, - jarResources); + jarResourcesElementDesc.getStoreFactory().store(aWriter, indent, jarResources); } } // Store nested <PostResources> elements WebResourceSet[] postResourcesArray = resourceRoot.getPostResources(); - StoreDescription postResourcesElementDesc = getRegistry().findDescription( - WebResourceSet.class.getName() - + ".[PostResources]"); + StoreDescription postResourcesElementDesc = + getRegistry().findDescription(WebResourceSet.class.getName() + ".[PostResources]"); if (postResourcesElementDesc != null) { for (WebResourceSet postResources : postResourcesArray) { - postResourcesElementDesc.getStoreFactory().store(aWriter, indent, - postResources); + postResourcesElementDesc.getStoreFactory().store(aWriter, indent, postResources); } } diff --git a/java/org/apache/catalina/storeconfig/WrapperLifecycleSF.java b/java/org/apache/catalina/storeconfig/WrapperLifecycleSF.java index 6c2839dd30..1267050cb5 100644 --- a/java/org/apache/catalina/storeconfig/WrapperLifecycleSF.java +++ b/java/org/apache/catalina/storeconfig/WrapperLifecycleSF.java @@ -26,19 +26,16 @@ public class WrapperLifecycleSF extends StoreFactoryBase { private static Log log = LogFactory.getLog(WrapperLifecycleSF.class); @Override - public void store(PrintWriter aWriter, int indent, Object aElement) - throws Exception { + public void store(PrintWriter aWriter, int indent, Object aElement) throws Exception { if (aElement instanceof StandardContext) { - StoreDescription elementDesc = getRegistry().findDescription( - aElement.getClass().getName() + ".[WrapperLifecycle]"); - String[] listeners = ((StandardContext) aElement) - .findWrapperLifecycles(); + StoreDescription elementDesc = + getRegistry().findDescription(aElement.getClass().getName() + ".[WrapperLifecycle]"); + String[] listeners = ((StandardContext) aElement).findWrapperLifecycles(); if (elementDesc != null) { if (log.isTraceEnabled()) { log.trace("store " + elementDesc.getTag() + "( " + aElement + " )"); } - getStoreAppender().printTagArray(aWriter, "WrapperLifecycle", - indent, listeners); + getStoreAppender().printTagArray(aWriter, "WrapperLifecycle", indent, listeners); } } else { log.warn(sm.getString("storeFactory.noDescriptor", aElement.getClass(), "WrapperLifecycle")); diff --git a/java/org/apache/catalina/storeconfig/WrapperListenerSF.java b/java/org/apache/catalina/storeconfig/WrapperListenerSF.java index ae4d82af17..eee88e19e0 100644 --- a/java/org/apache/catalina/storeconfig/WrapperListenerSF.java +++ b/java/org/apache/catalina/storeconfig/WrapperListenerSF.java @@ -26,20 +26,16 @@ public class WrapperListenerSF extends StoreFactoryBase { private static Log log = LogFactory.getLog(WrapperListenerSF.class); @Override - public void store(PrintWriter aWriter, int indent, Object aElement) - throws Exception { + public void store(PrintWriter aWriter, int indent, Object aElement) throws Exception { if (aElement instanceof StandardContext) { - StoreDescription elementDesc = getRegistry().findDescription( - aElement.getClass().getName() + ".[WrapperListener]"); - String[] listeners = ((StandardContext) aElement) - .findWrapperListeners(); + StoreDescription elementDesc = + getRegistry().findDescription(aElement.getClass().getName() + ".[WrapperListener]"); + String[] listeners = ((StandardContext) aElement).findWrapperListeners(); if (elementDesc != null) { if (log.isTraceEnabled()) { - log.trace("store " + elementDesc.getTag() + "( " + aElement - + " )"); + log.trace("store " + elementDesc.getTag() + "( " + aElement + " )"); } - getStoreAppender().printTagArray(aWriter, "WrapperListener", - indent, listeners); + getStoreAppender().printTagArray(aWriter, "WrapperListener", indent, listeners); } } else { log.warn(sm.getString("storeFactory.noDescriptor", aElement.getClass(), "WrapperListener")); --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org