You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by re...@apache.org on 2013/02/04 17:11:51 UTC

svn commit: r1442161 [1/3] - in /tomcat/trunk: ./ java/org/apache/catalina/mbeans/ java/org/apache/catalina/storeconfig/ webapps/docs/

Author: remm
Date: Mon Feb  4 16:11:50 2013
New Revision: 1442161

URL: http://svn.apache.org/viewvc?rev=1442161&view=rev
Log:
Port storeconfig functionality to trunk (with a FIXME about the new resources configuration which will need some gets to be able to be persisted).

Added:
    tomcat/trunk/java/org/apache/catalina/storeconfig/
    tomcat/trunk/java/org/apache/catalina/storeconfig/CatalinaClusterSF.java
    tomcat/trunk/java/org/apache/catalina/storeconfig/ChannelSF.java
    tomcat/trunk/java/org/apache/catalina/storeconfig/ConnectorSF.java
    tomcat/trunk/java/org/apache/catalina/storeconfig/ConnectorStoreAppender.java
    tomcat/trunk/java/org/apache/catalina/storeconfig/Constants.java
    tomcat/trunk/java/org/apache/catalina/storeconfig/GlobalNamingResourcesSF.java
    tomcat/trunk/java/org/apache/catalina/storeconfig/IStoreConfig.java
    tomcat/trunk/java/org/apache/catalina/storeconfig/IStoreFactory.java
    tomcat/trunk/java/org/apache/catalina/storeconfig/InstanceListenerSF.java
    tomcat/trunk/java/org/apache/catalina/storeconfig/InterceptorSF.java
    tomcat/trunk/java/org/apache/catalina/storeconfig/LoaderSF.java
    tomcat/trunk/java/org/apache/catalina/storeconfig/LocalStrings.properties
    tomcat/trunk/java/org/apache/catalina/storeconfig/ManagerSF.java
    tomcat/trunk/java/org/apache/catalina/storeconfig/NamingResourcesSF.java
    tomcat/trunk/java/org/apache/catalina/storeconfig/PersistentManagerSF.java
    tomcat/trunk/java/org/apache/catalina/storeconfig/SenderSF.java
    tomcat/trunk/java/org/apache/catalina/storeconfig/StandardContextSF.java
    tomcat/trunk/java/org/apache/catalina/storeconfig/StandardEngineSF.java
    tomcat/trunk/java/org/apache/catalina/storeconfig/StandardHostSF.java
    tomcat/trunk/java/org/apache/catalina/storeconfig/StandardServerSF.java
    tomcat/trunk/java/org/apache/catalina/storeconfig/StandardServiceSF.java
    tomcat/trunk/java/org/apache/catalina/storeconfig/StoreAppender.java
    tomcat/trunk/java/org/apache/catalina/storeconfig/StoreConfig.java
    tomcat/trunk/java/org/apache/catalina/storeconfig/StoreConfigLifecycleListener.java
    tomcat/trunk/java/org/apache/catalina/storeconfig/StoreContextAppender.java
    tomcat/trunk/java/org/apache/catalina/storeconfig/StoreDescription.java
    tomcat/trunk/java/org/apache/catalina/storeconfig/StoreFactoryBase.java
    tomcat/trunk/java/org/apache/catalina/storeconfig/StoreFactoryRule.java
    tomcat/trunk/java/org/apache/catalina/storeconfig/StoreFileMover.java
    tomcat/trunk/java/org/apache/catalina/storeconfig/StoreLoader.java
    tomcat/trunk/java/org/apache/catalina/storeconfig/StoreRegistry.java
    tomcat/trunk/java/org/apache/catalina/storeconfig/WatchedResourceSF.java
    tomcat/trunk/java/org/apache/catalina/storeconfig/WebResourceRootSF.java
    tomcat/trunk/java/org/apache/catalina/storeconfig/WrapperLifecycleSF.java
    tomcat/trunk/java/org/apache/catalina/storeconfig/WrapperListenerSF.java
    tomcat/trunk/java/org/apache/catalina/storeconfig/mbeans-descriptors.xml   (with props)
    tomcat/trunk/java/org/apache/catalina/storeconfig/server-registry.xml   (with props)
Modified:
    tomcat/trunk/build.xml
    tomcat/trunk/java/org/apache/catalina/mbeans/MBeanUtils.java
    tomcat/trunk/webapps/docs/changelog.xml

Modified: tomcat/trunk/build.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/build.xml?rev=1442161&r1=1442160&r2=1442161&view=diff
==============================================================================
--- tomcat/trunk/build.xml (original)
+++ tomcat/trunk/build.xml Mon Feb  4 16:11:50 2013
@@ -94,6 +94,7 @@
   <property name="catalina-tribes.jar" value="${tomcat.build}/lib/catalina-tribes.jar"/>
   <property name="catalina-ha.jar" value="${tomcat.build}/lib/catalina-ha.jar"/>
   <property name="catalina-ant.jar" value="${tomcat.build}/lib/catalina-ant.jar"/>
+  <property name="catalina-storeconfig.jar" value="${tomcat.build}/lib/catalina-storeconfig.jar"/>
   <property name="tomcat-coyote.jar" value="${tomcat.build}/lib/tomcat-coyote.jar"/>
   <property name="tomcat-jni.jar" value="${tomcat.build}/lib/tomcat-jni.jar"/>
   <property name="tomcat-spdy.jar" value="${tomcat.build}/lib/tomcat-spdy.jar"/>
@@ -120,6 +121,7 @@
   <property name="catalina-tribes-src.jar" value="${tomcat.src.jars}/catalina-tribes-src.jar"/>
   <property name="catalina-ha-src.jar" value="${tomcat.src.jars}/catalina-ha-src.jar"/>
   <property name="catalina-ant-src.jar" value="${tomcat.src.jars}/catalina-ant-src.jar"/>
+  <property name="catalina-storeconfig-src.jar" value="${tomcat.src.jars}/catalina-storeconfig-src.jar"/>
   <property name="tomcat-jni-src.jar" value="${tomcat.src.jars}/tomcat-jni-src.jar"/>
   <property name="tomcat-spdy-src.jar" value="${tomcat.src.jars}/tomcat-spdy-src.jar"/>
   <property name="tomcat-coyote-src.jar" value="${tomcat.src.jars}/tomcat-coyote-src.jar"/>
@@ -326,6 +328,7 @@
     <exclude name="org/apache/catalina/ha/**" />
     <exclude name="org/apache/catalina/mbeans/JmxRemote*" />
     <exclude name="org/apache/catalina/tribes/**" />
+    <exclude name="org/apache/catalina/storeconfig/**" />
     <exclude name="org/apache/naming/factory/webservices/**" />
   </patternset>
 
@@ -343,6 +346,10 @@
     <include name="org/apache/catalina/util/Base64.*" />
   </patternset>
 
+  <patternset id="files.catalina-storeconfig">
+    <include name="org/apache/catalina/storeconfig/**" />
+  </patternset>
+
   <patternset id="files.tomcat-jni">
     <include name="org/apache/tomcat/jni/**" />
   </patternset>
@@ -708,6 +715,11 @@
       filesDir="${tomcat.classes}"
       filesId="files.catalina-ant" />
 
+    <!-- Catalina Storeconfig JAR File -->
+    <jarIt jarfile="${catalina-storeconfig.jar}"
+      filesDir="${tomcat.classes}"
+      filesId="files.catalina-storeconfig" />
+
     <!-- Tomcat API JAR File -->
     <jarIt jarfile="${tomcat-api.jar}"
       filesDir="${tomcat.classes}"
@@ -2329,6 +2341,11 @@ Apache Tomcat ${version} native binaries
       filesDir="java"
       filesId="files.catalina-ant" />
 
