tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject svn commit: r1401867 [1/3] - in /tomcat/sandbox/storeconfig7: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/catalina/ src/main/java/org/apache/catalina/storeconfig/ src/main/resources/ src/main/r...
Date Wed, 24 Oct 2012 20:38:59 GMT
Author: remm
Date: Wed Oct 24 20:38:57 2012
New Revision: 1401867

URL: http://svn.apache.org/viewvc?rev=1401867&view=rev
Log:
Also experiment with porting storeconfig to Tomcat 7.

Added:
    tomcat/sandbox/storeconfig7/
    tomcat/sandbox/storeconfig7/pom.xml   (with props)
    tomcat/sandbox/storeconfig7/src/
    tomcat/sandbox/storeconfig7/src/main/
    tomcat/sandbox/storeconfig7/src/main/java/
    tomcat/sandbox/storeconfig7/src/main/java/org/
    tomcat/sandbox/storeconfig7/src/main/java/org/apache/
    tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/
    tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/
    tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/CatalinaClusterSF.java
    tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/ChannelSF.java
    tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/ConnectorSF.java
    tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/ConnectorStoreAppender.java
    tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/Constants.java
    tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/GlobalNamingResourcesSF.java
    tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/IDynamicPropertyStoreAppender.java
    tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/IStoreConfig.java
    tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/IStoreFactory.java
    tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/InstanceListenerSF.java
    tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/InterceptorSF.java
    tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/LoaderSF.java
    tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/ManagerSF.java
    tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/NamingResourcesSF.java
    tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/PersistentManagerSF.java
    tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/SenderSF.java
    tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/StandardContextSF.java
    tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/StandardEngineSF.java
    tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/StandardHostSF.java
    tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/StandardServerSF.java
    tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/StandardServiceSF.java
    tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/StoreAppender.java
    tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/StoreConfig.java
    tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/StoreConfigLifecycleListener.java
    tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/StoreContextAppender.java
    tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/StoreDescription.java
    tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/StoreFactoryBase.java
    tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/StoreFactoryRule.java
    tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/StoreFileMover.java
    tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/StoreLoader.java
    tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/StoreRegistry.java
    tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/WatchedResourceSF.java
    tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/WrapperLifecycleSF.java
    tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/WrapperListenerSF.java
    tomcat/sandbox/storeconfig7/src/main/resources/
    tomcat/sandbox/storeconfig7/src/main/resources/org/
    tomcat/sandbox/storeconfig7/src/main/resources/org/apache/
    tomcat/sandbox/storeconfig7/src/main/resources/org/apache/catalina/
    tomcat/sandbox/storeconfig7/src/main/resources/org/apache/catalina/storeconfig/
    tomcat/sandbox/storeconfig7/src/main/resources/org/apache/catalina/storeconfig/LocalStrings.properties
    tomcat/sandbox/storeconfig7/src/main/resources/org/apache/catalina/storeconfig/mbeans-descriptors.xml   (with props)
    tomcat/sandbox/storeconfig7/src/main/resources/org/apache/catalina/storeconfig/server-registry.xml   (with props)

Added: tomcat/sandbox/storeconfig7/pom.xml
URL: http://svn.apache.org/viewvc/tomcat/sandbox/storeconfig7/pom.xml?rev=1401867&view=auto
==============================================================================
Binary file - no diff available.

Propchange: tomcat/sandbox/storeconfig7/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = application/xml

Added: tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/CatalinaClusterSF.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/CatalinaClusterSF.java?rev=1401867&view=auto
==============================================================================
--- tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/CatalinaClusterSF.java (added)
+++ tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/CatalinaClusterSF.java Wed Oct 24 20:38:57 2012
@@ -0,0 +1,95 @@
+/*
+ * 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.ClusterManager;
+import org.apache.catalina.tribes.Channel;
+import org.apache.catalina.tribes.ChannelReceiver;
+import org.apache.catalina.tribes.ChannelSender;
+import org.apache.catalina.tribes.ManagedChannel;
+import org.apache.catalina.tribes.MembershipService;
+import org.apache.catalina.tribes.transport.MultiPointSender;
+import org.apache.catalina.tribes.transport.ReplicationTransmitter;
+import org.apache.catalina.ha.ClusterListener;
+import org.apache.catalina.ha.tcp.SimpleTcpCluster;
+
+/**
+ * Generate Cluster Element with Membership,Sender,Receiver,Deployer and
+ * ReplicationValve
+ * 
+ * @author Peter Rossbach
+ */
+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/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/ChannelSF.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/ChannelSF.java?rev=1401867&view=auto
==============================================================================
--- tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/ChannelSF.java (added)
+++ tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/ChannelSF.java Wed Oct 24 20:38:57 2012
@@ -0,0 +1,82 @@
+/*
+ * 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.Member;
+import org.apache.catalina.tribes.MembershipService;
+import org.apache.catalina.tribes.transport.MultiPointSender;
+import org.apache.catalina.tribes.transport.ReplicationTransmitter;
+
+/**
+ * Generate Channel Element
+ * 
+ * @author Peter Rossbach
+ */
+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 interceptors = managedChannel.getInterceptors();
+                while (interceptors.hasNext()) {
+                    ChannelInterceptor interceptor = (ChannelInterceptor) interceptors.next();
+                    storeElement(aWriter, indent, interceptor);
+                }
+            }
+       }
+    }
+}
\ No newline at end of file