+    <!-- Catalina Storeconfig JAR File -->
+    <jarIt jarfile="${catalina-storeconfig-src.jar}"
+      filesDir="java"
+      filesId="files.catalina-storeconfig" />
+
     <!-- Tomcat API JAR File -->
     <jarIt jarfile="${tomcat-api-src.jar}"
       filesDir="java"

Modified: tomcat/trunk/java/org/apache/catalina/mbeans/MBeanUtils.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/mbeans/MBeanUtils.java?rev=1442161&r1=1442160&r2=1442161&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/mbeans/MBeanUtils.java (original)
+++ tomcat/trunk/java/org/apache/catalina/mbeans/MBeanUtils.java Mon Feb  4 16:11:50 2013
@@ -563,6 +563,7 @@ public class MBeanUtils {
             registry.loadDescriptors("org.apache.catalina.ha", cl);
             registry.loadDescriptors("org.apache.catalina.connector", cl);
             registry.loadDescriptors("org.apache.catalina.valves",  cl);
+            registry.loadDescriptors("org.apache.catalina.storeconfig",  cl);
         }
         return (registry);
 

Added: tomcat/trunk/java/org/apache/catalina/storeconfig/CatalinaClusterSF.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/storeconfig/CatalinaClusterSF.java?rev=1442161&view=auto
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/storeconfig/CatalinaClusterSF.java (added)
+++ tomcat/trunk/java/org/apache/catalina/storeconfig/CatalinaClusterSF.java Mon Feb  4 16:11:50 2013
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.catalina.storeconfig;
+
+import java.io.PrintWriter;
+
+import org.apache.catalina.LifecycleListener;
+import org.apache.catalina.Valve;
+import org.apache.catalina.ha.CatalinaCluster;
+import org.apache.catalina.ha.ClusterDeployer;
+import org.apache.catalina.ha.ClusterListener;
+import org.apache.catalina.ha.ClusterManager;
+import org.apache.catalina.ha.tcp.SimpleTcpCluster;
+import org.apache.catalina.tribes.Channel;
+
+/**
+ * Generate Cluster Element with Membership,Sender,Receiver,Deployer and
+ * ReplicationValve
+ */
+public class CatalinaClusterSF extends StoreFactoryBase {
+
+    /**
+     * Store the specified Cluster childs.
+     * 
+     * @param aWriter
+     *            PrintWriter to which we are storing
+     * @param indent
+     *            Number of spaces to indent this element
+     * @param aCluster
+     *            Cluster whose properties are being stored
+     * 
+     * @exception Exception
+     *                if an exception occurs while storing
+     */
+    public void storeChilds(PrintWriter aWriter, int indent, Object aCluster,
+            StoreDescription parentDesc) throws Exception {
+        if (aCluster instanceof CatalinaCluster) {
+            CatalinaCluster cluster = (CatalinaCluster) aCluster;
+            if (cluster instanceof SimpleTcpCluster) {
+                SimpleTcpCluster tcpCluster = (SimpleTcpCluster) cluster;
+                // Store nested <Manager> element
+                ClusterManager manager = tcpCluster.getManagerTemplate();
+                if (manager != null) {
+                    storeElement(aWriter, indent, manager);
+                }
+            }
+            // Store nested <Channel> element
+            Channel channel = cluster.getChannel();
+            if (channel != null) {
+                storeElement(aWriter, indent, channel);
+            }
+            // Store nested <Deployer> element
+            ClusterDeployer deployer = cluster.getClusterDeployer();
+            if (deployer != null) {
+                storeElement(aWriter, indent, deployer);
+            }
+            // Store nested <Valve> element
+            // ClusterValve are not store at Hosts element, see
+            Valve valves[] = cluster.getValves();
+            storeElementArray(aWriter, indent, valves);
+ 
+            if (aCluster instanceof SimpleTcpCluster) {
+                // Store nested <Listener> elements
+                LifecycleListener listeners[] = ((SimpleTcpCluster)cluster).findLifecycleListeners();
+                storeElementArray(aWriter, indent, listeners);
+                // Store nested <ClusterListener> elements
+                ClusterListener mlisteners[] = ((SimpleTcpCluster)cluster).findClusterListeners();
+                storeElementArray(aWriter, indent, mlisteners);
+            }
+        }
+    }
+}
\ No newline at end of file

Added: tomcat/trunk/java/org/apache/catalina/storeconfig/ChannelSF.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/storeconfig/ChannelSF.java?rev=1442161&view=auto
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/storeconfig/ChannelSF.java (added)
+++ tomcat/trunk/java/org/apache/catalina/storeconfig/ChannelSF.java Mon Feb  4 16:11:50 2013
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.catalina.storeconfig;
+
+import java.io.PrintWriter;
+import java.util.Iterator;
+
+import org.apache.catalina.tribes.Channel;
+import org.apache.catalina.tribes.ChannelInterceptor;
+import org.apache.catalina.tribes.ChannelReceiver;
+import org.apache.catalina.tribes.ChannelSender;
+import org.apache.catalina.tribes.ManagedChannel;
+import org.apache.catalina.tribes.MembershipService;
+
+/**
+ * Generate Channel Element
+ */
+public class ChannelSF extends StoreFactoryBase {
+
+    /**
+     * Store the specified Channel childs.
+     * 
+     * @param aWriter
+     *            PrintWriter to which we are storing
+     * @param indent
+     *            Number of spaces to indent this element
+     * @param aChannel
+     *            Channel whose properties are being stored
+     * 
+     * @exception Exception
+     *                if an exception occurs while storing
+     */
+    public void storeChilds(PrintWriter aWriter, int indent, Object aChannel,
+            StoreDescription parentDesc) throws Exception {
+        if (aChannel instanceof Channel) {
+            Channel channel = (Channel) aChannel;
+            if (channel instanceof ManagedChannel) {
+                ManagedChannel managedChannel = (ManagedChannel) channel;
+                // Store nested <Membership> element
+                MembershipService service = managedChannel.getMembershipService();
+                if (service != null) {
+                    storeElement(aWriter, indent, service);
+                }
+                // Store nested <Sender> element
+                ChannelSender sender = managedChannel.getChannelSender();
+                if (sender != null) {
+                    storeElement(aWriter, indent, sender);
+                }
+                // Store nested <Receiver> element
+                ChannelReceiver receiver = managedChannel.getChannelReceiver();
+                if (receiver != null) {
+                    storeElement(aWriter, indent, receiver);
+                }
+                Iterator<ChannelInterceptor> interceptors = managedChannel.getInterceptors();
+                while (interceptors.hasNext()) {
+                    ChannelInterceptor interceptor = interceptors.next();
+                    storeElement(aWriter, indent, interceptor);
+                }
+            }
+       }
+    }
+}
\ No newline at end of file

Added: tomcat/trunk/java/org/apache/catalina/storeconfig/ConnectorSF.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/storeconfig/ConnectorSF.java?rev=1442161&view=auto
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/storeconfig/ConnectorSF.java (added)
+++ tomcat/trunk/java/org/apache/catalina/storeconfig/ConnectorSF.java Mon Feb  4 16:11:50 2013
@@ -0,0 +1,86 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.catalina.storeconfig;
+
+import java.io.PrintWriter;
+
+import org.apache.catalina.Lifecycle;
+import org.apache.catalina.LifecycleListener;
+import org.apache.catalina.connector.Connector;
+
+/**
+ * Store Connector and Listeners
+ */
+public class ConnectorSF extends StoreFactoryBase {
+
+    /**
+     * Store Connector description
+     * 
+     * @param aWriter
+     * @param indent
+     * @param aConnector
+     * @throws Exception
+     */
+    public void storeChilds(PrintWriter aWriter, int indent, Object aConnector,
+            StoreDescription parentDesc) throws Exception {
+
+        if (aConnector instanceof Connector) {
+            Connector connector = (Connector) aConnector;
+            // Store nested <Listener> elements
+            if (connector instanceof Lifecycle) {
+                LifecycleListener listeners[] = ((Lifecycle) connector)
+                        .findLifecycleListeners();
+                storeElementArray(aWriter, indent, listeners);
+            }
+        }
+    }
+
+    protected void printOpenTag(PrintWriter aWriter, int indent, Object bean,
+            StoreDescription aDesc) throws Exception {
+        aWriter.print("<");
+        aWriter.print(aDesc.getTag());
+        storeConnectorAttribtues(aWriter, indent, bean, aDesc);
+        aWriter.println(">");
+    }
+
+    protected void storeConnectorAttribtues(PrintWriter aWriter, int indent,
+            Object bean, StoreDescription aDesc) throws Exception {
+        if (aDesc.isAttributes()) {
+            getStoreAppender().printAttributes(aWriter, indent, false, bean,
+                    aDesc);
+            /*
+             * if (bean instanceof Connector) { StoreDescription elementDesc =
+             * getRegistry().findDescription( bean.getClass().getName() +
+             * ".[ProtocolHandler]"); if (elementDesc != null) { ProtocolHandler
+             * protocolHandler = ((Connector) bean) .getProtocolHandler(); if
+             * (protocolHandler != null)
+             * getStoreAppender().printAttributes(aWriter, indent, false,
+             * protocolHandler, elementDesc); } }
+             */
+        }
+    }
+
+    protected void printTag(PrintWriter aWriter, int indent, Object bean,
+            StoreDescription aDesc) throws Exception {
+        aWriter.print("<");
+        aWriter.print(aDesc.getTag());
+        storeConnectorAttribtues(aWriter, indent, bean, aDesc);
+        aWriter.println("/>");
+    }
+
+}
\ No newline at end of file

Added: tomcat/trunk/java/org/apache/catalina/storeconfig/ConnectorStoreAppender.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/storeconfig/ConnectorStoreAppender.java?rev=1442161&view=auto
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/storeconfig/ConnectorStoreAppender.java (added)
+++ tomcat/trunk/java/org/apache/catalina/storeconfig/ConnectorStoreAppender.java Mon Feb  4 16:11:50 2013
@@ -0,0 +1,295 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.catalina.storeconfig;
+
+import java.beans.IndexedPropertyDescriptor;
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.net.InetAddress;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.catalina.connector.Connector;
+import org.apache.coyote.ProtocolHandler;
+import org.apache.tomcat.util.IntrospectionUtils;
+
+/**
+ * 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 attribtues from the Connector attribtue map.
+ * Strange is that some attributes change there name and the attribute
+ * sslProtocol need a sepzial handling
+ */
+public class ConnectorStoreAppender extends StoreAppender {
+
+    protected static HashMap<String, String> replacements = new HashMap<>();
+    static {
+        replacements.put("backlog", "acceptCount");
+        replacements.put("soLinger", "connectionLinger");
+        replacements.put("soTimeout", "connectionTimeout");
+        replacements.put("timeout", "connectionUploadTimeout");
+        replacements.put("clientauth", "clientAuth");
+        replacements.put("keystore", "keystoreFile");
+        replacements.put("randomfile", "randomFile");
+        replacements.put("rootfile", "rootFile");
+        replacements.put("keypass", "keystorePass");
+        replacements.put("keytype", "keystoreType");
+        replacements.put("protocol", "sslProtocol");
+        replacements.put("protocols", "sslProtocols");
+    }
+
+    /**
+     * Store the relevant attributes of the specified JavaBean.
+     * 
+     * @param writer
+     *            PrintWriter to which we are storing
+     * @param include
+     *            Should we include a <code>className</code> attribute?
+     * @param bean
+     *            Bean whose properties are to be rendered as attributes,
+     * @param desc
+     *            RegistryDescrpitor from this bean
+     * 
+     * @exception Exception
+     *                if an exception occurs while storing
+     */
+    public void printAttributes(PrintWriter writer, int indent,
+            boolean include, Object bean, StoreDescription desc)
+            throws Exception {
+
+        // Render a className attribute if requested
+        if (include && desc != null && !desc.isStandard()) {
+            writer.print(" className=\"");
+            writer.print(bean.getClass().getName());
+            writer.print("\"");
+        }
+
+        Connector connector = (Connector) bean;
+        String protocol = connector.getProtocol();
+        List<String> propertyKeys = getPropertyKeys(connector);
+        // Create blank instance
+        Object bean2 = new Connector(protocol);//defaultInstance(bean);
+        Iterator<String> propertyIterator = propertyKeys.iterator();
+        while (propertyIterator.hasNext()) {
+            String key = propertyIterator.next();
+            Object value = (Object) IntrospectionUtils.getProperty(bean, key);
+
+            if (desc.isTransientAttribute(key)) {
+                continue; // Skip the specified exceptions
+            }
+            if (value == null) {
+                continue; // Null values are not persisted
+            }
+            // Convert IP addresses to strings so they will be persisted
+            if (value instanceof InetAddress) {
+                value = ((InetAddress) value).getHostAddress();
+            }
+            if (!isPersistable(value.getClass())) {
+                continue;
+            }
+            Object value2 = IntrospectionUtils.getProperty(bean2, key);
+            if (value.equals(value2)) {
+                // The property has its default value
+                continue;
+            }
+            if (isPrintValue(bean, bean2, key, desc)) {
+                printValue(writer, indent, key, value);
+            }
+        }
+        if (protocol != null && !"HTTP/1.1".equals(protocol))
+            super.printValue(writer, indent, "protocol", protocol);
+
+    }
+
+    /**
+     * Get all properties from Connector and current ProtocolHandler
+     * 
+     * @param bean
+     * @return List of Connector Properties
+     * @throws IntrospectionException
+     */
+    protected List<String> getPropertyKeys(Connector bean)
+            throws IntrospectionException {
+        ArrayList<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();
+        if (descriptors == null) {
+            descriptors = new PropertyDescriptor[0];
+        }
+        for (int i = 0; i < descriptors.length; i++) {
+            if (descriptors[i] instanceof IndexedPropertyDescriptor) {
+                continue; // Indexed properties are not persisted
+            }
+            if (!isPersistable(descriptors[i].getPropertyType())
+                    || (descriptors[i].getReadMethod() == null)
+                    || (descriptors[i].getWriteMethod() == null)) {
+                continue; // Must be a read-write primitive or String
+            }
+            if ("protocol".equals(descriptors[i].getName())
+                    || "protocolHandlerClassName".equals(descriptors[i]
+                            .getName()))
+                continue;
+            propertyKeys.add(descriptors[i].getName());
+        }
+        // Add the properties of the protocol handler
+        descriptors = Introspector.getBeanInfo(
+                protocolHandler.getClass()).getPropertyDescriptors();
+        if (descriptors == null) {
+            descriptors = new PropertyDescriptor[0];
+        }
+        for (int i = 0; i < descriptors.length; i++) {
+            if (descriptors[i] instanceof IndexedPropertyDescriptor) {
+                continue; // Indexed properties are not persisted
+            }
+            if (!isPersistable(descriptors[i].getPropertyType())
+                    || (descriptors[i].getReadMethod() == null)
+                    || (descriptors[i].getWriteMethod() == null)) {
+                continue; // Must be a read-write primitive or String
+            }
+            String key = descriptors[i].getName();
+            if (replacements.get(key) != null) {
+                key = (String) replacements.get(key);
+            }
+            if (!propertyKeys.contains(key)) {
+                propertyKeys.add(key);
+            }
+        }
+        return propertyKeys;
+    }
+
+    /**
+     * print Attributes
+     * 
+     * @param aWriter
+     * @param indent
+     * @param bean
+     * @param aDesc
+     * @throws Exception
+     */
+    protected void storeConnectorAttribtues(PrintWriter aWriter, int indent,
+            Object bean, StoreDescription aDesc) throws Exception {
+        if (aDesc.isAttributes()) {
+            printAttributes(aWriter, indent, false, bean, aDesc);
+        }
+    }
+
+    /*
+     * Print the open tag for connector attributes (override)
+     * 
+     * @see org.apache.catalina.storeconfig.StoreAppender#printOpenTag(java.io.PrintWriter,
+     *      int, java.lang.Object,
+     *      org.apache.catalina.storeconfig.StoreDescription)
+     */
+    public void printOpenTag(PrintWriter aWriter, int indent, Object bean,
+            StoreDescription aDesc) throws Exception {
+        aWriter.print("<");
+        aWriter.print(aDesc.getTag());
+        storeConnectorAttribtues(aWriter, indent, bean, aDesc);
+        aWriter.println(">");
+    }
+
+    /**
+     * print a tag for connector attributes (override)
+     * 
+     * @see org.apache.catalina.storeconfig.StoreAppender#printTag(java.io.PrintWriter,
+     *      int, java.lang.Object,
+     *      org.apache.catalina.storeconfig.StoreDescription)
+     */
+    public void printTag(PrintWriter aWriter, int indent, Object bean,
+            StoreDescription aDesc) throws Exception {
+        aWriter.print("<");
+        aWriter.print(aDesc.getTag());
+        storeConnectorAttribtues(aWriter, indent, bean, aDesc);
+        aWriter.println("/>");
+    }
+
+    /**
+     * print a value but replace attribute name
+     * 
+     * @param writer
+     * @param name
+     * @param value
+     * @see org.apache.catalina.storeconfig.StoreAppender#printValue(java.io.PrintWriter,
+     *      int, java.lang.String, java.lang.Object)
+     */
+    public void printValue(PrintWriter writer, int indent, String name,
+            Object value) {
+        String repl = name;
+        if (replacements.get(name) != null) {
+            repl = (String) replacements.get(name);
+        }
+        super.printValue(writer, indent, repl, value);
+    }
+    
+    /*
+     * Print Connector Values. <ul><li> Spezial handling to default jkHome.
+     * </li><li> Don't save catalina.base path at server.xml</li><li></ul>
+     * 
+     * @see org.apache.catalina.config.StoreAppender#isPrintValue(java.lang.Object,
+     *      java.lang.Object, java.lang.String,
+     *      org.apache.catalina.config.StoreDescription)
+     */
+    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);
+                isPrint = !catalinaBase.equals(jkHomeBase);
+
+            }
+        }
+        return isPrint;
+    }
+
+    protected File getCatalinaBase() {
+
+        File file = new File(System.getProperty("catalina.base"));
+        try {
+            file = file.getCanonicalFile();
+        } catch (IOException e) {
+        }
+        return (file);
+    }
+
+    protected File getJkHomeBase(String jkHome, File appBase) {
+
+        File jkHomeBase;
+        File file = new File(jkHome);
+        if (!file.isAbsolute())
+            file = new File(appBase, jkHome);
+        try {
+            jkHomeBase = file.getCanonicalFile();
+        } catch (IOException e) {
+            jkHomeBase = file;
+        }
+        return (jkHomeBase);
+    }
+
+}
\ No newline at end of file