Added: tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/ConnectorSF.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/ConnectorSF.java?rev=1401867&view=auto
==============================================================================
--- tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/ConnectorSF.java (added)
+++ tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/ConnectorSF.java Wed Oct 24 20:38:57 2012
@@ -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.Lifecycle;
+import org.apache.catalina.LifecycleListener;
+import org.apache.catalina.connector.Connector;
+
+/**
+ * Store Connector and Listeners
+ * 
+ * @author Peter Rossbach
+ */
+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/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/ConnectorStoreAppender.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/ConnectorStoreAppender.java?rev=1401867&view=auto
==============================================================================
--- tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/ConnectorStoreAppender.java (added)
+++ tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/ConnectorStoreAppender.java Wed Oct 24 20:38:57 2012
@@ -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
+ * 
+ * @author Peter Rossbach
+ *  
+ */
+public class ConnectorStoreAppender extends StoreAppender {
+
+    protected static HashMap 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("\"");
+        }
+
+        List propertyKeys = getPropertyKeys((Connector) bean);
+        // Create blank instance
+        Object bean2 = defaultInstance(bean);
+        for (Iterator propertyIterator = propertyKeys.iterator(); propertyIterator
+                .hasNext();) {
+            String key = (String) propertyIterator.next();
+            if (replacements.get(key) != null) {
+                key = (String) replacements.get(key);
+            }
+            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);
+        }
+        String protocol = ((Connector) bean).getProtocol();
+        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 getPropertyKeys(Connector bean)
+            throws IntrospectionException {
+        ArrayList 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
+            }
+            if (!propertyKeys.contains(descriptors[i].getName())) {
+                propertyKeys.add(descriptors[i].getName());
+            }
+        }
+        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/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/Constants.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/Constants.java?rev=1401867&view=auto
==============================================================================
--- tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/Constants.java (added)
+++ tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/Constants.java Wed Oct 24 20:38:57 2012
@@ -0,0 +1,28 @@
+/*
+ * 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;
+
+/**
+ * @author Peter Rossbach
+ *  
+ */
+public class Constants {
+
+    public static final String Package = "org.apache.catalina.storeconfig";
+
+}
\ No newline at end of file

Added: tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/GlobalNamingResourcesSF.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/GlobalNamingResourcesSF.java?rev=1401867&view=auto
==============================================================================
--- tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/GlobalNamingResourcesSF.java (added)
+++ tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/GlobalNamingResourcesSF.java Wed Oct 24 20:38:57 2012
@@ -0,0 +1,78 @@
+/*
+ * 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.
+ * 
+ * @author Peter Rossbach 
+ *  
+ */
+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/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/IDynamicPropertyStoreAppender.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/IDynamicPropertyStoreAppender.java?rev=1401867&view=auto
==============================================================================
--- tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/IDynamicPropertyStoreAppender.java (added)
+++ tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/IDynamicPropertyStoreAppender.java Wed Oct 24 20:38:57 2012
@@ -0,0 +1,134 @@
+/**
+ * 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.PrintWriter;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.catalina.ha.util.IDynamicProperty;
+import org.apache.tomcat.util.IntrospectionUtils;
+
+/**
+ * Store the IDynamicProperty attributes. 
+ * 
+ * @author Peter Rossbach
+ *  
+ */
+public class IDynamicPropertyStoreAppender extends StoreAppender {
+
+    /**
+     * 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("\"");
+        }
+
+        if (bean instanceof IDynamicProperty) {
+            List propertyKeys = getPropertyKeys((IDynamicProperty) bean);
+            // Create blank instance
+            Object bean2 = defaultInstance(bean);
+            for (Iterator propertyIterator = propertyKeys.iterator(); propertyIterator
+                    .hasNext();) {
+                String key = (String) 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
+                }
+                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);
+            }
+        }
+    }
+
+    /**
+     * Get all properties from ReplicationTransmitter (also dynamic properties)
+     * 
+     * @param bean
+     * @return List of Connector Properties
+     * @throws IntrospectionException
+     */
+    protected List getPropertyKeys(IDynamicProperty bean)
+            throws IntrospectionException {
+        ArrayList propertyKeys = new ArrayList();
+        // 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
+            }
+            propertyKeys.add(descriptors[i].getName());
+        }
+        for (Iterator propertyIterator = bean.getPropertyNames(); propertyIterator
+                .hasNext();) {
+            Object key = propertyIterator.next();
+            if (propertyKeys.contains(key))
+                continue;
+            if ("className".equals(key))
+                continue;
+            propertyKeys.add(key);
+        }
+        return propertyKeys;
+    }
+
+}
\ No newline at end of file