Added: tomcat/trunk/java/org/apache/catalina/storeconfig/Constants.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/storeconfig/Constants.java?rev=1442161&view=auto
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/storeconfig/Constants.java (added)
+++ tomcat/trunk/java/org/apache/catalina/storeconfig/Constants.java Mon Feb  4 16:11:50 2013
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.catalina.storeconfig;
+
+public class Constants {
+
+    public static final String Package = "org.apache.catalina.storeconfig";
+
+}
\ No newline at end of file

Added: tomcat/trunk/java/org/apache/catalina/storeconfig/GlobalNamingResourcesSF.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/storeconfig/GlobalNamingResourcesSF.java?rev=1442161&view=auto
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/storeconfig/GlobalNamingResourcesSF.java (added)
+++ tomcat/trunk/java/org/apache/catalina/storeconfig/GlobalNamingResourcesSF.java Mon Feb  4 16:11:50 2013
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.catalina.storeconfig;
+
+import java.io.PrintWriter;
+
+import org.apache.catalina.deploy.NamingResources;
+import org.apache.juli.logging.Log;
+import org.apache.juli.logging.LogFactory;
+
+/**
+ * store server.xml GlobalNamingResource.
+ */
+public class GlobalNamingResourcesSF extends StoreFactoryBase {
+    private static Log log = LogFactory.getLog(GlobalNamingResourcesSF.class);
+
+    /*
+     * Store with NamingResource Factory
+     * 
+     * @see org.apache.catalina.storeconfig.IStoreFactory#store(java.io.PrintWriter,
+     *      int, java.lang.Object)
+     */
+    public void store(PrintWriter aWriter, int indent, Object aElement)
+            throws Exception {
+
+        if (aElement instanceof NamingResources) {
+
+            StoreDescription elementDesc = getRegistry().findDescription(
+                    NamingResources.class.getName()
+                            + ".[GlobalNamingResources]");
+
+            if (elementDesc != null) {
+                getStoreAppender().printIndent(aWriter, indent + 2);
+                getStoreAppender().printOpenTag(aWriter, indent + 2, aElement,
+                        elementDesc);
+                NamingResources resources = (NamingResources) aElement;
+                StoreDescription resourcesdesc = getRegistry().findDescription(
+                        NamingResources.class.getName());
+                if (resourcesdesc != null) {
+                    resourcesdesc.getStoreFactory().store(aWriter, indent + 2,
+                            resources);
+                } else {
+                    if(log.isWarnEnabled())
+                        log.warn("Can't find NamingRsources Store Factory!");
+                }
+                    
+                getStoreAppender().printIndent(aWriter, indent + 2);
+                getStoreAppender().printCloseTag(aWriter, elementDesc);
+            } else {
+                if (log.isWarnEnabled())
+                    log.warn("Descriptor for element" + aElement.getClass()
+                            + " not configured!");
+            }
+        } else {
+            if (log.isWarnEnabled())
+                log.warn("wrong element " + aElement.getClass());
+
+        }
+    }
+}
+

Added: tomcat/trunk/java/org/apache/catalina/storeconfig/IStoreConfig.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/storeconfig/IStoreConfig.java?rev=1442161&view=auto
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/storeconfig/IStoreConfig.java (added)
+++ tomcat/trunk/java/org/apache/catalina/storeconfig/IStoreConfig.java Mon Feb  4 16:11:50 2013
@@ -0,0 +1,147 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.catalina.storeconfig;
+
+import java.io.PrintWriter;
+
+import org.apache.catalina.Context;
+import org.apache.catalina.Host;
+import org.apache.catalina.Server;
+import org.apache.catalina.Service;
+
+public interface IStoreConfig {
+
+    /**
+     * Get Configuration Registry
+     * 
+     * @return aRegistry that handle the store operations
+     */
+    StoreRegistry getRegistry();
+
+    /**
+     * Set Configuration Registry
+     * 
+     * @param aRegistry
+     *            aregistry that handle the store operations
+     */
+    void setRegistry(StoreRegistry aRegistry);
+
+    /**
+     * Get associated server
+     * 
+     * @return aServer the associated server
+     */
+    Server getServer();
+
+    /**
+     * Set associated server
+     * 
+     * @param aServer the associated server
+     */
+    void setServer(Server aServer);
+
+    /**
+     * Store the current StoreFactory Server.
+     * 
+     * @exception Exception
+     *                if an exception occurs while storing
+     */
+    void storeConfig() throws Exception;
+
+    /**
+     * Store the specified Server properties.
+     * 
+     * @param aServer
+     *            Object to be stored
+     * 
+     * @exception Exception
+     *                if an exception occurs while storing
+     */
+    void store(Server aServer) throws Exception;
+
+    /**
+     * 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
+     * 
+     * @exception Exception
+     *                if an exception occurs while storing
+     */
+    void store(PrintWriter aWriter, int indent, Server aServer);
+
+    /**
+     * 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
+     * 
+     * @exception Exception
+     *                if an exception occurs while storing
+     */
+    void store(PrintWriter aWriter, int indent, Service aService);
+
+    /**
+     * 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
+     * 
+     * @exception Exception
+     *                if an exception occurs while storing
+     */
+    void store(PrintWriter aWriter, int indent, Host aHost);
+
+    /**
+     * Store the specified Context properties.
+     * 
+     * @param aContext
+     *            Object to be stored
+     * 
+     * @exception Exception
+     *                if an exception occurs while storing
+     */
+    void store(Context aContext);
+
+    /**
+     * 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
+     * 
+     * @exception Exception
+     *                if an exception occurs while storing
+     */
+    void store(PrintWriter aWriter, int indent, Context aContext);
+}
\ No newline at end of file

Added: tomcat/trunk/java/org/apache/catalina/storeconfig/IStoreFactory.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/storeconfig/IStoreFactory.java?rev=1442161&view=auto
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/storeconfig/IStoreFactory.java (added)
+++ tomcat/trunk/java/org/apache/catalina/storeconfig/IStoreFactory.java Mon Feb  4 16:11:50 2013
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.catalina.storeconfig;
+
+import java.io.PrintWriter;
+
+public interface IStoreFactory {
+    StoreAppender getStoreAppender();
+
+    void setStoreAppender(StoreAppender storeWriter);
+
+    void setRegistry(StoreRegistry aRegistry);
+
+    StoreRegistry getRegistry();
+
+    void store(PrintWriter aWriter, int indent, Object aElement)
+            throws Exception;
+
+    void storeXMLHead(PrintWriter aWriter);
+}
\ No newline at end of file

Added: tomcat/trunk/java/org/apache/catalina/storeconfig/InstanceListenerSF.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/storeconfig/InstanceListenerSF.java?rev=1442161&view=auto
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/storeconfig/InstanceListenerSF.java (added)
+++ tomcat/trunk/java/org/apache/catalina/storeconfig/InstanceListenerSF.java Mon Feb  4 16:11:50 2013
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.catalina.storeconfig;
+
+import java.io.PrintWriter;
+
+import org.apache.catalina.core.StandardContext;
+import org.apache.juli.logging.Log;
+import org.apache.juli.logging.LogFactory;
+
+/**
+ * Store Context InstanceListener
+ */
+public class InstanceListenerSF extends StoreFactoryBase {
+    private static Log log = LogFactory.getLog(InstanceListenerSF.class);
+
+    /*
+     * Store nested Element Value Arrays
+     * 
+     * @see org.apache.catalina.config.IStoreFactory#store(java.io.PrintWriter,
+     *      int, java.lang.Object)
+     */
+    public void store(PrintWriter aWriter, int indent, Object aElement)
+            throws Exception {
+        if (aElement instanceof StandardContext) {
+            StoreDescription elementDesc = getRegistry().findDescription(
+                    aElement.getClass().getName() + ".[InstanceListener]");
+            String[] listeners = ((StandardContext) aElement)
+                    .findInstanceListeners();
+            if (elementDesc != null) {
+                if (log.isDebugEnabled())
+                    log.debug("store " + elementDesc.getTag() + "( " + aElement
+                            + " )");
+                getStoreAppender().printTagArray(aWriter, "InstanceListener",
+                        indent, listeners);
+            }
+        } else {
+            if (log.isWarnEnabled())
+                log.warn("Descriptor for element" + aElement.getClass()
+                        + ".[InstanceListener] not configured!");
+        }
+    }
+}
\ No newline at end of file

Added: tomcat/trunk/java/org/apache/catalina/storeconfig/InterceptorSF.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/storeconfig/InterceptorSF.java?rev=1442161&view=auto
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/storeconfig/InterceptorSF.java (added)
+++ tomcat/trunk/java/org/apache/catalina/storeconfig/InterceptorSF.java Mon Feb  4 16:11:50 2013
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.catalina.storeconfig;
+
+import java.io.PrintWriter;
+
+import org.apache.catalina.tribes.ChannelInterceptor;
+
+/**
+ * Generate Interceptor Element
+ */
+public class InterceptorSF extends StoreFactoryBase {
+
+    /**
+     * Store the specified Interceptor child.
+     * 
+     * @param aWriter
+     *            PrintWriter to which we are storing
+     * @param indent
+     *            Number of spaces to indent this element
+     * @param aInterceptor
+     *            Channel whose properties are being stored
+     * 
+     * @exception Exception
+     *                if an exception occurs while storing
+     */
+    public void storeChilds(PrintWriter aWriter, int indent, Object aInterceptor,
+            StoreDescription parentDesc) throws Exception {
+        if (aInterceptor instanceof ChannelInterceptor) {
+            ChannelInterceptor interceptor = (ChannelInterceptor) aInterceptor;
+            // Store nested <Member> elements
+            storeElementArray(aWriter, indent + 2, interceptor.getMembers());
+       }
+    }
+}
\ No newline at end of file

Added: tomcat/trunk/java/org/apache/catalina/storeconfig/LoaderSF.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/storeconfig/LoaderSF.java?rev=1442161&view=auto
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/storeconfig/LoaderSF.java (added)
+++ tomcat/trunk/java/org/apache/catalina/storeconfig/LoaderSF.java Mon Feb  4 16:11:50 2013
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.catalina.storeconfig;
+
+import java.io.PrintWriter;
+
+import org.apache.catalina.Loader;
+import org.apache.catalina.loader.WebappLoader;
+import org.apache.juli.logging.Log;
+import org.apache.juli.logging.LogFactory;
+
+/**
+ * Store Loader Element.
+ */
+public class LoaderSF extends StoreFactoryBase {
+
+    private static Log log = LogFactory.getLog(LoaderSF.class);
+
+    /**
+     * Store the only the Loader elements, when not default
+     * 
+     * @see NamingResourcesSF#storeChilds(PrintWriter, int, Object, StoreDescription)
+     */
+    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)) {
+                if (log.isDebugEnabled())
+                    log.debug("store " + elementDesc.getTag() + "( " + aElement
+                            + " )");
+                getStoreAppender().printIndent(aWriter, indent + 2);
+                getStoreAppender().printTag(aWriter, indent + 2, loader,
+                        elementDesc);
+            }
+        } else {
+            if (log.isWarnEnabled()) {
+                log
+                        .warn("Descriptor for element"
+                                + aElement.getClass()
+                                + " not configured or element class not StandardManager!");
+            }
+        }
+    }
+
+    /**
+     * Is this an instance of the default <code>Loader</code> configuration,
+     * with all-default properties?
+     * 
+     * @param loader
+     *            Loader to be tested
+     */
+    protected boolean isDefaultLoader(Loader loader) {
+
+        if (!(loader instanceof WebappLoader)) {
+            return (false);
+        }
+        WebappLoader wloader = (WebappLoader) loader;
+        if ((wloader.getDelegate() != false)
+                || !wloader.getLoaderClass().equals(
+                        "org.apache.catalina.loader.WebappClassLoader")) {
+            return (false);
+        }
+        return (true);
+    }
+}