Added: tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/IStoreConfig.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/IStoreConfig.java?rev=1401867&view=auto
==============================================================================
--- tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/IStoreConfig.java (added)
+++ tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/IStoreConfig.java Wed Oct 24 20:38:57 2012
@@ -0,0 +1,151 @@
+/*
+ * 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;
+
+/**
+ * @author Peter Rossbach 
+ *  
+ */
+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/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/IStoreFactory.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/IStoreFactory.java?rev=1401867&view=auto
==============================================================================
--- tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/IStoreFactory.java (added)
+++ tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/IStoreFactory.java Wed Oct 24 20:38:57 2012
@@ -0,0 +1,38 @@
+/*
+ * 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;
+
+/**
+ * @author Peter Rossbach 
+ *  
+ */
+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/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/InstanceListenerSF.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/InstanceListenerSF.java?rev=1401867&view=auto
==============================================================================
--- tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/InstanceListenerSF.java (added)
+++ tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/InstanceListenerSF.java Wed Oct 24 20:38:57 2012
@@ -0,0 +1,61 @@
+/*
+ * 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
+ * 
+ * @author Peter Rossbach 
+ *  
+ */
+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/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/InterceptorSF.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/InterceptorSF.java?rev=1401867&view=auto
==============================================================================
--- tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/InterceptorSF.java (added)
+++ tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/InterceptorSF.java Wed Oct 24 20:38:57 2012
@@ -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.ChannelInterceptor;
+import org.apache.catalina.tribes.transport.MultiPointSender;
+import org.apache.catalina.tribes.transport.ReplicationTransmitter;
+
+/**
+ * Generate Interceptor Element
+ * 
+ * @author Peter Rossbach
+ */
+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/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/LoaderSF.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/LoaderSF.java?rev=1401867&view=auto
==============================================================================
--- tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/LoaderSF.java (added)
+++ tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/LoaderSF.java Wed Oct 24 20:38:57 2012
@@ -0,0 +1,85 @@
+/*
+ * 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.
+ * 
+ * @author Peter Rossbach
+ */
+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/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/ManagerSF.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/ManagerSF.java?rev=1401867&view=auto
==============================================================================
--- tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/ManagerSF.java (added)
+++ tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/ManagerSF.java Wed Oct 24 20:38:57 2012
@@ -0,0 +1,82 @@
+/*
+ * 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
+ * 
+ * @author Peter Rossbach
+ */
+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/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/NamingResourcesSF.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/NamingResourcesSF.java?rev=1401867&view=auto
==============================================================================
--- tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/NamingResourcesSF.java (added)
+++ tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/NamingResourcesSF.java Wed Oct 24 20:38:57 2012
@@ -0,0 +1,108 @@
+/*
+ * 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
+ * 
+ * @author Peter Rossbach
+ *  
+ */
+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/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/PersistentManagerSF.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/PersistentManagerSF.java?rev=1401867&view=auto
==============================================================================
--- tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/PersistentManagerSF.java (added)
+++ tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/PersistentManagerSF.java Wed Oct 24 20:38:57 2012
@@ -0,0 +1,57 @@
+/*
+ * 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"
+ * 
+ * @author Peter Rossbach
+ */
+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/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/SenderSF.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/SenderSF.java?rev=1401867&view=auto
==============================================================================
--- tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/SenderSF.java (added)
+++ tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/SenderSF.java Wed Oct 24 20:38:57 2012
@@ -0,0 +1,56 @@
+/*
+ * 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
+ * 
+ * @author Peter Rossbach
+ */
+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/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/StandardContextSF.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/StandardContextSF.java?rev=1401867&view=auto
==============================================================================
--- tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/StandardContextSF.java (added)
+++ tomcat/sandbox/storeconfig7/src/main/java/org/apache/catalina/storeconfig/StandardContextSF.java Wed Oct 24 20:38:57 2012
@@ -0,0 +1,380 @@
+/*
+ * 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 javax.naming.directory.DirContext;
+
+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.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;
+import org.apache.naming.resources.ProxyDirContext;
+
+/**
+ * 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>
+ * 
+ * @author Peter Rossbach
+ */
+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 = mover.getWriter();
+            try {
+                storeXMLHead(writer);
+                super.store(writer, -2, aContext);
+            } finally {
+                // 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
+            DirContext resources = context.getResources();
+            if (resources instanceof ProxyDirContext)
+                resources = ((ProxyDirContext) resources).getDirContext();
+            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 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()]);
+    }
+
+}



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


Mime
View raw message