Added: tomcat/trunk/java/org/apache/catalina/storeconfig/LocalStrings.properties
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/storeconfig/LocalStrings.properties?rev=1442161&view=auto
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/storeconfig/LocalStrings.properties (added)
+++ tomcat/trunk/java/org/apache/catalina/storeconfig/LocalStrings.properties Mon Feb  4 16:11:50 2013
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+factory.storeTag=store tag {0} ( Object: {1} )
+factory.storeNoDescriptor=Descriptor for element class {0} not configured!

Added: tomcat/trunk/java/org/apache/catalina/storeconfig/ManagerSF.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/storeconfig/ManagerSF.java?rev=1442161&view=auto
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/storeconfig/ManagerSF.java (added)
+++ tomcat/trunk/java/org/apache/catalina/storeconfig/ManagerSF.java Mon Feb  4 16:11:50 2013
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.catalina.storeconfig;
+
+import java.io.PrintWriter;
+
+import org.apache.catalina.session.StandardManager;
+import org.apache.juli.logging.Log;
+import org.apache.juli.logging.LogFactory;
+
+/**
+ * Store server.xml Manager element
+ */
+public class ManagerSF extends StoreFactoryBase {
+
+    private static Log log = LogFactory.getLog(ManagerSF.class);
+
+    /**
+     * Store the only the Manager elements
+     * 
+     * @see NamingResourcesSF#storeChilds(PrintWriter, int, Object, StoreDescription)
+     */
+    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.isDebugEnabled())
+                        log.debug(sm.getString("factory.storeTag", elementDesc
+                                .getTag(), aElement));
+                    getStoreAppender().printIndent(aWriter, indent + 2);
+                    getStoreAppender().printTag(aWriter, indent + 2, manager,
+                            elementDesc);
+                }
+            } else {
+                super.store(aWriter, indent, aElement);
+            }
+        } else {
+            if (log.isWarnEnabled())
+                log.warn(sm.getString("factory.storeNoDescriptor", aElement
+                        .getClass()));
+        }
+    }
+
+    /**
+     * Is this an instance of the default <code>Manager</code> configuration,
+     * with all-default properties?
+     * 
+     * @param smanager
+     *            Manager to be tested
+     */
+    protected boolean isDefaultManager(StandardManager smanager) {
+
+        if (!"SESSIONS.ser".equals(smanager.getPathname())
+                || (smanager.getMaxActiveSessions() != -1)) {
+            return (false);
+        }
+        return (true);
+
+    }
+
+}

Added: tomcat/trunk/java/org/apache/catalina/storeconfig/NamingResourcesSF.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/storeconfig/NamingResourcesSF.java?rev=1442161&view=auto
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/storeconfig/NamingResourcesSF.java (added)
+++ tomcat/trunk/java/org/apache/catalina/storeconfig/NamingResourcesSF.java Mon Feb  4 16:11:50 2013
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.catalina.storeconfig;
+
+import java.io.PrintWriter;
+
+import org.apache.catalina.deploy.ContextEjb;
+import org.apache.catalina.deploy.ContextEnvironment;
+import org.apache.catalina.deploy.ContextLocalEjb;
+import org.apache.catalina.deploy.ContextResource;
+import org.apache.catalina.deploy.ContextResourceEnvRef;
+import org.apache.catalina.deploy.ContextResourceLink;
+import org.apache.catalina.deploy.NamingResources;
+import org.apache.juli.logging.Log;
+import org.apache.juli.logging.LogFactory;
+
+/**
+ * Store server.xml elements Resources at context and GlobalNamingResources
+ */
+public class NamingResourcesSF extends StoreFactoryBase {
+    private static Log log = LogFactory.getLog(NamingResourcesSF.class);
+
+    /**
+     * Store the only the NamingResources elements
+     * 
+     * @see NamingResourcesSF#storeChilds(PrintWriter, int, Object, StoreDescription)
+     */
+    public void store(PrintWriter aWriter, int indent, Object aElement)
+            throws Exception {
+        StoreDescription elementDesc = getRegistry().findDescription(
+                aElement.getClass());
+        if (elementDesc != null) {
+            if (log.isDebugEnabled())
+                log.debug("store " + elementDesc.getTag() + "( " + aElement
+                        + " )");
+            storeChilds(aWriter, indent, aElement, elementDesc);
+        } else {
+            if (log.isWarnEnabled())
+                log.warn("Descriptor for element" + aElement.getClass()
+                        + " not configured!");
+        }
+    }
+
+    /**
+     * Store the specified NamingResources properties.
+     * 
+     * @param aWriter
+     *            PrintWriter to which we are storing
+     * @param indent
+     *            Number of spaces to indent this element
+     * @param aElement
+     *            Object whose properties are being stored
+     * @param elementDesc
+     *            element descriptor
+     * 
+     * @exception Exception
+     *                if an exception occurs while storing
+     * 
+     * @see org.apache.catalina.storeconfig.StoreFactoryBase#storeChilds(java.io.PrintWriter,
+     *      int, java.lang.Object, StoreDescription)
+     */
+    public void storeChilds(PrintWriter aWriter, int indent, Object aElement,
+            StoreDescription elementDesc) throws Exception {
+
+        if (aElement instanceof NamingResources) {
+            NamingResources resources = (NamingResources) aElement;
+            // Store nested <Ejb> elements
+            ContextEjb[] ejbs = resources.findEjbs();
+            storeElementArray(aWriter, indent, ejbs);
+            // Store nested <Environment> elements
+            ContextEnvironment[] envs = resources.findEnvironments();
+            storeElementArray(aWriter, indent, envs);
+            // Store nested <LocalEjb> elements
+            ContextLocalEjb[] lejbs = resources.findLocalEjbs();
+            storeElementArray(aWriter, indent, lejbs);
+
+            // Store nested <Resource> elements
+            ContextResource[] dresources = resources.findResources();
+            storeElementArray(aWriter, indent, dresources);
+
+            // Store nested <ResourceEnvRef> elements
+            ContextResourceEnvRef[] resEnv = resources.findResourceEnvRefs();
+            storeElementArray(aWriter, indent, resEnv);
+
+            // Store nested <ResourceLink> elements
+            ContextResourceLink[] resourceLinks = resources.findResourceLinks();
+            storeElementArray(aWriter, indent, resourceLinks);
+        }
+    }
+}
+

Added: tomcat/trunk/java/org/apache/catalina/storeconfig/PersistentManagerSF.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/storeconfig/PersistentManagerSF.java?rev=1442161&view=auto
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/storeconfig/PersistentManagerSF.java (added)
+++ tomcat/trunk/java/org/apache/catalina/storeconfig/PersistentManagerSF.java Mon Feb  4 16:11:50 2013
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.catalina.storeconfig;
+
+import java.io.PrintWriter;
+
+import org.apache.catalina.Store;
+import org.apache.catalina.session.PersistentManager;
+
+/**
+ * store server.xml PersistentManager element with nested "Store"
+ */
+public class PersistentManagerSF extends StoreFactoryBase {
+
+    /**
+     * Store the specified PersistentManager properties.
+     * 
+     * @param aWriter
+     *            PrintWriter to which we are storing
+     * @param indent
+     *            Number of spaces to indent this element
+     * @param aManager
+     *            PersistentManager whose properties are being stored
+     * 
+     * @exception Exception
+     *                if an exception occurs while storing
+     */
+    public void storeChilds(PrintWriter aWriter, int indent, Object aManager,
+            StoreDescription parentDesc) throws Exception {
+        if (aManager instanceof PersistentManager) {
+            PersistentManager manager = (PersistentManager) aManager;
+
+            // Store nested <Manager> elements
+            Store store = manager.getStore();
+            storeElement(aWriter, indent, store);
+
+        }
+    }
+
+}
\ No newline at end of file

Added: tomcat/trunk/java/org/apache/catalina/storeconfig/SenderSF.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/storeconfig/SenderSF.java?rev=1442161&view=auto
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/storeconfig/SenderSF.java (added)
+++ tomcat/trunk/java/org/apache/catalina/storeconfig/SenderSF.java Mon Feb  4 16:11:50 2013
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.catalina.storeconfig;
+
+import java.io.PrintWriter;
+
+import org.apache.catalina.tribes.transport.MultiPointSender;
+import org.apache.catalina.tribes.transport.ReplicationTransmitter;
+
+/**
+ * Generate Sender Element
+ */
+public class SenderSF extends StoreFactoryBase {
+
+    /**
+     * Store the specified Sender child.
+     * 
+     * @param aWriter
+     *            PrintWriter to which we are storing
+     * @param indent
+     *            Number of spaces to indent this element
+     * @param aSender
+     *            Channel whose properties are being stored
+     * 
+     * @exception Exception
+     *                if an exception occurs while storing
+     */
+    public void storeChilds(PrintWriter aWriter, int indent, Object aSender,
+            StoreDescription parentDesc) throws Exception {
+        if (aSender instanceof ReplicationTransmitter) {
+            ReplicationTransmitter transmitter = (ReplicationTransmitter) aSender;
+            // Store nested <Transport> element
+            MultiPointSender transport = transmitter.getTransport();
+            if (transport != null) {
+                storeElement(aWriter, indent, transport);
+            }
+       }
+    }
+}
\ No newline at end of file

Added: tomcat/trunk/java/org/apache/catalina/storeconfig/StandardContextSF.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/storeconfig/StandardContextSF.java?rev=1442161&view=auto
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/storeconfig/StandardContextSF.java (added)
+++ tomcat/trunk/java/org/apache/catalina/storeconfig/StandardContextSF.java Mon Feb  4 16:11:50 2013
@@ -0,0 +1,377 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.catalina.storeconfig;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.catalina.Container;
+import org.apache.catalina.Context;
+import org.apache.catalina.Engine;
+import org.apache.catalina.Host;
+import org.apache.catalina.Lifecycle;
+import org.apache.catalina.LifecycleListener;
+import org.apache.catalina.Loader;
+import org.apache.catalina.Manager;
+import org.apache.catalina.Realm;
+import org.apache.catalina.Valve;
+import org.apache.catalina.WebResourceRoot;
+import org.apache.catalina.core.StandardContext;
+import org.apache.catalina.deploy.ApplicationParameter;
+import org.apache.catalina.deploy.NamingResources;
+import org.apache.juli.logging.Log;
+import org.apache.juli.logging.LogFactory;
+
+/**
+ * Store server.xml Context element with all childs
+ * <ul>
+ * <li>Store all context at server.xml</li>
+ * <li>Store existing app.xml context a conf/enginename/hostname/app.xml</li>
+ * <li>Store with backup</li>
+ * </ul>
+ */
+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.
+     * 
+     * @see org.apache.catalina.config.IStoreFactory#store(java.io.PrintWriter,
+     *      int, java.lang.Object)
+     */
+    public void store(PrintWriter aWriter, int indent, Object aContext)
+            throws Exception {
+
+        if (aContext instanceof StandardContext) {
+            StoreDescription desc = getRegistry().findDescription(
+                    aContext.getClass());
+            if (desc.isStoreSeparate()) {
+                URL configFile = ((StandardContext) aContext)
+                        .getConfigFile();
+                if (configFile != null) {
+                    if (desc.isExternalAllowed()) {
+                        if (desc.isBackup())
+                            storeWithBackup((StandardContext) aContext);
+                        else
+                            storeContextSeparate(aWriter, indent,
+                                    (StandardContext) aContext);
+                        return;
+                    }
+                } else if (desc.isExternalOnly()) {
+                    return;
+                }
+            }
+        }
+        super.store(aWriter, indent, aContext);
+
+    }
+
+    /**
+     * Store a Context without backup add separate file or when configFile =
+     * null a aWriter.
+     * 
+     * @param aWriter
+     * @param indent
+     * @param aContext
+     * @throws Exception
+     */
+    protected void storeContextSeparate(PrintWriter aWriter, int indent,
+            StandardContext aContext) throws Exception {
+        URL configFile = aContext.getConfigFile();
+        PrintWriter writer = null;
+        if (configFile != null) {
+            File config = new File(configFile.toURI());
+            if (!config.isAbsolute()) {
+                config = new File(System.getProperty("catalina.base"),
+                        config.getPath());
+            }            
+            if( (!config.isFile()) || (!config.canWrite())) {
+                log.error("Cannot write context output file at "
+                            + configFile + ", not saving.");
+                throw new IOException("Context save file at "
+                                      + configFile
+                                      + " not a file, or not writable.");
+            }
+            if (log.isInfoEnabled())
+                log.info("Store Context " + aContext.getPath()
+                        + " separate at file " + config);
+            try {
+                writer = new PrintWriter(new OutputStreamWriter(
+                        new FileOutputStream(config), getRegistry()
+                                .getEncoding()));
+                storeXMLHead(writer);
+                super.store(writer, -2, aContext);
+            } finally {
+                if (writer != null) {
+                    try {
+                        writer.flush();
+                    } catch (Exception e) {
+                        ;
+                    }
+                    try {
+                        writer.close();
+                    } catch (Throwable t) {
+                        ;
+                    }
+                }
+            }
+        } else {
+            super.store(aWriter, indent, aContext);
+        }
+    }
+
+    /**
+     * Store the Context with a Backup
+     * 
+     * @param aContext
+     * @throws Exception
+     */
+    protected void storeWithBackup(StandardContext aContext) throws Exception {
+        StoreFileMover mover = getConfigFileWriter((Context) 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())) {
+                log.error("Cannot move orignal context output file at "
+                        + mover.getConfigOld());
+                throw new IOException("Context orginal file at "
+                        + mover.getConfigOld()
+                        + " is null, not a file or not writable.");
+            }
+            File dir = mover.getConfigSave().getParentFile();
+            if (dir != null && dir.isDirectory() && (!dir.canWrite())) {
+                log.error("Cannot save context output file at "
+                        + mover.getConfigSave());
+                throw new IOException("Context save file at "
+                        + mover.getConfigSave() + " is not writable.");
+            }
+            if (log.isInfoEnabled())
+                log.info("Store Context " + aContext.getPath()
+                        + " separate with backup (at file "
+                        + mover.getConfigSave() + " )");
+
+            PrintWriter writer = null;
+            try {
+                writer = mover.getWriter();
+                storeXMLHead(writer);
+                super.store(writer, -2, aContext);
+            } finally {
+                if (writer != null) {
+                    // Flush and close the output file
+                    try {
+                        writer.flush();
+                    } catch (Exception e) {
+                        log.error(e);
+                    }
+                    try {
+                        writer.close();
+                    } catch (Exception e) {
+                        throw (e);
+                    }
+                }
+            }
+            mover.move();
+        }
+    }
+
+    /**
+     * Get explicit writer for context (context.getConfigFile()).
+     * 
+     * @param context
+     * @return The file mover
+     * @throws IOException
+     */
+    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("catalina.base"),
+                        config.getPath());
+            }
+            // Open an output writer for the new configuration file
+            mover = new StoreFileMover("", config.getCanonicalPath(),
+                    getRegistry().getEncoding());
+        }
+        return mover;
+    }
+
+    /**
+     * Store the specified Host properties.
+     * 
+     * @param aWriter
+     *            PrintWriter to which we are storing
+     * @param indent
+     *            Number of spaces to indent this element
+     * @param aContext
+     *            Context whose properties are being stored
+     * 
+     * @exception Exception
+     *                if an exception occurs while storing
+     */
+    public void storeChilds(PrintWriter aWriter, int indent, Object aContext,
+            StoreDescription parentDesc) throws Exception {
+        if (aContext instanceof StandardContext) {
+            StandardContext context = (StandardContext) aContext;
+            // Store nested <Listener> elements
+            if (context instanceof Lifecycle) {
+                LifecycleListener listeners[] = context
+                        .findLifecycleListeners();
+                storeElementArray(aWriter, indent, listeners);
+            }
+            // Store nested <Valve> elements
+            Valve valves[] = context.getPipeline().getValves();
+            storeElementArray(aWriter, indent, valves);
+
+            // Store nested <Loader> elements
+            Loader loader = context.getLoader();
+            storeElement(aWriter, indent, loader);
+
+            // Store nested <Manager> elements
+            if (context.getCluster() == null) {
+                Manager manager = context.getManager();
+                storeElement(aWriter, indent, manager);
+            }
+
+            // Store nested <Realm> element
+            Realm realm = context.getRealm();
+            if (realm != null) {
+                Realm parentRealm = null;
+                // @TODO is this case possible?
+                if (context.getParent() != null) {
+                    parentRealm = context.getParent().getRealm();
+                }
+                if (realm != parentRealm) {
+                    storeElement(aWriter, indent, realm);
+                }
+            }
+            // Store nested resources
+            WebResourceRoot resources = context.getResources();
+            storeElement(aWriter, indent, resources);
+
+            // Store nested <InstanceListener> elements
+            String iListeners[] = context.findInstanceListeners();
+            getStoreAppender().printTagArray(aWriter, "InstanceListener",
+                    indent + 2, iListeners);
+
+            // Store nested <WrapperListener> elements
+            String wLifecycles[] = context.findWrapperLifecycles();
+            getStoreAppender().printTagArray(aWriter, "WrapperListener",
+                    indent + 2, wLifecycles);
+            // Store nested <WrapperLifecycle> elements
+            String wListeners[] = context.findWrapperListeners();
+            getStoreAppender().printTagArray(aWriter, "WrapperLifecycle",
+                    indent + 2, wListeners);
+
+            // Store nested <Parameter> elements
+            ApplicationParameter[] appParams = context
+                    .findApplicationParameters();
+            storeElementArray(aWriter, indent, appParams);
+
+            // Store nested naming resources elements (EJB,Resource,...)
+            NamingResources nresources = context.getNamingResources();
+            storeElement(aWriter, indent, nresources);
+
+            // Store nested watched resources <WatchedResource>
+            String[] wresources = context.findWatchedResources();
+            wresources = filterWatchedResources(context, wresources);
+            getStoreAppender().printTagArray(aWriter, "WatchedResource",
+                    indent + 2, wresources);
+        }
+    }
+
+    /**
+     * Return a File object representing the "configuration root" directory for
+     * our associated Host.
+     */
+    protected File configBase(Context context) {
+
+        File file = new File(System.getProperty("catalina.base"), "conf");
+        Container host = (Host) context.getParent();
+
+        if ((host != null) && (host instanceof Host)) {
+            Container engine = host.getParent();
+            if ((engine != null) && (engine instanceof Engine)) {
+                file = new File(file, engine.getName());
+            }
+            file = new File(file, host.getName());
+            try {
+                file = file.getCanonicalFile();
+            } catch (IOException e) {
+                log.error(e);
+            }
+        }
+        return (file);
+
+    }
+
+    /**
+     * filter out the default watched resources
+     * 
+     * @param context
+     * @param wresources
+     * @return The watched resources
+     * @throws IOException
+     * TODO relative watchedresource
+     * TODO absolute handling configFile
+     * TODO Filename case handling for Windows?
+     * TODO digester variable subsitution $catalina.base, $catalina.home
+     */
+    protected String[] filterWatchedResources(StandardContext context,
+            String[] wresources) throws Exception {
+        File configBase = configBase(context);
+        String confContext = new File(System.getProperty("catalina.base"),
+                "conf/context.xml").getCanonicalPath();
+        String confWeb = new File(System.getProperty("catalina.base"),
+                "conf/web.xml").getCanonicalPath();
+        String confHostDefault = new File(configBase, "context.xml.default")
+                .getCanonicalPath();
+        String configFile = new File(context.getConfigFile().toURI()).getCanonicalPath();
+        String webxml = "WEB-INF/web.xml" ;
+        
+        List<String> resource = new ArrayList<>();
+        for (int i = 0; i < wresources.length; i++) {
+
+            if (wresources[i].equals(confContext))
+                continue;
+            if (wresources[i].equals(confWeb))
+                continue;
+            if (wresources[i].equals(confHostDefault))
+                continue;
+            if (wresources[i].equals(configFile))
+                continue;
+            if (wresources[i].equals(webxml))
+                continue;
+            resource.add(wresources[i]);
+        }
+        return (String[]) resource.toArray(new String[resource.size()]);
+    }
+
+}

Added: tomcat/trunk/java/org/apache/catalina/storeconfig/StandardEngineSF.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/storeconfig/StandardEngineSF.java?rev=1442161&view=auto
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/storeconfig/StandardEngineSF.java (added)
+++ tomcat/trunk/java/org/apache/catalina/storeconfig/StandardEngineSF.java Mon Feb  4 16:11:50 2013
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.catalina.storeconfig;
+
+import java.io.PrintWriter;
+
+import org.apache.catalina.Cluster;
+import org.apache.catalina.Container;
+import org.apache.catalina.Lifecycle;
+import org.apache.catalina.LifecycleListener;
+import org.apache.catalina.Realm;
+import org.apache.catalina.Valve;
+import org.apache.catalina.core.StandardEngine;
+
+/**
+ * Store server.xml Element Engine
+ */
+public class StandardEngineSF extends StoreFactoryBase {
+
+    /**
+     * Store the specified Engine properties.
+     * 
+     * @param aWriter
+     *            PrintWriter to which we are storing
+     * @param indent
+     *            Number of spaces to indent this element
+     * @param aEngine
+     *            Object whose properties are being stored
+     * 
+     * @exception Exception
+     *                if an exception occurs while storing
+     */
+    public void storeChilds(PrintWriter aWriter, int indent, Object aEngine,
+            StoreDescription parentDesc) throws Exception {
+        if (aEngine instanceof StandardEngine) {
+            StandardEngine engine = (StandardEngine) aEngine;
+            // Store nested <Listener> elements
+            if (engine instanceof Lifecycle) {
+                LifecycleListener listeners[] = ((Lifecycle) engine)
+                        .findLifecycleListeners();
+                storeElementArray(aWriter, indent, listeners);
+            }
+
+            // Store nested <Realm> element
+            Realm realm = engine.getRealm();
+            if (realm != null) {
+                Realm parentRealm = null;
+                // TODO is this case possible? (see it a old Server 5.0 impl)
+                if (engine.getParent() != null) {
+                    parentRealm = engine.getParent().getRealm();
+                }
+                if (realm != parentRealm) {
+                    storeElement(aWriter, indent, realm);
+
+                }
+            }
+
+            // Store nested <Valve> elements
+            Valve valves[] = engine.getPipeline().getValves();
+            storeElementArray(aWriter, indent, valves);
+
+            // store all <Cluster> elements
+            Cluster cluster = engine.getCluster();
+            if (cluster != null) {
+                storeElement(aWriter, indent, cluster);
+            }
+            // store all <Host> elements
+            Container children[] = engine.findChildren();
+            storeElementArray(aWriter, indent, children);
+
+       }
+    }
+}
\ No newline at end of file



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