[maven-release-plugin] copy for tag cocoon-spring-configurator-2.1.0
git-svn-id: https://svn.apache.org/repos/asf/cocoon/tags/cocoon-configuration@761910 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/LICENSE.txt b/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/LICENSE.txt
new file mode 100644
index 0000000..261eeb9
--- /dev/null
+++ b/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/LICENSE.txt
@@ -0,0 +1,201 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed 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.
diff --git a/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/NOTICE.txt b/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/NOTICE.txt
new file mode 100644
index 0000000..bb0f11b
--- /dev/null
+++ b/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/NOTICE.txt
@@ -0,0 +1,5 @@
+Apache Cocoon
+Copyright 1999-2008 The Apache Software Foundation.
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
diff --git a/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/pom.xml b/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/pom.xml
new file mode 100644
index 0000000..9e944fb
--- /dev/null
+++ b/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/pom.xml
@@ -0,0 +1,146 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<!-- $Id$ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+ <packaging>jar</packaging>
+
+ <parent>
+ <artifactId>cocoon</artifactId>
+ <groupId>org.apache.cocoon</groupId>
+ <version>8</version>
+ <relativePath>../../../parent</relativePath>
+ </parent>
+ <artifactId>cocoon-spring-configurator</artifactId>
+ <version>2.1.0</version>
+ <name>Cocoon Spring Configurator</name>
+ <description>
+ The Cocoon Spring Configurator is an extension for the Spring framework.
+ It provides a standardized way of handling various configuration issues when using Spring.
+ The feature list includes automatic property handling and inclusion of configuration files.
+ </description>
+
+ <distributionManagement>
+ <site>
+ <id>website</id>
+ <url>${docs.deploymentBaseUrl}/${docs.m.spring-configurator.relPath}/</url>
+ </site>
+ </distributionManagement>
+
+ <properties>
+ <docs.name>Cocoon Spring Configurator</docs.name>
+ <docs.version>${docs.m.spring-configurator.version}</docs.version>
+ <docs.urlRelativizer>../../../../../</docs.urlRelativizer>
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-release-plugin</artifactId>
+ <configuration>
+ <tagBase>https://svn.apache.org/repos/asf/cocoon/tags/cocoon-configuration/${project.artifactId}</tagBase>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.cocoon</groupId>
+ <artifactId>cocoon-configuration-api</artifactId>
+ <version>1.0.2</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <exclusions>
+ <exclusion>
+ <artifactId>logkit</artifactId>
+ <groupId>logkit</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>avalon-framework</artifactId>
+ <groupId>avalon-framework</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-beans</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-aop</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-web</artifactId>
+ </dependency>
+ </dependencies>
+
+ <scm>
+ <connection>scm:svn:https://svn.apache.org/repos/asf/cocoon/tags/cocoon-configuration/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0</connection>
+ <developerConnection>scm:svn:https://svn.apache.org/repos/asf/cocoon/tags/cocoon-configuration/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0</developerConnection>
+ <url>https://svn.apache.org/repos/asf/cocoon/tags/cocoon-configuration/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0</url>
+ </scm>
+
+ <profiles>
+ <profile>
+ <id>daisy</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.daisycms</groupId>
+ <artifactId>daisy-maven-plugin</artifactId>
+ <configuration>
+ <navDocId>1305</navDocId>
+ <collection>cdocs-spring-configurator</collection>
+ <skipFirstNavigationDocumentLevel>false</skipFirstNavigationDocumentLevel>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+</project>
diff --git a/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/changes/changes.xml b/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/changes/changes.xml
new file mode 100644
index 0000000..76fc78e
--- /dev/null
+++ b/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/changes/changes.xml
@@ -0,0 +1,107 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+
+<!--
+ - @see http://maven.apache.org/plugins/maven-changes-plugin/usage.html
+ - @version $Id$
+ -->
+<document>
+ <body>
+ <release version="2.1.0" date="2009-??-??" description="unreleased">
+ <action dev="reinhard" type="add">
+ Add a WildcardBeanMap that extends BeanMap but checks for a wildcard expression
+ instead of the bean type.
+ </action>
+ <action dev="reinhard" type="add">
+ Support the definition of a user properties file as servlet context init parameter
+ (org.apache.cocoon.settings).
+ </action>
+ </release>
+ <release version="2.0.0" date="2008-08-09" description="released">
+ <action dev="gkossakowski" type="update">
+ Java 5 as minimum requirement.
+ </action>
+ <action dev="reinhard" type="fix">
+ Remove Block-Deployment functionality into a separate module.
+ </action>
+ <action dev="gkossakowski" type="add">
+ Introduced resource filter feature as explained here: http://article.gmane.org/gmane.text.xml.cocoon.devel/78158
+ The resource filtering is used for *all* resources being processed by
+ Spring Configurator including beans definitions and property files.
+
+ The resource filter itself is a simple class implementing one method of
+ ResourceFilter interface.
+ </action>
+ <action dev="lgawron" type="fix">
+ Fix configurator:bean-map throwing ClassCastException when
+ key-property="propertyName" did not resolve to a String property.
+ </action>
+ </release>
+
+ <release version="1.0.2" date="2008-04-07" description="released">
+ <action dev="reinhard" type="fix" issue="COCOON-2172" due-to="Juan Jose Vazquez Delgado" due-to-email="jvazquez@apache.org">
+ Fix block deployment for Weblogic 9.2.
+ </action>
+ <action dev="vgritsenko" type="fix">
+ SettingsBeanFactoryPostProcessor creates work and cache directories only
+ after properties are loaded and settings object is populated, and
+ not before that.
+ </action>
+ </release>
+
+ <release version="1.0.1" date="2007-09-20" description="released">
+ <action dev="giacomo" type="add">
+ Added ability to the bean-map handler to specify what properties a bean must have
+ to be considered as a candidate for the constructed Map as well as keying the Map
+ with a property value from the bean itself instead of its bean-id.
+ </action>
+ <action dev="cziegeler" type="fix">
+ SettingsBeanFactoryPostProcessor can be used outside of a servlet context.
+ </action>
+ </release>
+
+ <release version="1.0.0" date="2007-02-22" description="released">
+ <action dev="reinhard" type="fix">
+ WebAppContextUtils stored a Spring parent application context in a static field. This
+ made it impossible to reload the context. The static field was removed and a request
+ for the parent context results in
+ WebApplicationContextUtils.getRequiredWebApplicationContext(ServletContext)
+ which returns the parent Spring application context stored in the servlet context.
+ </action>
+ <action dev="cziegeler" type="add">
+ Each property reference can have an optional default value, like
+ ${my.property.net:THE DEFAULT}. If no other definition for this
+ property is found, the default is used.
+ </action>
+ <action dev="cziegeler" type="add">
+ Add a bean map that collects all beans from the Spring context
+ conforming to a specified type.
+ </action>
+ <action dev="cziegeler" type="add">
+ Improved the DefaultBlockResourcesHolder to act like a PropertyPlaceholderConfigurer.
+ This allows access to the path of the deployed blocks in the configuration files
+ through properties like ${org.apache.cocoon.blocks.[BLOCK_NAME].resources}.
+ </action>
+ <action dev="cziegeler" type="add">
+ Initial creation.
+ </action>
+ </release>
+ </body>
+</document>
diff --git a/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/java/org/apache/cocoon/spring/configurator/ResourceFilter.java b/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/java/org/apache/cocoon/spring/configurator/ResourceFilter.java
new file mode 100644
index 0000000..0f6c65b
--- /dev/null
+++ b/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/java/org/apache/cocoon/spring/configurator/ResourceFilter.java
@@ -0,0 +1,47 @@
+/*
+ * 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.cocoon.spring.configurator;
+
+import java.util.Set;
+
+import org.springframework.core.io.Resource;
+
+/**
+ * <p>This is an interface for custom implementations of filtering of resources being
+ * processed by Spring Configurator.</p>
+ *
+ * <p>If you want to make some decisions on which resources you want to include at the runtime
+ * then you should implement this interface and configure it following way:</p>
+ * <pre>
+ * <configurator:settings>
+ * ..
+ * <configurator:filter class="org.package.SomeClass"/>
+ * </configurator:settings>
+ * </pre>
+ *
+ * <p>The implementations of this interface should be stateless</p>
+ *
+ */
+public interface ResourceFilter {
+
+ /**
+ * @param resources The set of {@link Resource Spring resources}
+ * @return
+ */
+ Set filter(Set resources);
+
+}
diff --git a/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/java/org/apache/cocoon/spring/configurator/ResourceUtils.java b/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/java/org/apache/cocoon/spring/configurator/ResourceUtils.java
new file mode 100644
index 0000000..7f7c0e2
--- /dev/null
+++ b/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/java/org/apache/cocoon/spring/configurator/ResourceUtils.java
@@ -0,0 +1,242 @@
+/*
+ * 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.cocoon.spring.configurator;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.HashSet;
+import java.util.Properties;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.springframework.core.io.Resource;
+import org.springframework.core.io.ResourceLoader;
+import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
+import org.springframework.core.io.support.ResourcePatternResolver;
+
+/**
+ * Utility class for Spring resource handling.
+ *
+ * @since 1.0
+ * @version $Id$
+ */
+public abstract class ResourceUtils {
+
+ /**
+ * Get the uri of a resource. This method corrects the uri in the case of
+ * the file protocol on windows.
+ *
+ * @param resource The resource.
+ * @return The uri.
+ * @throws IOException
+ */
+ public static String getUri(Resource resource) throws IOException {
+ if (resource == null) {
+ return null;
+ }
+ return correctUri(resource.getURL().toExternalForm());
+ }
+
+ protected static String correctUri(String uri) {
+ // if it is a file we have to recreate the url,
+ // otherwise we get problems under windows with some file
+ // references starting with "/DRIVELETTER" and some
+ // just with "DRIVELETTER"
+ if (uri.startsWith("file:")) {
+ final File f = new File(uri.substring(5));
+ return "file://" + f.getAbsolutePath();
+ }
+
+ return uri;
+ }
+
+ public static boolean isClasspathUri(String uri) {
+ return uri.startsWith(ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX) ||
+ uri.startsWith(ResourceLoader.CLASSPATH_URL_PREFIX);
+ }
+
+ /**
+ * Read all property files from the given directory and apply them to the
+ * supplied properties.
+ * @param propertiesPath The directory path.
+ * @param properties The properties object where all the read properties are applied to.
+ * @param resourceLoader The resource loader to load the property files.
+ * @param resourceFilter The resource filter used to filter read property files, if null no filtering is being applied.
+ * @param logger Optional logger for debugging.
+ */
+ public static void readProperties(String propertiesPath,
+ Properties properties,
+ ResourceLoader resourceLoader,
+ ResourceFilter resourceFilter,
+ Log logger) {
+ if (logger != null && logger.isDebugEnabled()) {
+ logger.debug("Reading properties from directory: " + propertiesPath);
+ }
+
+ ResourcePatternResolver resolver;
+ if (resourceLoader instanceof ResourcePatternResolver) {
+ resolver = (ResourcePatternResolver) resourceLoader;
+ } else {
+ resolver = new PathMatchingResourcePatternResolver(resourceLoader);
+ }
+
+ Resource[] resources = null;
+
+ // check if directory exists
+ boolean load = true;
+ if (!ResourceUtils.isClasspathUri(propertiesPath)) {
+ final Resource resource = resolver.getResource(propertiesPath);
+ if (!resource.exists()) {
+ load = false;
+ }
+ }
+ if (load) {
+ try {
+ resources = resolver.getResources(propertiesPath + "/*.properties");
+ resources = filterResources(resources, resourceFilter);
+ if (logger != null && logger.isDebugEnabled())
+ logger.debug("Found " + resources.length + " matching resources in " +
+ propertiesPath + "/*.properties");
+ } catch (IOException ignore) {
+ if (logger != null && logger.isDebugEnabled()) {
+ logger.debug("Unable to read properties from directory '" +
+ propertiesPath + "' - Continuing initialization.", ignore);
+ }
+ }
+ }
+
+ if (resources != null) {
+ // we process the resources in alphabetical order, so we put
+ // them first into a list, sort them and then read the properties.
+ Arrays.sort(resources, getResourceComparator());
+
+ // now process
+ for (int i = 0; i < resources.length; i++) {
+ final Resource src = resources[i];
+ try {
+ if (logger != null && logger.isDebugEnabled()) {
+ logger.debug("Reading settings from '" + src.getURL() + "'.");
+ }
+ final InputStream propsIS = src.getInputStream();
+ properties.load(propsIS);
+ propsIS.close();
+ } catch (IOException ignore) {
+ if (logger != null && logger.isDebugEnabled()) {
+ logger.info("Unable to read properties from file '" + src.getDescription() +
+ "' - Continuing initialization.", ignore);
+ }
+ }
+ }
+ } else {
+ if (logger != null && logger.isDebugEnabled()) {
+ logger.debug("Directory '" + propertiesPath + "' does not exist - Continuing initialization.");
+ }
+ }
+ }
+
+ /**
+ * Return a resource comparator.
+ * This comparator compares the file name of two resources.
+ * In addition all resources contained in a directory named
+ * WEB-INF/classes/cocoon are sorted (in alphabetical) order
+ * after all other files.
+ *
+ * @return A new comparator for resources.
+ */
+ public static Comparator getResourceComparator() {
+ return new ResourceComparator();
+ }
+
+ /**
+ * Class implementing a simple resource comparator as described
+ * here: {@link ResourceUtils#getResourceComparator}.
+ */
+ protected final static class ResourceComparator implements Comparator {
+
+ protected static final String WEB_INF_CLASSES_META_INF_COCOON = "/WEB-INF/classes/META-INF/cocoon/";
+
+ /**
+ * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
+ */
+ public int compare(Object o1, Object o2) {
+ if (!(o1 instanceof Resource) || !(o2 instanceof Resource)) {
+ return 0;
+ }
+
+ try {
+ String name1 = ((Resource) o1).getURL().toExternalForm();
+ String name2 = ((Resource) o2).getURL().toExternalForm();
+ // replace '\' with '/'
+ name1 = name1.replace('\\', '/');
+ name2 = name2.replace('\\', '/');
+
+ boolean webInfClasses1 = name1.indexOf(ResourceComparator.WEB_INF_CLASSES_META_INF_COCOON) != -1;
+ boolean webInfClasses2 = name2.indexOf(ResourceComparator.WEB_INF_CLASSES_META_INF_COCOON) != -1;
+ if (!webInfClasses1 && webInfClasses2) {
+ return -1;
+ }
+ if (webInfClasses1 && !webInfClasses2) {
+ return +1;
+ }
+ } catch (IOException io) {
+ // ignore
+ }
+
+ // default behaviour:
+ return ((Resource) o1).getFilename().compareTo(((Resource) o2).getFilename());
+ }
+ }
+
+ /**
+ * Return the properties added by Maven.
+ *
+ * @param groupId The group identifier of the artifact.
+ * @param artifactId The artifact identifier.
+ * @return Returns a properties object or null if the properties can't be found/read.
+ */
+ public static Properties getPOMProperties(String groupId, String artifactId) {
+ final String resourceName = "META-INF/maven/" + groupId + "/" + artifactId + "/pom.properties";
+ try {
+ final Properties p = new Properties();
+ final InputStream resourceAsStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(resourceName);
+ if (resourceAsStream == null)
+ return null;
+ p.load(resourceAsStream);
+ return p;
+ } catch (IOException ignore) {
+ return null;
+ }
+ }
+
+ /**
+ * @param resources The array of resources need to be filtered
+ * @param filter The instance of the filter itself
+ * @return the array of resources that has been filtered
+ */
+ public static Resource[] filterResources(Resource[] resources, ResourceFilter filter) {
+ if (filter == null)
+ return resources;
+
+ Set resourcesSet = new HashSet(Arrays.asList(resources));
+ Set filteredResources = filter.filter(resourcesSet);
+ return (Resource[])(new ArrayList(filteredResources)).toArray(new Resource[0]);
+ }
+}
diff --git a/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/java/org/apache/cocoon/spring/configurator/WebAppContextUtils.java b/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/java/org/apache/cocoon/spring/configurator/WebAppContextUtils.java
new file mode 100644
index 0000000..623ca3a
--- /dev/null
+++ b/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/java/org/apache/cocoon/spring/configurator/WebAppContextUtils.java
@@ -0,0 +1,123 @@
+/*
+ * 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.cocoon.spring.configurator;
+
+import org.springframework.web.context.WebApplicationContext;
+import org.springframework.web.context.request.RequestAttributes;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.support.WebApplicationContextUtils;
+
+import org.apache.cocoon.spring.configurator.impl.ServletContextFactoryBean;
+
+/**
+ * Utility class to manage hierarchical application contexts.
+ *
+ * @version $Id$
+ * @since 1.0
+ */
+public abstract class WebAppContextUtils {
+
+ /** The name of the request attribute containing the current bean factory. */
+ public static final String CONTAINER_REQUEST_ATTRIBUTE = WebAppContextUtils.class.getName();
+
+ /**
+ * Get the current web application context.
+ *
+ * @throws IllegalStateException if no WebApplicationContext could not be found
+ * @return The current web application context.
+ */
+ public static WebApplicationContext getCurrentWebApplicationContext() {
+ final RequestAttributes attributes = RequestContextHolder.getRequestAttributes();
+ return getCurrentWebApplicationContext(attributes);
+ }
+
+ /**
+ * Return the current web application context or if the attributes are null, the parent context.
+ *
+ * @param attributes The request attributes.
+ * @throws IllegalStateException if no WebApplicationContext could not be found
+ * @return The web application context.
+ */
+ protected static WebApplicationContext getCurrentWebApplicationContext(RequestAttributes attributes) {
+ if (attributes != null) {
+ Object obj = attributes.getAttribute(CONTAINER_REQUEST_ATTRIBUTE, RequestAttributes.SCOPE_REQUEST);
+ if (obj != null) {
+ return (WebApplicationContext) obj;
+ }
+ }
+
+ // return the root context
+ return WebApplicationContextUtils.getRequiredWebApplicationContext(ServletContextFactoryBean.getServletContext());
+ }
+
+ /**
+ * Notify about entering this context.
+ *
+ * @param webAppContext The current web application context.
+ * @return A handle which should be passed to {@link #leavingContext(WebApplicationContext, Object)}.
+ */
+ public static Object enteringContext(WebApplicationContext webAppContext) {
+ // get request attributes
+ final RequestAttributes attributes = RequestContextHolder.currentRequestAttributes();
+
+ // save current class loader and web application context
+ final ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
+ final WebApplicationContext oldContext = (WebApplicationContext) attributes.getAttribute(CONTAINER_REQUEST_ATTRIBUTE, RequestAttributes.SCOPE_REQUEST);
+
+ // set new class loader and context
+ attributes.setAttribute(CONTAINER_REQUEST_ATTRIBUTE, webAppContext, RequestAttributes.SCOPE_REQUEST);
+ Thread.currentThread().setContextClassLoader(webAppContext.getClassLoader());
+
+ return new ContextInfo(oldContext, oldClassLoader);
+ }
+
+ /**
+ * Notify about leaving this context.
+ * @param webAppContext The current web application context.
+ * @param handle The returned handle from {@link #enteringContext(WebApplicationContext)}.
+ */
+ public static void leavingContext(WebApplicationContext webAppContext, Object handle) {
+ if (!(handle instanceof ContextInfo)) {
+ throw new IllegalArgumentException("Handle must be an instance of ContextInfo and not " + handle);
+ }
+ final ContextInfo info = (ContextInfo) handle;
+
+ // get request attributes
+ final RequestAttributes attributes = RequestContextHolder.currentRequestAttributes();
+
+ // restore class loader and previous web application context
+ Thread.currentThread().setContextClassLoader(info.classLoader);
+ if (info.webAppContext == null) {
+ attributes.removeAttribute(CONTAINER_REQUEST_ATTRIBUTE, RequestAttributes.SCOPE_REQUEST);
+ } else {
+ attributes.setAttribute(CONTAINER_REQUEST_ATTRIBUTE, info.webAppContext, RequestAttributes.SCOPE_REQUEST);
+ }
+ }
+
+ /**
+ * Private bean keeping track of the class loader and web application context.
+ */
+ protected static final class ContextInfo {
+ public final ClassLoader classLoader;
+ public final WebApplicationContext webAppContext;
+
+ public ContextInfo(WebApplicationContext w, ClassLoader c) {
+ this.classLoader = c;
+ this.webAppContext = w;
+ }
+ }
+}
diff --git a/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/java/org/apache/cocoon/spring/configurator/impl/AbstractElementParser.java b/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/java/org/apache/cocoon/spring/configurator/impl/AbstractElementParser.java
new file mode 100644
index 0000000..c4ce417
--- /dev/null
+++ b/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/java/org/apache/cocoon/spring/configurator/impl/AbstractElementParser.java
@@ -0,0 +1,226 @@
+/*
+ * 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.cocoon.spring.configurator.impl;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.config.BeanDefinitionHolder;
+import org.springframework.beans.factory.config.RuntimeBeanReference;
+import org.springframework.beans.factory.support.BeanDefinitionReaderUtils;
+import org.springframework.beans.factory.support.BeanDefinitionRegistry;
+import org.springframework.beans.factory.support.RootBeanDefinition;
+import org.springframework.beans.factory.xml.BeanDefinitionParser;
+import org.springframework.beans.factory.xml.BeanDefinitionParserDelegate;
+import org.springframework.util.StringUtils;
+
+import org.apache.cocoon.configuration.Settings;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * This is a base class for all bean definition parsers used in Cocoon. It
+ * provides some utility methods.
+ *
+ * @since 1.0
+ * @version $Id$
+ */
+public abstract class AbstractElementParser implements BeanDefinitionParser {
+
+ /** Logger (we use the same logging mechanism as Spring!) */
+ protected final Log logger = LogFactory.getLog(getClass());
+
+ /**
+ * Get the value of an attribute or if the attribute is not present return
+ * the default value. As Element#getAttribute(String) returns an empty string
+ * and not null, we have to check this.
+ */
+ protected String getAttributeValue(Element element, String attributeName, String defaultValue) {
+ String value = element.getAttribute(attributeName);
+ if (value == null || value.trim().length() == 0) {
+ value = defaultValue;
+ }
+
+ return value;
+ }
+
+ /**
+ * Returns all Element children of an Element that have the given local name.
+ */
+ protected Element[] getChildElements(Element element, String localName) {
+ final ArrayList elements = new ArrayList();
+ final NodeList nodeList = element.getChildNodes();
+ for (int i = 0; i < nodeList.getLength(); i++) {
+ final Node node = nodeList.item(i);
+ if (node instanceof Element && localName.equals(node.getLocalName())) {
+ elements.add(node);
+ }
+ }
+
+ return (Element[]) elements.toArray(new Element[elements.size()]);
+ }
+
+ /**
+ * Register a bean definition.
+ *
+ * @param beanDef The bean definition.
+ * @param beanName The name of the bean.
+ * @param registry The registry.
+ */
+ protected void register(BeanDefinition beanDef, String beanName, BeanDefinitionRegistry registry) {
+ register(beanDef, beanName, null, registry);
+ }
+
+ /**
+ * Register a bean definition.
+ *
+ * @param beanDef The bean definition.
+ * @param beanName The name of the bean.
+ * @param alias Optional alias.
+ * @param registry The registry.
+ */
+ protected void register(BeanDefinition beanDef, String beanName, String alias, BeanDefinitionRegistry registry) {
+ if (this.logger.isDebugEnabled()) {
+ this.logger.debug("Registering bean with name " + beanName +
+ (alias != null ? " (alias=" + alias + ") " : " ") + beanDef);
+ }
+ final BeanDefinitionHolder holder;
+ if (alias != null) {
+ holder = new BeanDefinitionHolder(beanDef, beanName, new String[] { alias });
+ } else {
+ holder = new BeanDefinitionHolder(beanDef, beanName);
+ }
+
+ BeanDefinitionReaderUtils.registerBeanDefinition(holder, registry);
+ }
+
+ /**
+ * Register a global bean definition.
+ * The provided xml element is searched for an id and/or name attribute to register
+ * the bean. This implementation works the same as the default spring implementation.
+ *
+ * @param beanDef The bean definition.
+ * @param element The xml element defining the bean.
+ * @param registry The registry.
+ * @since 1.0.1
+ */
+ protected void register(BeanDefinition beanDef, Element element, BeanDefinitionRegistry registry) {
+ String id = element.getAttribute(BeanDefinitionParserDelegate.ID_ATTRIBUTE);
+ String nameAttr = element.getAttribute(BeanDefinitionParserDelegate.NAME_ATTRIBUTE);
+
+ final List aliases = new ArrayList();
+ if (StringUtils.hasLength(nameAttr)) {
+ String[] nameArr = StringUtils.tokenizeToStringArray(nameAttr, BeanDefinitionParserDelegate.BEAN_NAME_DELIMITERS);
+ aliases.addAll(Arrays.asList(nameArr));
+ }
+
+ String beanName = id;
+ if (!StringUtils.hasText(beanName) && !aliases.isEmpty()) {
+ beanName = (String) aliases.remove(0);
+ if (this.logger.isDebugEnabled()) {
+ this.logger.debug("No XML 'id' specified - using '" + beanName +
+ "' as bean name and " + aliases + " as aliases");
+ }
+ }
+
+ final BeanDefinitionHolder holder = new BeanDefinitionHolder(beanDef, beanName, StringUtils.toStringArray(aliases));
+ BeanDefinitionReaderUtils.registerBeanDefinition(holder, registry);
+ }
+
+ /**
+ * Helper method to create a new bean definition.
+ *
+ * @param componentClass The class of the implementation.
+ * @param initMethod Optional initialization method.
+ * @param requiresSettings If set to true, this bean has a property "settings" for the
+ * settings object.
+ * @return A new root bean definition.
+ */
+ protected RootBeanDefinition createBeanDefinition(Class componentClass, String initMethod, boolean requiresSettings) {
+ final RootBeanDefinition beanDef = new RootBeanDefinition();
+ beanDef.setBeanClass(componentClass);
+ fillBeanDefinition(beanDef, initMethod, requiresSettings);
+ return beanDef;
+ }
+
+ /**
+ * Helper method to create a new bean definition.
+ *
+ * @param componentClass The class of the implementation.
+ * @param initMethod Optional initialization method.
+ * @param requiresSettings If set to true, this bean has a property "settings" for the
+ * settings object.
+ * @return A new root bean definition.
+ */
+ protected RootBeanDefinition createBeanDefinition(String componentClass, String initMethod, boolean requiresSettings) {
+ final RootBeanDefinition beanDef = new RootBeanDefinition();
+ beanDef.setBeanClassName(componentClass);
+ fillBeanDefinition(beanDef, initMethod, requiresSettings);
+ return beanDef;
+ }
+
+ private void fillBeanDefinition(RootBeanDefinition beanDef, String initMethod, boolean requiresSettings) {
+ beanDef.setScope(BeanDefinition.SCOPE_SINGLETON);
+ beanDef.setLazyInit(false);
+ if (initMethod != null) {
+ beanDef.setInitMethodName(initMethod);
+ }
+ if (requiresSettings) {
+ beanDef.getPropertyValues().addPropertyValue("settings", new RuntimeBeanReference(Settings.ROLE));
+ }
+ }
+
+ /**
+ * Add a new bean definition to the registry.
+ *
+ * @param componentClass The class of the implementation.
+ * @param beanName The name of the bean.
+ * @param initMethod Optional initialization method.
+ * @param requiresSettings If set to true, this bean has a property "settings" for the
+ * settings object.
+ * @param registry The bean registry.
+ */
+ protected void addComponent(Class componentClass, String beanName,
+ String initMethod, boolean requiresSettings,
+ BeanDefinitionRegistry registry) {
+ final RootBeanDefinition beanDef = createBeanDefinition(componentClass, initMethod, requiresSettings);
+ register(beanDef, beanName, registry);
+ }
+
+ /**
+ * Add a new bean definition to the registry.
+ *
+ * @param componentClass The class of the implementation.
+ * @param beanName The name of the bean.
+ * @param initMethod Optional initialization method.
+ * @param requiresSettings If set to true, this bean has a property "settings" for the
+ * settings object.
+ * @param registry The bean registry.
+ */
+ protected void addComponent(String componentClass, String beanName,
+ String initMethod, boolean requiresSettings,
+ BeanDefinitionRegistry registry) {
+ final RootBeanDefinition beanDef = createBeanDefinition(componentClass, initMethod, requiresSettings);
+ register(beanDef, beanName, registry);
+ }
+}
diff --git a/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/java/org/apache/cocoon/spring/configurator/impl/AbstractSettingsBeanFactoryPostProcessor.java b/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/java/org/apache/cocoon/spring/configurator/impl/AbstractSettingsBeanFactoryPostProcessor.java
new file mode 100644
index 0000000..9ff375f
--- /dev/null
+++ b/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/java/org/apache/cocoon/spring/configurator/impl/AbstractSettingsBeanFactoryPostProcessor.java
@@ -0,0 +1,365 @@
+/*
+ * 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.cocoon.spring.configurator.impl;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+
+import javax.servlet.ServletContext;
+
+import org.apache.cocoon.configuration.MutableSettings;
+import org.apache.cocoon.configuration.PropertyHelper;
+import org.apache.cocoon.configuration.PropertyProvider;
+import org.apache.cocoon.configuration.Settings;
+import org.apache.cocoon.spring.configurator.ResourceFilter;
+import org.apache.cocoon.spring.configurator.ResourceUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.BeanDefinitionStoreException;
+import org.springframework.beans.factory.BeanFactory;
+import org.springframework.beans.factory.FactoryBean;
+import org.springframework.beans.factory.HierarchicalBeanFactory;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.config.BeanDefinitionVisitor;
+import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
+import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
+import org.springframework.context.ResourceLoaderAware;
+import org.springframework.core.io.FileSystemResourceLoader;
+import org.springframework.core.io.ResourceLoader;
+import org.springframework.web.context.ServletContextAware;
+import org.springframework.web.context.support.ServletContextResourceLoader;
+
+/**
+ * This is a bean factory post processor which handles all the settings stuff
+ * for Cocoon. It reads in all properties files and replaces references to
+ * them in the spring configuration files.
+ * In addition this bean acts as a factory bean providing the settings object.
+ *
+ * @see SettingsBeanFactoryPostProcessor
+ * @see ChildSettingsBeanFactoryPostProcessor
+ * @since 1.0
+ * @version $Id$
+ */
+public abstract class AbstractSettingsBeanFactoryPostProcessor
+ extends PropertyPlaceholderConfigurer
+ implements ServletContextAware, ResourceLoaderAware, FactoryBean {
+
+ /** Logger (we use the same logging mechanism as Spring!) */
+ protected final Log logger = LogFactory.getLog(getClass());
+
+ protected ServletContext servletContext;
+
+ protected MutableSettings settings;
+
+ protected BeanFactory beanFactory;
+
+ protected ResourceLoader resourceLoader;
+
+ protected ResourceFilter resourceFilter;
+
+ /**
+ * Additional properties.
+ */
+ protected Properties additionalProperties;
+
+ /**
+ * List of additional property directories.
+ */
+ protected List directories;
+
+ /**
+ * @see org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#setBeanFactory(org.springframework.beans.factory.BeanFactory)
+ */
+ public void setBeanFactory(BeanFactory factory) {
+ super.setBeanFactory(factory);
+ this.beanFactory = factory;
+ }
+
+ /**
+ * @see org.springframework.web.context.ServletContextAware#setServletContext(javax.servlet.ServletContext)
+ */
+ public void setServletContext(ServletContext sContext) {
+ this.servletContext = sContext;
+ }
+
+ /**
+ * @see org.springframework.context.ResourceLoaderAware#setResourceLoader(org.springframework.core.io.ResourceLoader)
+ */
+ public void setResourceLoader(ResourceLoader loader) {
+ this.resourceLoader = loader;
+ }
+
+ public void setResourceFilter(ResourceFilter resourceFilter) {
+ this.resourceFilter = resourceFilter;
+ }
+
+ public void setDirectories(List directories) {
+ this.directories = directories;
+ }
+
+ public void setAdditionalProperties(Properties props) {
+ this.additionalProperties = props;
+ }
+
+ /**
+ * Initialize this processor.
+ * Setup the settings object.
+ *
+ * @throws Exception
+ */
+ public void init()
+ throws Exception {
+ settings = createSettings();
+ dumpSettings();
+ }
+
+ /**
+ * Get the running mode.
+ * This method should be implemented by subclasses.
+ */
+ protected abstract String getRunningMode();
+
+ /**
+ * Return a parent settings object if available.
+ */
+ protected Settings getParentSettings() {
+ final BeanFactory parentBeanFactory = ((HierarchicalBeanFactory) this.beanFactory).getParentBeanFactory();
+ if (parentBeanFactory != null) {
+ return (Settings) parentBeanFactory.getBean(Settings.ROLE);
+ }
+
+ return null;
+ }
+
+ /**
+ * Create a new settings object.
+ * If a parent settings object is available a new child settings object is created.
+ * Otherwise a new root settings object with the running mode is instantiated.
+ */
+ protected MutableSettings createMutableSettingsInstance() {
+ final Settings parentSettings = getParentSettings();
+ if (parentSettings == null) {
+ return new MutableSettings(getRunningMode());
+ }
+
+ return new MutableSettings(parentSettings);
+ }
+
+ /**
+ * This method can be used by subclasses to initialize the settings and/or
+ * the properties before {@link #createSettings()} does it's work.
+ */
+ protected void preInit(final MutableSettings s, final Properties properties) {
+ // default implementation does nothing
+ }
+
+ /**
+ * This method can be used by subclasses to initialize the settings and/or
+ * the properties after {@link #createSettings()} did it's work.
+ */
+ protected void postInit(final MutableSettings s, final Properties properties) {
+ // default implementation does nothing
+ }
+
+ protected String getNameForPropertyProvider() {
+ return null;
+ }
+
+ /**
+ * Create a settings object.
+ * This method creates the settings by executing the following task:
+ * <ol>
+ * <li>Create a new mutable settings object invoking {@link #createMutableSettingsInstance()}.
+ * <li>Configure the properties and settings object by calling {@link #preInit(MutableSettings, Properties)}.
+ * <li>Invoke a {@link PropertyProvider} if configured in the same application context (or its parent)
+ * <li>Add properties from configured directories {@link #directories}.
+ * <li>Add additional properties configured at {@link #additionalProperties}
+ * <li>Apply system properties
+ * <li>Configure the properties and settings object by calling {@link #postInit(MutableSettings, Properties)}.
+ * <li>Replace references in properties
+ * <li>Configure the settings object with the properties
+ * <li>Make the settings object read-only.
+ * </ol>
+ *
+ * @return A new Settings object
+ */
+ protected MutableSettings createSettings() {
+ final String mode = getRunningMode();
+ // create an empty settings objects
+ final MutableSettings s = createMutableSettingsInstance();
+ // create the initial properties
+ final Properties properties = new Properties();
+
+ // invoke pre initialization hook
+ preInit(s, properties);
+
+ // check for property providers
+ if (this.beanFactory != null && this.beanFactory.containsBean(PropertyProvider.ROLE) ) {
+ try {
+ final PropertyProvider provider = (PropertyProvider) this.beanFactory.getBean(PropertyProvider.ROLE);
+ final Properties providedProperties = provider.getProperties(s, mode, this.getNameForPropertyProvider());
+ if (providedProperties != null) {
+ properties.putAll(providedProperties);
+ }
+ } catch (Exception ignore) {
+ this.logger.warn("Unable to get properties from provider.", ignore);
+ this.logger.warn("Continuing initialization.");
+ }
+ }
+
+ // add aditional directories
+ if (this.directories != null) {
+ final Iterator i = directories.iterator();
+ while (i.hasNext()) {
+ final String directory = (String) i.next();
+ // now read all properties from the properties directory
+ ResourceUtils.readProperties(directory, properties, getResourceLoader(), this.resourceFilter, this.logger);
+ // read all properties from the mode dependent directory
+ ResourceUtils.readProperties(directory + '/' + mode, properties, getResourceLoader(), this.resourceFilter, this.logger);
+ }
+ }
+
+ // add additional properties
+ if (this.additionalProperties != null) {
+ PropertyHelper.replaceAll(this.additionalProperties, s);
+ properties.putAll(this.additionalProperties);
+ }
+
+ // now overwrite with system properties
+ try {
+ properties.putAll(System.getProperties());
+ } catch (SecurityException se) {
+ // we ignore this
+ }
+
+ // invoke post initialization hook
+ postInit(s, properties);
+
+ PropertyHelper.replaceAll(properties, getParentSettings());
+ // configure settings
+ s.configure(properties);
+ s.makeReadOnly();
+
+ return s;
+ }
+
+ protected ResourceLoader getResourceLoader() {
+ if (this.resourceLoader != null) {
+ return this.resourceLoader;
+ }
+ if (this.servletContext != null) {
+ return new ServletContextResourceLoader(this.servletContext);
+ } else {
+ return new FileSystemResourceLoader();
+ }
+ }
+
+ protected String getSystemProperty(String key) {
+ return getSystemProperty(key, null);
+ }
+
+ protected String getSystemProperty(String key, String defaultValue) {
+ try {
+ return System.getProperty(key, defaultValue);
+ } catch (SecurityException se) {
+ // we ignore this
+ return defaultValue;
+ }
+ }
+
+ /**
+ * @see org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#processProperties(org.springframework.beans.factory.config.ConfigurableListableBeanFactory, java.util.Properties)
+ */
+ protected void processProperties(ConfigurableListableBeanFactory beanFactoryToProcess,
+ Properties props)
+ throws BeansException {
+ final BeanDefinitionVisitor visitor = new CocoonSettingsResolvingBeanDefinitionVisitor(this.settings);
+ String[] beanNames = beanFactoryToProcess.getBeanDefinitionNames();
+ for (int i = 0; i < beanNames.length; i++) {
+ BeanDefinition bd = beanFactoryToProcess.getBeanDefinition(beanNames[i]);
+ try {
+ visitor.visitBeanDefinition(bd);
+ } catch (BeanDefinitionStoreException e) {
+ throw new BeanDefinitionStoreException(bd.getResourceDescription(), beanNames[i], e);
+ }
+ }
+ }
+
+ /**
+ * @see org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#resolvePlaceholder(java.lang.String, java.util.Properties)
+ */
+ protected String resolvePlaceholder(String placeholder, Properties props) {
+ return PropertyHelper.getProperty(placeholder, props, null);
+ }
+
+ protected class CocoonSettingsResolvingBeanDefinitionVisitor
+ extends BeanDefinitionVisitor {
+
+ protected final Properties props;
+ protected final Set visitedPlaceholders = new HashSet();
+
+ public CocoonSettingsResolvingBeanDefinitionVisitor(Settings settings) {
+ this.props = new SettingsProperties(settings);
+ }
+
+ protected String resolveStringValue(String strVal) {
+ return parseStringValue(strVal, this.props, visitedPlaceholders);
+ }
+ }
+
+ /**
+ * Dump the settings object
+ */
+ protected void dumpSettings() {
+ if (this.logger.isDebugEnabled()) {
+ this.logger.debug("===== Settings Start =====");
+ this.logger.debug(this.settings.toString());
+ final List names = this.settings.getPropertyNames();
+ final Iterator i = names.iterator();
+ while (i.hasNext()) {
+ final String name = (String) i.next();
+ this.logger.debug("Property: " + name + "=" + this.settings.getProperty(name));
+ }
+ this.logger.debug("===== Settings End =====");
+ }
+ }
+
+ /**
+ * @see org.springframework.beans.factory.FactoryBean#getObject()
+ */
+ public Object getObject() throws Exception {
+ return this.settings;
+ }
+
+ /**
+ * @see org.springframework.beans.factory.FactoryBean#getObjectType()
+ */
+ public Class getObjectType() {
+ return Settings.class;
+ }
+
+ /**
+ * @see org.springframework.beans.factory.FactoryBean#isSingleton()
+ */
+ public boolean isSingleton() {
+ return true;
+ }
+}
diff --git a/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/java/org/apache/cocoon/spring/configurator/impl/AbstractSettingsElementParser.java b/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/java/org/apache/cocoon/spring/configurator/impl/AbstractSettingsElementParser.java
new file mode 100644
index 0000000..9a1c4af
--- /dev/null
+++ b/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/java/org/apache/cocoon/spring/configurator/impl/AbstractSettingsElementParser.java
@@ -0,0 +1,247 @@
+/*
+ * 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.cocoon.spring.configurator.impl;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+
+import org.apache.cocoon.spring.configurator.ResourceFilter;
+import org.apache.cocoon.spring.configurator.ResourceUtils;
+import org.springframework.beans.factory.BeanDefinitionStoreException;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.support.RootBeanDefinition;
+import org.springframework.beans.factory.xml.ParserContext;
+import org.springframework.core.io.Resource;
+import org.springframework.core.io.ResourceLoader;
+import org.springframework.core.io.support.ResourcePatternResolver;
+import org.w3c.dom.Element;
+
+/**
+ * Abstract class for the settings element parsers.
+ *
+ * @see ChildSettingsElementParser
+ * @see SettingsElementParser
+ * @version $Id$
+ * @since 1.0
+ */
+public abstract class AbstractSettingsElementParser extends AbstractElementParser {
+
+ /**
+ * Get the current running mode
+ */
+ protected abstract String getRunningMode(Element e);
+
+ /**
+ * Create and register the settings bean factory post processor.
+ */
+ protected abstract void createSettingsBeanFactoryPostProcessor(Element element,
+ ParserContext parserContext,
+ String runningMode);
+
+ private ResourceFilter resourceFilter;
+
+ /**
+ * Get additional includes of property directories.
+ */
+ protected List getPropertyIncludes(Element childSettingsElement) {
+ List propertyDirs = null;
+ if ( childSettingsElement != null ) {
+ final Element[] propertyDirConfigs = this.getChildElements(childSettingsElement, "include-properties");
+ if ( propertyDirConfigs != null && propertyDirConfigs.length > 0 ) {
+ propertyDirs = new ArrayList();
+ for(int i=0; i < propertyDirConfigs.length; i++) {
+ propertyDirs.add(this.getAttributeValue(propertyDirConfigs[i], "dir", null));
+ }
+ }
+ }
+ return propertyDirs;
+ }
+
+ /**
+ * Get additional properties.
+ */
+ protected Properties getAdditionalProperties(Element childSettingsElement) {
+ Properties variables = null;
+ final Element[] properties = this.getChildElements(childSettingsElement, "property");
+ if ( properties != null && properties.length > 0 ) {
+ variables = new Properties();
+ for(int i=0; i<properties.length; i++) {
+ variables.setProperty(this.getAttributeValue(properties[i], "name", null),
+ this.getAttributeValue(properties[i], "value", null));
+ }
+ }
+ return variables;
+ }
+
+ /**
+ * Get additional includes of bean configurations.
+ */
+ protected List getBeanIncludes(Element childSettingsElement) {
+ final List includes = new ArrayList();
+ // search for includes
+ if ( childSettingsElement.hasChildNodes() ) {
+ final Element[] includeElements = this.getChildElements(childSettingsElement, "include-beans");
+ if ( includeElements != null ) {
+ for(int i = 0 ; i < includeElements.length; i++ ) {
+ final String dir = this.getAttributeValue(includeElements[i], "dir", null);
+
+ includes.add(dir);
+ }
+ }
+ }
+ return includes;
+ }
+
+ /**
+ * Return the includes for the property override configuration
+ */
+ protected List getBeanPropertyOverrideIncludes(Element settingsElement) {
+ return this.getBeanIncludes(settingsElement);
+ }
+
+ /**
+ * @see org.springframework.beans.factory.xml.BeanDefinitionParser#parse(org.w3c.dom.Element, org.springframework.beans.factory.xml.ParserContext)
+ */
+ public BeanDefinition parse(Element element, ParserContext parserContext) {
+ final String runningMode = this.getRunningMode(element);
+
+ try {
+ this.resourceFilter = getResourceFilter(element);
+ } catch (Exception e) {
+ throw new BeanDefinitionStoreException("Unable to read filter configuration", e);
+ }
+
+ // create factory for settings object
+ this.createSettingsBeanFactoryPostProcessor(element, parserContext, runningMode);
+
+ // Get bean includes for property overrides
+ final List overridePropertyIncludes = this.getBeanPropertyOverrideIncludes(element);
+
+ // If there are bean includes for a directory, we register a property placeholder configurer
+ if ( overridePropertyIncludes.size() > 0 ) {
+ this.registerPropertyOverrideConfigurer(parserContext, overridePropertyIncludes);
+ }
+
+ // register additonal components
+ this.registerComponents(element, parserContext);
+
+ // Get bean includes
+ final List beanIncludes = this.getBeanIncludes(element);
+ // process bean includes!
+ final Iterator beanIncludeIterator = beanIncludes.iterator();
+ while ( beanIncludeIterator.hasNext() ) {
+ final String dir = (String)beanIncludeIterator.next();
+
+ try {
+ this.handleBeanInclude(parserContext, dir, false);
+ this.handleBeanInclude(parserContext, dir + "/" + runningMode, true);
+ } catch (Exception e) {
+ throw new BeanDefinitionStoreException("Unable to read spring configurations from " + dir, e);
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * This method can be used for subclasses to register additional components.
+ */
+ protected void registerComponents(Element settingsElement, ParserContext parserContext) {
+ // nothing to do here
+ }
+
+ /**
+ * Handle include for spring bean configurations.
+ */
+ protected void handleBeanInclude(final ParserContext parserContext,
+ final String path,
+ final boolean optional)
+ throws Exception {
+ final ResourcePatternResolver resolver =
+ (ResourcePatternResolver) parserContext.getReaderContext().getReader().getResourceLoader();
+
+ // check if the directory to read from exists
+ // we only check if optional is set to true
+ boolean load = true;
+ if ( optional
+ && !ResourceUtils.isClasspathUri(path) ) {
+ final Resource rsrc = resolver.getResource(path);
+ if ( !rsrc.exists()) {
+ load = false;
+ }
+ }
+ if ( load ) {
+ try {
+ Resource[] resources = resolver.getResources(path + "/*.xml");
+ resources = ResourceUtils.filterResources(resources, getResourceFilter());
+ Arrays.sort(resources, ResourceUtils.getResourceComparator());
+ for (int i = 0; i < resources.length; i++) {
+ this.handleImport(parserContext, resources[i].getURL().toExternalForm());
+ }
+ } catch (IOException ioe) {
+ throw new Exception("Unable to read configurations from " + path, ioe);
+ }
+ }
+ }
+
+ protected void handleImport(ParserContext parserContext, String uri) {
+ final ResourceLoader resourceLoader = parserContext.getReaderContext().getReader().getResourceLoader();
+ parserContext.getDelegate().getReaderContext().getReader().loadBeanDefinitions(resourceLoader.getResource(uri));
+ }
+
+ /**
+ * Register a property placeholder configurer. The configurer will read all
+ * *.properties files from the specified locations.
+ *
+ * @param parserContext
+ * @param locations
+ */
+ protected void registerPropertyOverrideConfigurer(final ParserContext parserContext,
+ final List locations) {
+ final RootBeanDefinition beanDef = this.createBeanDefinition(ExtendedPropertyOverrideConfigurer.class.getName(),
+ null, true);
+ beanDef.getPropertyValues().addPropertyValue("locations", locations);
+ beanDef.getPropertyValues().addPropertyValue("resourceLoader",
+ parserContext.getReaderContext().getReader().getResourceLoader());
+ beanDef.getPropertyValues().addPropertyValue("resourceFilter", getResourceFilter());
+ beanDef.getPropertyValues().addPropertyValue("beanNameSeparator", "/");
+ this.register(beanDef, ExtendedPropertyOverrideConfigurer.class.getName(), parserContext.getRegistry());
+ }
+
+
+ protected ResourceFilter getResourceFilter(Element e) throws Exception {
+ Element[] filters = this.getChildElements(e, "filter");
+
+ if (filters.length == 0)
+ return null;
+ else if (filters.length > 1)
+ throw new RuntimeException("Only one filter definition is allowed and you configured " + filters.length + " filters.");
+
+ String filterClassName = filters[0].getAttribute("class");
+ if (filterClassName.length() == 0)
+ throw new RuntimeException("Missing 'class' attribute.");
+ return (ResourceFilter)java.lang.Class.forName(filterClassName).newInstance();
+ }
+
+ protected final ResourceFilter getResourceFilter() {
+ return this.resourceFilter;
+ }
+}
diff --git a/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/java/org/apache/cocoon/spring/configurator/impl/BeanMap.java b/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/java/org/apache/cocoon/spring/configurator/impl/BeanMap.java
new file mode 100644
index 0000000..81ab44e
--- /dev/null
+++ b/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/java/org/apache/cocoon/spring/configurator/impl/BeanMap.java
@@ -0,0 +1,335 @@
+/*
+ * 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.cocoon.spring.configurator.impl;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+import org.springframework.beans.BeanWrapperImpl;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.BeanDefinitionStoreException;
+import org.springframework.beans.factory.BeanFactory;
+import org.springframework.beans.factory.BeanFactoryAware;
+import org.springframework.beans.factory.HierarchicalBeanFactory;
+import org.springframework.beans.factory.ListableBeanFactory;
+
+/**
+ * This is a map implementation collecting all beans of a specific type (class)
+ * from a spring bean factory. The beans are available through their configured
+ * bean id.
+ *
+ * The map has a lazy implementation: the beans are not searched on
+ * instantiation but the first time the map is accessed. This avoids any startup
+ * ordering problems.
+ *
+ * By default the map searches in the bean factory it is used in and in all the
+ * parent bean factories (if there are any). This behaviour can be changed by
+ * calling the {@link #setCheckParent(boolean)} method.
+ *
+ * @version $Id$
+ * @since 1.0.1
+ */
+public class BeanMap implements Map<Object, Object>, BeanFactoryAware {
+
+ /** The real map. */
+ protected final Map<Object, Object> beanMap = new HashMap<Object, Object>();
+
+ /** Is the map initialized? */
+ protected boolean initialized = false;
+
+ /** The bean factory. */
+ protected ListableBeanFactory beanFactory;
+
+ /** The class for all beans in this map. */
+ protected Class<?> beanClass;
+
+ /** Do we strip the prefix from the bean name? */
+ protected boolean stripPrefix = true;
+
+ /** Do we check the parent factories? */
+ protected boolean checkParent = true;
+
+ /** Do we check for properties? */
+ protected List<String> hasProperties = new ArrayList<String>();
+
+ /** Which property should we use to key the map? */
+ protected String keyProperty;
+
+ /**
+ * Get all the beans from the bean factory and put them into a map using their id.
+ *
+ * @param beanNames The bean names to load.
+ */
+ protected void load(Set<String> beanNames) {
+ for (String beanName : beanNames) {
+ Object key = this.stripPrefix(beanName);
+ if (this.hasProperties.size() > 0) {
+ final Object bean = this.beanFactory.getBean(beanName);
+ final BeanWrapperImpl wrapper = new BeanWrapperImpl(bean);
+ boolean isOk = true;
+ for (String propName : this.hasProperties) {
+ if (!wrapper.isReadableProperty(propName)) {
+ isOk = false;
+ }
+ }
+ if (isOk) {
+ if (this.keyProperty != null && this.keyProperty.length() > 0
+ && wrapper.isReadableProperty(this.keyProperty)) {
+ key = wrapper.getPropertyValue(this.keyProperty);
+ }
+ this.beanMap.put(key, bean);
+ }
+ } else {
+ final Object bean = this.beanFactory.getBean(beanName);
+ final BeanWrapperImpl wrapper = new BeanWrapperImpl(bean);
+ if (this.keyProperty != null && this.keyProperty.length() > 0
+ && wrapper.isReadableProperty(this.keyProperty)) {
+ key = wrapper.getPropertyValue(this.keyProperty);
+ }
+ this.beanMap.put(key, bean);
+ }
+ }
+ }
+
+ protected Object stripPrefix(final String beanName) {
+ final String prefix1 = this.beanClass.getName() + '.';
+ final String prefix2 = this.beanClass.getName() + '/';
+
+ Object key = beanName;
+ if (this.stripPrefix && (beanName.startsWith(prefix1) || beanName.startsWith(prefix2))) {
+ key = beanName.substring(prefix1.length());
+ }
+
+ return key;
+ }
+
+ /**
+ * Check if the bean is already initialized. If not, the bean's are searched
+ * in the bean factory.
+ */
+ protected void checkInit() {
+ if (!this.initialized) {
+ synchronized (this) {
+ if (!this.initialized) {
+ // although it is unlikely, but if this bean is used outside
+ // spring
+ // it will just contain an empty map
+ if (this.beanFactory != null) {
+ final Set<String> beanNames = new HashSet<String>();
+ this.getBeanNames(this.beanFactory, beanNames);
+ this.load(beanNames);
+ }
+ this.initialized = true;
+ }
+ }
+ }
+ }
+
+ /**
+ * Get all bean names for the given type.
+ *
+ * @param factory
+ * The bean factory.
+ * @param beanNames
+ * The set containing the resulting bean names.
+ */
+ protected void getBeanNames(ListableBeanFactory factory, Set<String> beanNames) {
+ // check parent first
+ if (this.checkParent) {
+ if (factory instanceof HierarchicalBeanFactory) {
+ if (((HierarchicalBeanFactory) factory).getParentBeanFactory() != null) {
+ this.getBeanNames((ListableBeanFactory) ((HierarchicalBeanFactory) factory).getParentBeanFactory(),
+ beanNames);
+ }
+ }
+ }
+ // get all bean names for our class
+ final String[] names = this.lookupBeans(factory);
+ for (int i = 0; i < names.length; i++) {
+ beanNames.add(names[i]);
+ }
+ }
+
+ protected String[] lookupBeans(ListableBeanFactory factory) {
+ return factory.getBeanNamesForType(this.beanClass);
+ }
+
+ /**
+ * @see org.springframework.beans.factory.BeanFactoryAware#setBeanFactory(org.springframework.beans.factory.BeanFactory)
+ */
+ public void setBeanFactory(BeanFactory factory) throws BeansException {
+ if (!(factory instanceof ListableBeanFactory)) {
+ throw new BeanDefinitionStoreException("BeanFactory must be listable.");
+ }
+ this.beanFactory = (ListableBeanFactory) factory;
+ }
+
+ public void setStripPrefix(boolean stripPrefix) {
+ this.stripPrefix = stripPrefix;
+ }
+
+ public void setCheckParent(boolean checkParent) {
+ this.checkParent = checkParent;
+ }
+
+ public void setHasProperties(String pHasProperties) {
+ final StringTokenizer tokenizer = new StringTokenizer(pHasProperties, " \t\n\r\f,");
+ final List<String> propNames = new ArrayList<String>();
+ while (tokenizer.hasMoreTokens()) {
+ propNames.add(tokenizer.nextToken());
+ }
+ this.hasProperties = propNames;
+ }
+
+ public void setKeyProperty(String pKeyProperty) {
+ this.keyProperty = pKeyProperty;
+ }
+
+ public void setType(Class<?> typeClass) {
+ this.beanClass = typeClass;
+ }
+
+ /**
+ * @see java.util.Map#clear()
+ */
+ public void clear() {
+ // no need to call checkInit as we clear the map!
+ this.initialized = true;
+ this.beanMap.clear();
+ }
+
+ /**
+ * @see java.util.Map#containsKey(java.lang.Object)
+ */
+ public boolean containsKey(Object key) {
+ this.checkInit();
+ return this.beanMap.containsKey(key);
+ }
+
+ /**
+ * @see java.util.Map#containsValue(java.lang.Object)
+ */
+ public boolean containsValue(Object value) {
+ this.checkInit();
+ return this.beanMap.containsValue(value);
+ }
+
+ /**
+ * @see java.util.Map#entrySet()
+ */
+ public Set<Entry<Object, Object>> entrySet() {
+ this.checkInit();
+ return this.beanMap.entrySet();
+ }
+
+ /**
+ * @see java.util.Map#get(java.lang.Object)
+ */
+ public Object get(Object key) {
+ this.checkInit();
+ return this.beanMap.get(key);
+ }
+
+ /**
+ * @see java.util.Map#isEmpty()
+ */
+ public boolean isEmpty() {
+ this.checkInit();
+ return this.beanMap.isEmpty();
+ }
+
+ /**
+ * @see java.util.Map#keySet()
+ */
+ public Set<Object> keySet() {
+ this.checkInit();
+ return this.beanMap.keySet();
+ }
+
+ /**
+ * @see java.util.Map#put(java.lang.Object, java.lang.Object)
+ */
+ public Object put(Object key, Object value) {
+ this.checkInit();
+ return this.beanMap.put(key, value);
+ }
+
+ /**
+ * @see java.util.Map#putAll(java.util.Map)
+ */
+ public void putAll(Map<?, ?> t) {
+ this.checkInit();
+ this.beanMap.putAll(t);
+ }
+
+ /**
+ * @see java.util.Map#remove(java.lang.Object)
+ */
+ public Object remove(Object key) {
+ this.checkInit();
+ return this.beanMap.remove(key);
+ }
+
+ /**
+ * @see java.util.Map#size()
+ */
+ public int size() {
+ this.checkInit();
+ return this.beanMap.size();
+ }
+
+ /**
+ * @see java.util.Map#values()
+ */
+ public Collection<Object> values() {
+ this.checkInit();
+ return this.beanMap.values();
+ }
+
+ /**
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ this.checkInit();
+ return this.beanMap.equals(obj);
+ }
+
+ /**
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ this.checkInit();
+ return this.beanMap.hashCode();
+ }
+
+ /**
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ this.checkInit();
+ return this.beanMap.toString();
+ }
+}
diff --git a/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/java/org/apache/cocoon/spring/configurator/impl/BeanMapElementParser.java b/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/java/org/apache/cocoon/spring/configurator/impl/BeanMapElementParser.java
new file mode 100644
index 0000000..247ced5
--- /dev/null
+++ b/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/java/org/apache/cocoon/spring/configurator/impl/BeanMapElementParser.java
@@ -0,0 +1,59 @@
+/*
+ * 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.cocoon.spring.configurator.impl;
+
+import org.springframework.beans.factory.BeanDefinitionStoreException;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.support.RootBeanDefinition;
+import org.springframework.beans.factory.xml.ParserContext;
+import org.springframework.util.ClassUtils;
+import org.w3c.dom.Element;
+
+/**
+ * The parser for the bean-map element.
+ *
+ * @version $Id$
+ * @since 1.0.1
+ */
+public class BeanMapElementParser extends AbstractElementParser {
+
+ /**
+ * @see org.springframework.beans.factory.xml.BeanDefinitionParser#parse(org.w3c.dom.Element, org.springframework.beans.factory.xml.ParserContext)
+ */
+ public BeanDefinition parse(Element element, ParserContext parserContext) {
+ // create a new bean definition for the aspect chain
+ RootBeanDefinition beanDef = this.createBeanDefinition(BeanMap.class, null, false);
+ final String type = this.getAttributeValue(element, "type", null);
+ final Class typeClass;
+ try {
+ typeClass = ClassUtils.forName(type);
+ } catch (ClassNotFoundException e) {
+ throw new BeanDefinitionStoreException("Unable to load aspect class: " + type, e);
+ }
+ beanDef.getPropertyValues().addPropertyValue("type", typeClass);
+ beanDef.getPropertyValues().addPropertyValue("checkParent", this.getAttributeValue(element, "check-parent", "true"));
+ beanDef.getPropertyValues().addPropertyValue("stripPrefix", this.getAttributeValue(element, "strip-prefix", "true"));
+ beanDef.getPropertyValues().addPropertyValue("hasProperties", this.getAttributeValue(element, "has-properties", ""));
+ beanDef.getPropertyValues().addPropertyValue("keyProperty", this.getAttributeValue(element, "key-property", ""));
+
+ // register bean if it's a global definition
+ if ( !parserContext.isNested() ) {
+ this.register(beanDef, element, parserContext.getRegistry());
+ }
+ return beanDef;
+ }
+}
diff --git a/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/java/org/apache/cocoon/spring/configurator/impl/ChildSettingsBeanFactoryPostProcessor.java b/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/java/org/apache/cocoon/spring/configurator/impl/ChildSettingsBeanFactoryPostProcessor.java
new file mode 100644
index 0000000..d2f131e
--- /dev/null
+++ b/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/java/org/apache/cocoon/spring/configurator/impl/ChildSettingsBeanFactoryPostProcessor.java
@@ -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.cocoon.spring.configurator.impl;
+
+
+/**
+ * This is a bean factory post processor which sets up a child settings object.
+ *
+ * The settings object is created by reading several property files and merging of
+ * the values. If there is more than one definition for a property, the last one wins.
+ * The property files are read in the following order:
+ * 1) Property provider (if configured in the bean factory)
+ * 2) Add properties from configured directories {@link #directories}.
+ * 3) Add additional properties configured at {@link #additionalProperties}
+ * 4) System properties
+ *
+ * @since 1.0
+ * @version $Id$
+ */
+public class ChildSettingsBeanFactoryPostProcessor
+ extends AbstractSettingsBeanFactoryPostProcessor {
+
+ /** Unique name for this child settings context. */
+ protected String name;
+
+ /**
+ * Set the unique name for this settings context.
+ * @param newName The new name.
+ */
+ public void setName(String newName) {
+ this.name = newName;
+ }
+
+ /**
+ * @see org.apache.cocoon.spring.configurator.impl.AbstractSettingsBeanFactoryPostProcessor#getRunningMode()
+ */
+ protected String getRunningMode() {
+ return this.getParentSettings().getRunningMode();
+ }
+
+ /**
+ * @see org.apache.cocoon.spring.configurator.impl.AbstractSettingsBeanFactoryPostProcessor#getNameForPropertyProvider()
+ */
+ protected String getNameForPropertyProvider() {
+ return this.name;
+ }
+}
diff --git a/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/java/org/apache/cocoon/spring/configurator/impl/ChildSettingsElementParser.java b/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/java/org/apache/cocoon/spring/configurator/impl/ChildSettingsElementParser.java
new file mode 100644
index 0000000..3fb6fcc
--- /dev/null
+++ b/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/java/org/apache/cocoon/spring/configurator/impl/ChildSettingsElementParser.java
@@ -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.cocoon.spring.configurator.impl;
+
+import java.util.List;
+import java.util.Properties;
+
+import org.apache.cocoon.configuration.Settings;
+import org.apache.cocoon.spring.configurator.WebAppContextUtils;
+import org.springframework.beans.factory.support.RootBeanDefinition;
+import org.springframework.beans.factory.xml.ParserContext;
+import org.springframework.web.context.WebApplicationContext;
+import org.w3c.dom.Element;
+
+/**
+ * Add a bean definition for the settings object of a child context to the bean factory
+ * and process all includes of spring configurations.
+ *
+ * @see ConfiguratorNamespaceHandler
+ * @see ChildSettingsBeanFactoryPostProcessor
+ * @version $Id$
+ * @since 1.0
+ */
+public class ChildSettingsElementParser extends AbstractSettingsElementParser {
+
+ /**
+ * @see org.apache.cocoon.spring.configurator.impl.AbstractSettingsElementParser#getRunningMode(org.w3c.dom.Element)
+ */
+ protected String getRunningMode(Element e) {
+ // get root application context
+ final WebApplicationContext rootAppContext = WebAppContextUtils.getCurrentWebApplicationContext();
+ // get running mode from root settings
+ return ((Settings)rootAppContext.getBean(Settings.ROLE)).getRunningMode();
+ }
+
+ /**
+ * Create and register the settings bean factory post processor.
+ */
+ protected void createSettingsBeanFactoryPostProcessor(Element element,
+ ParserContext parserContext,
+ String runningMode) {
+ // Create definition for child settings
+ RootBeanDefinition def = this.createBeanDefinition(ChildSettingsBeanFactoryPostProcessor.class.getName(),
+ "init",
+ false);
+ def.getPropertyValues().addPropertyValue("name", element.getAttribute("name"));
+
+ final Properties additionalProps = this.getAdditionalProperties(element);
+ if ( additionalProps != null ) {
+ def.getPropertyValues().addPropertyValue("additionalProperties", additionalProps);
+ }
+
+ final List propertiesIncludes = this.getPropertyIncludes(element);
+ if ( propertiesIncludes != null ) {
+ def.getPropertyValues().addPropertyValue("directories", propertiesIncludes);
+ }
+
+ // and now we register the child settings
+ this.register(def, Settings.ROLE, parserContext.getRegistry());
+ }
+}
diff --git a/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/java/org/apache/cocoon/spring/configurator/impl/ChildXmlWebApplicationContext.java b/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/java/org/apache/cocoon/spring/configurator/impl/ChildXmlWebApplicationContext.java
new file mode 100644
index 0000000..3b5e874
--- /dev/null
+++ b/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/java/org/apache/cocoon/spring/configurator/impl/ChildXmlWebApplicationContext.java
@@ -0,0 +1,119 @@
+/*
+ * 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.cocoon.spring.configurator.impl;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
+import org.springframework.core.io.ByteArrayResource;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.core.io.Resource;
+import org.springframework.core.io.UrlResource;
+import org.springframework.util.ResourceUtils;
+import org.springframework.web.context.support.XmlWebApplicationContext;
+
+/**
+ * Own implementation of a {@link XmlWebApplicationContext} which is configured with
+ * a base url specifying the root directory for this web application context.
+ *
+ * @since 1.0
+ * @version $Id$
+ */
+public class ChildXmlWebApplicationContext extends XmlWebApplicationContext {
+
+ /** The base url (already postfixed with a '/'). */
+ protected String baseUrl;
+
+ /** The bean definition for this context. */
+ protected String beanDefinition;
+
+ public ChildXmlWebApplicationContext() {
+ // nothing to do here
+ }
+
+ public ChildXmlWebApplicationContext(String url,
+ String rootDefinition) {
+ this.setBaseUrl(url);
+ this.setBeanDefinition(rootDefinition);
+ }
+
+ public String getBaseUrl() {
+ return this.baseUrl;
+ }
+
+ public void setBaseUrl(String url) {
+ if ( url.endsWith("/") ) {
+ this.baseUrl = url;
+ } else {
+ this.baseUrl = url + '/';
+ }
+ }
+
+ public String getBeanDefinition() {
+ return beanDefinition;
+ }
+
+ public void setBeanDefinition(String beanDefinition) {
+ this.beanDefinition = beanDefinition;
+ }
+
+ /**
+ * @see org.springframework.web.context.support.XmlWebApplicationContext#loadBeanDefinitions(org.springframework.beans.factory.xml.XmlBeanDefinitionReader)
+ */
+ protected void loadBeanDefinitions(XmlBeanDefinitionReader reader) throws BeansException, IOException {
+ if ( this.beanDefinition != null ) {
+ reader.loadBeanDefinitions(new ByteArrayResource(this.beanDefinition.getBytes("utf-8")));
+ }
+ super.loadBeanDefinitions(reader);
+ }
+
+ /**
+ * @see org.springframework.web.context.support.AbstractRefreshableWebApplicationContext#getResourceByPath(java.lang.String)
+ */
+ protected Resource getResourceByPath(String path) {
+ if ( this.baseUrl != null ) {
+ // only if the path does not start with a "/" and is not a url
+ // we assume it is relative
+ if ( path != null && !path.startsWith("/") && !ResourceUtils.isUrl(path) ) {
+ final String absoluteUrl = this.baseUrl + path;
+ if (absoluteUrl.startsWith(CLASSPATH_URL_PREFIX)) {
+ return new ClassPathResource(absoluteUrl.substring(CLASSPATH_URL_PREFIX.length()), getClassLoader());
+ }
+ try {
+ // try URL
+ URL url = new URL(absoluteUrl);
+ return new UrlResource(url);
+ } catch (MalformedURLException ex) {
+ // no URL -> resolve resource path
+ return super.getResourceByPath(absoluteUrl);
+ }
+ }
+ }
+ return super.getResourceByPath(path);
+ }
+
+ /**
+ * A child application context has no default configuration.
+ * @see org.springframework.web.context.support.XmlWebApplicationContext#getDefaultConfigLocations()
+ */
+ protected String[] getDefaultConfigLocations() {
+ return new String[0];
+ }
+}
diff --git a/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/java/org/apache/cocoon/spring/configurator/impl/ConfiguratorNamespaceHandler.java b/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/java/org/apache/cocoon/spring/configurator/impl/ConfiguratorNamespaceHandler.java
new file mode 100644
index 0000000..1e72b71
--- /dev/null
+++ b/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/java/org/apache/cocoon/spring/configurator/impl/ConfiguratorNamespaceHandler.java
@@ -0,0 +1,48 @@
+/*
+ * 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.cocoon.spring.configurator.impl;
+
+import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
+
+/**
+ * Spring namespace handler for the cocoon core namespace. Currently this namespace defines the
+ * following elements (in the namespace "http://cocoon.apache.org/schema/configurator"):
+ * <ul>
+ * <li>"settings": This sets up the Cocoon Settings object (by reading the property files located
+ * under /WEB-INF/cocoon/properties. By specifying the attribute "processorClassName" an own
+ * implementation can be used (this should be a subclass of the
+ * {@link SettingsBeanFactoryPostProcessor}).</li>
+ * <li>"child-settings" : This sets up a sub context.</li>
+ * <li>"bean-map" : Creates a bean map. "wildcard-bean-map" : Creates a bean map by matching the
+ * bean name against a wildcard expression.</li>
+ * </ul>
+ *
+ * @version $Id$
+ * @since 1.0
+ */
+public class ConfiguratorNamespaceHandler extends NamespaceHandlerSupport {
+
+ /**
+ * @see org.springframework.beans.factory.xml.NamespaceHandler#init()
+ */
+ public void init() {
+ this.registerBeanDefinitionParser("settings", new SettingsElementParser());
+ this.registerBeanDefinitionParser("child-settings", new ChildSettingsElementParser());
+ this.registerBeanDefinitionParser("bean-map", new BeanMapElementParser());
+ this.registerBeanDefinitionParser("wildcard-bean-map", new WildcardBeanMapElementParser());
+ }
+}
diff --git a/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/java/org/apache/cocoon/spring/configurator/impl/Constants.java b/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/java/org/apache/cocoon/spring/configurator/impl/Constants.java
new file mode 100644
index 0000000..cc5b851
--- /dev/null
+++ b/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/java/org/apache/cocoon/spring/configurator/impl/Constants.java
@@ -0,0 +1,51 @@
+/*
+ * 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.cocoon.spring.configurator.impl;
+
+/**
+ * Some constants for the spring integration.
+ * The default location of spring related configuration files.
+ *
+ * @version $Id$
+ * @since 1.0
+ */
+public abstract class Constants {
+
+ /**
+ * The location of spring configuration files in the classpath.
+ * From this location bean definitions (*.xml) and property overrides (*.properties)
+ * are read.
+ */
+ public static final String CLASSPATH_SPRING_CONFIGURATION_LOCATION =
+ "classpath*:META-INF/cocoon/spring";
+
+ /**
+ * The location of property files (*.properties) for the settings.
+ */
+ public static final String CLASSPATH_PROPERTIES_LOCATION =
+ "classpath*:META-INF/cocoon/properties";
+
+ /**
+ * The location of global property overrides (*.properties).
+ */
+ public static final String GLOBAL_SPRING_CONFIGURATION_LOCATION = "/WEB-INF/cocoon/spring";
+
+ /**
+ * The location of global property files (*.properties) for the settings.
+ */
+ public static final String GLOBAL_PROPERTIES_LOCATION = "/WEB-INF/cocoon/properties";
+}
diff --git a/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/java/org/apache/cocoon/spring/configurator/impl/ExtendedPropertyOverrideConfigurer.java b/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/java/org/apache/cocoon/spring/configurator/impl/ExtendedPropertyOverrideConfigurer.java
new file mode 100644
index 0000000..fd02e23
--- /dev/null
+++ b/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/java/org/apache/cocoon/spring/configurator/impl/ExtendedPropertyOverrideConfigurer.java
@@ -0,0 +1,138 @@
+/*
+ * 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.cocoon.spring.configurator.impl;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+
+import org.apache.cocoon.configuration.Settings;
+import org.apache.cocoon.spring.configurator.ResourceUtils;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
+import org.springframework.beans.factory.config.PropertyOverrideConfigurer;
+import org.springframework.core.io.DefaultResourceLoader;
+import org.springframework.core.io.ResourceLoader;
+
+import org.apache.cocoon.spring.configurator.ResourceFilter;
+
+/**
+ * Our version of the property override configurer which reads properties from
+ * the Cocoon spring configuration directory. A property should have the
+ * following format: {bean name}/{property name}={value}.
+ *
+ * @version $Id$
+ * @since 1.0
+ */
+public class ExtendedPropertyOverrideConfigurer extends PropertyOverrideConfigurer {
+
+ /**
+ * The locations of the directories where the different property files are
+ * located.
+ */
+ protected List locations;
+
+ /**
+ * The resource loader used to load the property files. This loader is
+ * either resolving relative to the current sitemap or the root of the
+ * context.
+ */
+ protected ResourceLoader resourceLoader = new DefaultResourceLoader();
+
+ protected ResourceFilter resourceFilter;
+
+ /**
+ * The settings object.
+ */
+ protected Settings settings;
+
+ public ExtendedPropertyOverrideConfigurer() {
+ // add default locations
+ final List list = new ArrayList();
+ list.add(Constants.CLASSPATH_SPRING_CONFIGURATION_LOCATION);
+ list.add(Constants.GLOBAL_SPRING_CONFIGURATION_LOCATION);
+ }
+
+ /**
+ * Set the directories to search in.
+ *
+ * @param list A list of string pointing to directories.
+ */
+ public void setLocations(final List list) {
+ this.locations = list;
+ }
+
+ /**
+ * Set the settings.
+ *
+ * @param object The settings object.
+ */
+ public void setSettings(Settings object) {
+ this.settings = object;
+ }
+
+ /**
+ * Set the resource loader.
+ *
+ * @param loader The new resource loader.
+ */
+ public void setResourceLoader(final ResourceLoader loader) {
+ this.resourceLoader = loader;
+ }
+
+ /**
+ * Set the {@link ResourceFilter resource filter}
+ *
+ * @param resourceFilter
+ */
+ public void setResourceFilter(ResourceFilter resourceFilter) {
+ this.resourceFilter = resourceFilter;
+ }
+
+ /**
+ * Read all property files from the specified location and apply the
+ * changes.
+ *
+ * @see org.springframework.beans.factory.config.PropertyResourceConfigurer#postProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory)
+ */
+ public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
+ if (this.logger.isDebugEnabled()) {
+ this.logger.debug("Processing bean factory: " + beanFactory);
+ }
+ final String mode = RunningModeHelper.determineRunningMode(this.settings != null ? this.settings.getRunningMode() : null);
+ final Properties mergedProps = new Properties();
+
+ if ( this.locations != null ) {
+ final Iterator i = this.locations.iterator();
+ while ( i.hasNext() ) {
+ final String location = (String)i.next();
+ ResourceUtils.readProperties(location, mergedProps, this.resourceLoader, resourceFilter, this.logger);
+ // read properties from running-mode dependent directory
+ ResourceUtils.readProperties(location + '/' + mode, mergedProps, this.resourceLoader, resourceFilter, this.logger);
+ }
+ }
+
+ if (mergedProps.size() > 0) {
+ // Convert the merged properties, if necessary.
+ convertProperties(mergedProps);
+
+ // Let the subclass process the properties.
+ processProperties(beanFactory, mergedProps);
+ }
+ }
+}
diff --git a/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/java/org/apache/cocoon/spring/configurator/impl/RunningModeHelper.java b/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/java/org/apache/cocoon/spring/configurator/impl/RunningModeHelper.java
new file mode 100644
index 0000000..7975e44
--- /dev/null
+++ b/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/java/org/apache/cocoon/spring/configurator/impl/RunningModeHelper.java
@@ -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.cocoon.spring.configurator.impl;
+
+import org.apache.cocoon.configuration.SettingsDefaults;
+
+/**
+ * Helper class to determine the running mode.
+ *
+ * @since 1.0
+ * @version $Id$
+ */
+public abstract class RunningModeHelper {
+
+ /**
+ * Name of the system property specifying the running mode.
+ */
+ public final static String PROPERTY_RUNNING_MODE = "org.apache.cocoon.mode";
+
+ // determine an ev. set running mode from the system properties
+ private static final String SYSTEM_RUNNING_MODE;
+ static {
+ String mode = null;
+ try {
+ mode = System.getProperty( PROPERTY_RUNNING_MODE, null );
+ } catch (SecurityException se) {
+ // we ignore this
+ }
+ SYSTEM_RUNNING_MODE = mode;
+ }
+
+ /**
+ * Determine the running mode.
+ * A non-null system property will have precedence over everything else.
+ * The system default running mode will be used if the passed parameter mode is null.
+ *
+ * @param mode The default running mode.
+ * @return The current running mode.
+ * @see #PROPERTY_RUNNING_MODE
+ * @see SettingsDefaults#DEFAULT_RUNNING_MODE
+ */
+ public static String determineRunningMode(String mode) {
+ if (SYSTEM_RUNNING_MODE != null) {
+ return SYSTEM_RUNNING_MODE;
+ }
+ if (mode == null) {
+ return SettingsDefaults.DEFAULT_RUNNING_MODE;
+ }
+ return mode;
+ }
+
+ /**
+ * Check if the value for the running mode is valid.
+ * Currently this method does not check anything. All modes (apart from null)
+ * are valid.
+ * @param mode Check if the mode is a valid mode.
+ * @throws IllegalArgumentException if the mode is invalid
+ */
+ public static void checkRunningMode(String mode)
+ throws IllegalArgumentException {
+ if ( mode == null ) {
+ throw new IllegalArgumentException("Running mode can't be null.");
+ }
+ /*
+ if ( !Arrays.asList(SettingsDefaults.RUNNING_MODES).contains(mode) ) {
+ final String msg =
+ "Invalid running mode: " + mode + " - Use one of: " + Arrays.asList(SettingsDefaults.RUNNING_MODES);
+ throw new IllegalArgumentException(msg);
+ }
+ */
+ }
+}
diff --git a/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/java/org/apache/cocoon/spring/configurator/impl/ServletContextFactoryBean.java b/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/java/org/apache/cocoon/spring/configurator/impl/ServletContextFactoryBean.java
new file mode 100644
index 0000000..519788d
--- /dev/null
+++ b/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/java/org/apache/cocoon/spring/configurator/impl/ServletContextFactoryBean.java
@@ -0,0 +1,69 @@
+/*
+ * 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.cocoon.spring.configurator.impl;
+
+import javax.servlet.ServletContext;
+
+import org.springframework.beans.factory.FactoryBean;
+import org.springframework.web.context.ServletContextAware;
+
+/**
+ * Simple Spring factory bean which provides the servlet context as a bean.
+ * This avoids a dependence to Springs ServletContextAware interface.
+ *
+ * @version $Id$
+ * @since 1.0
+ */
+public class ServletContextFactoryBean implements FactoryBean, ServletContextAware {
+
+ protected static ServletContext servletContext;
+
+ public static ServletContext getServletContext() {
+ if ( servletContext == null ) {
+ throw new RuntimeException("ServletContext in ServletContextFactoryBean is not initialized yet. Check your configuration.");
+ }
+ return servletContext;
+ }
+
+ /**
+ * @see org.springframework.web.context.ServletContextAware#setServletContext(javax.servlet.ServletContext)
+ */
+ public void setServletContext(ServletContext context) {
+ servletContext = context;
+ }
+
+ /**
+ * @see org.springframework.beans.factory.FactoryBean#getObject()
+ */
+ public Object getObject() throws Exception {
+ return servletContext;
+ }
+
+ /**
+ * @see org.springframework.beans.factory.FactoryBean#getObjectType()
+ */
+ public Class getObjectType() {
+ return ServletContext.class;
+ }
+
+ /**
+ * @see org.springframework.beans.factory.FactoryBean#isSingleton()
+ */
+ public boolean isSingleton() {
+ return true;
+ }
+}
diff --git a/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/java/org/apache/cocoon/spring/configurator/impl/SettingsBeanFactoryPostProcessor.java b/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/java/org/apache/cocoon/spring/configurator/impl/SettingsBeanFactoryPostProcessor.java
new file mode 100644
index 0000000..685d288
--- /dev/null
+++ b/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/java/org/apache/cocoon/spring/configurator/impl/SettingsBeanFactoryPostProcessor.java
@@ -0,0 +1,358 @@
+/*
+ * 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.cocoon.spring.configurator.impl;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.Properties;
+
+import org.apache.cocoon.configuration.MutableSettings;
+import org.apache.cocoon.configuration.Settings;
+import org.apache.cocoon.configuration.SettingsDefaults;
+import org.apache.cocoon.spring.configurator.ResourceUtils;
+
+/**
+ * This is a bean factory post processor which handles all the settings stuff for Cocoon. It reads
+ * in all properties files and replaces references to them in the spring configuration files. In
+ * addition this bean acts as a factory bean providing the settings object.
+ *
+ * <p>
+ * The settings object is created by reading several property files and merging of the values. If
+ * there is more than one definition for a property, the last one wins. The property files are read
+ * in the following order:
+ * <ol>
+ * <li>If {@link #readFromClasspath} is true: classpath*:/META-INF/cocoon/properties/*.properties
+ * Default values for the core and each block - the files are read in alphabetical order. Actually
+ * the files are read in two chunks, the first one containing all property files from jar files, and
+ * the second one containing all property files from WEB-INF/classes.
+ * <li>If {@link #readFromClasspath} is true:
+ * classpath*:/META-INF/cocoon/properties/[RUNNING_MODE]/*.properties Default values for the core
+ * and each block for a specific running mode - the files are read in alphabetical order. Actually
+ * the files are read in two chunks, the first one containing all property files from jar files, and
+ * the second one containing all property files from WEB-INF/classes.
+ * <li>If {@link #readFromGlobalLocation} is true: /WEB-INF/cocoon/properties/*.properties Default
+ * values for the core and each block - the files are read in alphabetical order. Actually the files
+ * are read in two chunks, the first one containing all property files from jar files, and the
+ * second one containing all property files from WEB-INF/classes.
+ * <li>If {@link #readFromGlobalLocation} is true:
+ * /WEB-INF/cocoon/properties/[RUNNING_MODE]/*.properties Default values for the core and each block
+ * for a specific running mode - the files are read in alphabetical order. Actually the files are
+ * read in two chunks, the first one containing all property files from jar files, and the second
+ * one containing all property files from WEB-INF/classes.
+ * <li>Working directory from servlet context (if not already set)
+ * <li>Optional property file which is stored under ".cocoon/settings.properties" in the user
+ * directory.
+ * <li>Additional property file specified by the "org.apache.cocoon.settings" property. If the
+ * property defines a directory, all property files from this directory are read in alphabetical
+ * order and all files from a sub directory with the name of the current running mode are read in
+ * alphabetical order as well.
+ * <li>Property provider (if configured in the bean factory)
+ * <li>Add properties from configured directories {@link #directories}.
+ * <li>Add additional properties configured at {@link #additionalProperties}
+ * <li>System properties
+ * </ol>
+ *
+ * This means that system properties (provided on startup of the web application) override all
+ * others etc.
+ *
+ * @since 1.0
+ * @version $Id$
+ */
+public class SettingsBeanFactoryPostProcessor extends AbstractSettingsBeanFactoryPostProcessor {
+
+ /**
+ * The running mode for the web application.
+ */
+ protected String runningMode = SettingsDefaults.DEFAULT_RUNNING_MODE;
+
+ /**
+ * Should we read the properties from the classpath?
+ *
+ * @see Constants#CLASSPATH_PROPERTIES_LOCATION
+ */
+ protected boolean readFromClasspath = true;
+
+ /**
+ * Should we read the properties from the global location?
+ *
+ * @see Constants#GLOBAL_PROPERTIES_LOCATION
+ */
+ protected boolean readFromGlobalLocation = true;
+
+ /**
+ * Set the running mode.
+ *
+ * @param mode The new running mode.
+ */
+ public void setRunningMode(String mode) {
+ this.runningMode = mode;
+ }
+
+ /**
+ * Set if we read property configurations from the classpath.
+ *
+ * @param readFromClasspath
+ */
+ public void setReadFromClasspath(boolean readFromClasspath) {
+ this.readFromClasspath = readFromClasspath;
+ }
+
+ /**
+ * Set if we read property configurations from the global location.
+ */
+ public void setReadFromGlobalLocation(boolean readFromGlobalLocation) {
+ this.readFromGlobalLocation = readFromGlobalLocation;
+ }
+
+ /**
+ * Initialize this processor. Setup the settings object.
+ *
+ * @throws Exception
+ */
+ @Override
+ public void init() throws Exception {
+ // get the running mode
+ final String mode = this.getRunningMode();
+ RunningModeHelper.checkRunningMode(mode);
+
+ // print out version information
+ final Properties pomProps = ResourceUtils.getPOMProperties("org.apache.cocoon", "cocoon-spring-configurator");
+ final String version;
+ if (pomProps != null) {
+ version = pomProps.getProperty("version");
+ } else {
+ version = null;
+ }
+
+ // give a startup message
+ final String msg = "Apache Cocoon Spring Configurator " + (version != null ? "v" + version + " " : "")
+ + "is running in mode '" + mode + "'.";
+ if (this.servletContext != null) {
+ this.servletContext.log(msg);
+ } else {
+ this.logger.info(msg);
+ }
+
+ // first we dump the system properties
+ this.dumpSystemProperties();
+
+ // now create the settings object
+ super.init();
+
+ // finally pre load classes
+ this.forceLoad();
+ }
+
+ /**
+ * @see org.apache.cocoon.spring.configurator.impl.AbstractSettingsBeanFactoryPostProcessor#getRunningMode()
+ */
+ @Override
+ protected String getRunningMode() {
+ return RunningModeHelper.determineRunningMode(this.runningMode);
+ }
+
+ @Override
+ protected void preInit(final MutableSettings s, final Properties properties) {
+ final String mode = this.getRunningMode();
+ if (this.readFromClasspath) {
+ // now read all properties from classpath directory
+ ResourceUtils.readProperties(Constants.CLASSPATH_PROPERTIES_LOCATION, properties, this.getResourceLoader(),
+ this.resourceFilter, this.logger);
+ // read all properties from the mode dependent directory
+ ResourceUtils.readProperties(Constants.CLASSPATH_PROPERTIES_LOCATION + "/" + mode, properties, this
+ .getResourceLoader(), this.resourceFilter, this.logger);
+ }
+
+ if (this.readFromGlobalLocation) {
+ // now read all properties from the properties directory
+ ResourceUtils.readProperties(Constants.GLOBAL_PROPERTIES_LOCATION, properties, this.getResourceLoader(),
+ this.resourceFilter, this.logger);
+ // read all properties from the mode dependent directory
+ ResourceUtils.readProperties(Constants.GLOBAL_PROPERTIES_LOCATION + "/" + mode, properties, this
+ .getResourceLoader(), this.resourceFilter, this.logger);
+ }
+
+ // set default work directory value
+ if (s.getWorkDirectory() == null) {
+ File workDir;
+ // fill from the servlet context
+ if (this.servletContext != null) {
+ workDir = (File) this.servletContext.getAttribute("javax.servlet.context.tempdir");
+ } else {
+ workDir = new File("cocoon-files");
+ }
+ s.setWorkDirectory(workDir.getAbsolutePath());
+ }
+
+ // set default cache directory value
+ if (s.getCacheDirectory() == null) {
+ s.setCacheDirectory(new File(s.getWorkDirectory(), "cache-dir").getAbsolutePath());
+ }
+
+ // read additional properties file
+ // first try in home directory
+ final String homeDir = this.getSystemProperty("user.home");
+ if (homeDir != null) {
+ final String fileName = homeDir + File.separator + ".cocoon" + File.separator + "settings.properties";
+ final File testFile = new File(fileName);
+ if (testFile.exists()) {
+ if (this.logger.isDebugEnabled()) {
+ this.logger.debug("Reading user settings from '" + fileName + "'");
+ }
+ try {
+ final FileInputStream fis = new FileInputStream(fileName);
+ try {
+ properties.load(fis);
+ } finally {
+ try {
+ fis.close();
+ } catch (IOException ioe) {
+ this.logger.warn("Failed to close FileInputStream:", ioe);
+ }
+ }
+ } catch (IOException ignore) {
+ this.logger.info("Unable to read '" + fileName + "' - continuing with initialization.", ignore);
+ }
+ }
+ }
+
+ // check for additionally specified custom file:
+ // 1. bean attribute
+ // 2. servletContext init parameter
+ // 3. system property
+ String additionalPropertyFile = s.getProperty(Settings.PROPERTY_USER_SETTINGS, this
+ .getServletContextInitParameter(Settings.PROPERTY_USER_SETTINGS, this
+ .getSystemProperty(Settings.PROPERTY_USER_SETTINGS)));
+ if (additionalPropertyFile != null) {
+ if (this.logger.isDebugEnabled()) {
+ this.logger.debug("Reading user settings from '" + additionalPropertyFile + "'");
+ }
+ final File additionalFile = new File(additionalPropertyFile);
+ if (additionalFile.exists()) {
+ if (additionalFile.isDirectory()) {
+ // read from directory
+ ResourceUtils.readProperties(additionalFile.getAbsolutePath(), properties,
+ this.getResourceLoader(), this.resourceFilter, this.logger);
+ // read all properties from the mode dependent directory
+ ResourceUtils.readProperties(additionalFile.getAbsolutePath() + File.separatorChar + mode,
+ properties, this.getResourceLoader(), this.resourceFilter, this.logger);
+ } else {
+ // read the file
+ try {
+ final FileInputStream fis = new FileInputStream(additionalFile);
+ properties.load(fis);
+ fis.close();
+ } catch (IOException ignore) {
+ this.logger.info("Unable to read '" + additionalPropertyFile
+ + "' - continuing with initialization.", ignore);
+ }
+ }
+ } else {
+ this.logger.info("Additional settings file '" + additionalPropertyFile
+ + "' does not exist - continuing with initialization.");
+ }
+ }
+ }
+
+ protected String getServletContextInitParameter(String key, String defaultValue) {
+ if (this.servletContext == null) {
+ return defaultValue;
+ }
+
+ String servletContextSettings = this.servletContext.getInitParameter(key);
+
+ if (servletContextSettings == null || "".equals(servletContextSettings)) {
+ return defaultValue;
+ }
+
+ return servletContextSettings;
+ }
+
+ @Override
+ protected MutableSettings createSettings() {
+ final MutableSettings s = super.createSettings();
+
+ // first init the work-directory for the logger.
+ // this is required if we are running inside a war file!
+ File workDir = new File(s.getWorkDirectory());
+ workDir.mkdirs();
+ if (this.logger.isDebugEnabled()) {
+ this.logger.debug("Using work-directory " + workDir);
+ }
+
+ File cacheDir = new File(s.getCacheDirectory());
+ cacheDir.mkdirs();
+ if (this.logger.isDebugEnabled()) {
+ this.logger.debug("Using cache-directory " + cacheDir);
+ }
+
+ return s;
+ }
+
+ /**
+ * Dump System Properties.
+ */
+ protected void dumpSystemProperties() {
+ if (this.logger.isDebugEnabled()) {
+ try {
+ Enumeration e = System.getProperties().propertyNames();
+ this.logger.debug("===== System Properties Start =====");
+ while (e.hasMoreElements()) {
+ String key = (String) e.nextElement();
+ this.logger.debug(key + "=" + System.getProperty(key));
+ }
+ this.logger.debug("===== System Properties End =====");
+ } catch (SecurityException se) {
+ // Ignore Exceptions.
+ }
+ }
+ }
+
+ /**
+ * Handle the <code>load-class</code> settings. This overcomes limits in many classpath issues.
+ * One of the more notorious ones is a bug in WebSphere that does not load the URL handler for
+ * the <code>classloader://</code> protocol. In order to overcome that bug, set
+ * <code>org.apache.cocoon.classloader.load.classes.XY</code> property to the
+ * <code>com.ibm.servlet.classloader.Handler</code> value.
+ *
+ * <p>
+ * If you need to load more than one class, then add several properties, all starting with
+ * <cod>org.apache.cocoon.classloader.load.classes.</code> followed by a self defined
+ * identifier.
+ * </p>
+ */
+ protected void forceLoad() {
+ final Iterator i = this.settings.getLoadClasses().iterator();
+ while (i.hasNext()) {
+ final String fqcn = (String) i.next();
+ try {
+ if (this.logger.isDebugEnabled()) {
+ this.logger.debug("Loading class: " + fqcn);
+ }
+ Thread.currentThread().getContextClassLoader().loadClass(fqcn).newInstance();
+ } catch (Exception e) {
+ if (this.logger.isWarnEnabled()) {
+ this.logger.warn("Could not load class: " + fqcn + ". Continuing initialization.", e);
+ }
+ // Do not throw an exception, because it is not a fatal error.
+ }
+ }
+ }
+}
diff --git a/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/java/org/apache/cocoon/spring/configurator/impl/SettingsElementParser.java b/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/java/org/apache/cocoon/spring/configurator/impl/SettingsElementParser.java
new file mode 100644
index 0000000..d591dc6
--- /dev/null
+++ b/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/java/org/apache/cocoon/spring/configurator/impl/SettingsElementParser.java
@@ -0,0 +1,140 @@
+/*
+ * 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.cocoon.spring.configurator.impl;
+
+import java.util.List;
+import java.util.Properties;
+
+import javax.servlet.ServletContext;
+
+import org.apache.cocoon.configuration.Settings;
+import org.apache.cocoon.spring.configurator.ResourceFilter;
+import org.springframework.beans.factory.support.RootBeanDefinition;
+import org.springframework.beans.factory.xml.ParserContext;
+import org.w3c.dom.Element;
+
+/**
+ * Add a bean definition for the settings object to the bean factory.
+ *
+ * @see ConfiguratorNamespaceHandler
+ * @see SettingsBeanFactoryPostProcessor
+ * @version $Id$
+ * @since 1.0
+ */
+public class SettingsElementParser extends AbstractSettingsElementParser {
+
+ /** The name of the configuration attribute to specify the running mode. */
+ public static final String RUNNING_MODE_ATTR = "runningMode";
+
+ /** The name of the configuration attribute to specify if configurations are read from the classpath. */
+ public static final String READ_FROM_CLASSPATH_ATTR = "readFromClasspath";
+
+ /** The name of the configuration attribute to specify if configurations are read from the global location. */
+ public static final String READ_FROM_GLOBAL_LOCATION_ATTR = "readFromGlobalLocation";
+
+ /**
+ * Create and register the settings bean factory post processor.
+ */
+ protected void createSettingsBeanFactoryPostProcessor(Element element, ParserContext parserContext,
+ String runningMode) {
+ // create bean definition for settings object
+ final RootBeanDefinition beanDef = this.createBeanDefinition(SettingsBeanFactoryPostProcessor.class.getName(),
+ "init", false);
+
+ //pass resource filter
+ final ResourceFilter resourceFilter = getResourceFilter();
+ if (resourceFilter != null) {
+ beanDef.getPropertyValues().addPropertyValue("resourceFilter", resourceFilter);
+ }
+ // add additional properties
+ final Properties additionalProps = this.getAdditionalProperties(element);
+ if (additionalProps != null) {
+ beanDef.getPropertyValues().addPropertyValue("additionalProperties", additionalProps);
+ }
+
+ // add additional property directories
+ final List propertiesIncludes = this.getPropertyIncludes(element);
+ if (propertiesIncludes != null) {
+ beanDef.getPropertyValues().addPropertyValue("directories", propertiesIncludes);
+ }
+
+ // check for boolean settings
+ final Boolean readFromClasspath = Boolean.valueOf(this.getAttributeValue(element, READ_FROM_CLASSPATH_ATTR,
+ "true"));
+ final Boolean readFromGlobalLocation = Boolean.valueOf(this.getAttributeValue(element,
+ READ_FROM_GLOBAL_LOCATION_ATTR, "true"));
+
+ beanDef.getPropertyValues().addPropertyValue(READ_FROM_CLASSPATH_ATTR, readFromClasspath);
+ beanDef.getPropertyValues().addPropertyValue(READ_FROM_GLOBAL_LOCATION_ATTR, readFromGlobalLocation);
+
+ // if running mode is specified add it as a property
+ if (runningMode != null) {
+ beanDef.getPropertyValues().addPropertyValue(RUNNING_MODE_ATTR, runningMode);
+ }
+
+ // register settings bean
+ this.register(beanDef, Settings.ROLE, parserContext.getRegistry());
+ }
+
+ /**
+ * @see org.apache.cocoon.spring.configurator.impl.AbstractSettingsElementParser#getRunningMode(org.w3c.dom.Element)
+ */
+ protected String getRunningMode(Element e) {
+ return RunningModeHelper.determineRunningMode(this.getAttributeValue(e, RUNNING_MODE_ATTR, null));
+ }
+
+ /**
+ * @see org.apache.cocoon.spring.configurator.impl.AbstractSettingsElementParser#getBeanIncludes(org.w3c.dom.Element)
+ */
+ protected List getBeanIncludes(Element settingsElement) {
+ final List includes = super.getBeanIncludes(settingsElement);
+ final boolean readFromClasspath = Boolean.valueOf(
+ this.getAttributeValue(settingsElement, READ_FROM_CLASSPATH_ATTR, "true")).booleanValue();
+ if (readFromClasspath) {
+ includes.add(0, Constants.CLASSPATH_SPRING_CONFIGURATION_LOCATION);
+ }
+ return includes;
+ }
+
+ /**
+ * @see org.apache.cocoon.spring.configurator.impl.AbstractSettingsElementParser#getBeanPropertyOverrideIncludes(org.w3c.dom.Element)
+ */
+ protected List getBeanPropertyOverrideIncludes(Element settingsElement) {
+ final List includes = super.getBeanPropertyOverrideIncludes(settingsElement);
+ final boolean readFromClasspath = Boolean.valueOf(
+ this.getAttributeValue(settingsElement, READ_FROM_CLASSPATH_ATTR, "true")).booleanValue();
+ final boolean readFromGlobalLocation = Boolean.valueOf(
+ this.getAttributeValue(settingsElement, READ_FROM_GLOBAL_LOCATION_ATTR, "true")).booleanValue();
+ if (readFromGlobalLocation) {
+ int pos = (readFromClasspath ? 1 : 0);
+ includes.add(pos, Constants.GLOBAL_SPRING_CONFIGURATION_LOCATION);
+ }
+ return includes;
+ }
+
+ /**
+ * @see org.apache.cocoon.spring.configurator.impl.AbstractSettingsElementParser#registerComponents(org.w3c.dom.Element,
+ * org.springframework.beans.factory.xml.ParserContext)
+ */
+ protected void registerComponents(Element settingsElement, ParserContext parserContext) {
+ super.registerComponents(settingsElement, parserContext);
+ // add the servlet context as a bean
+ this.addComponent(ServletContextFactoryBean.class.getName(), ServletContext.class.getName(), null, false,
+ parserContext.getRegistry());
+
+ }
+}
diff --git a/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/java/org/apache/cocoon/spring/configurator/impl/SettingsProperties.java b/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/java/org/apache/cocoon/spring/configurator/impl/SettingsProperties.java
new file mode 100644
index 0000000..9e19647
--- /dev/null
+++ b/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/java/org/apache/cocoon/spring/configurator/impl/SettingsProperties.java
@@ -0,0 +1,59 @@
+/*
+ * 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.cocoon.spring.configurator.impl;
+
+import java.util.Properties;
+
+import org.apache.cocoon.configuration.Settings;
+
+/**
+ * A properties implementation using the settings object.
+ * @since 1.0
+ * @version $Id$
+ */
+public class SettingsProperties extends Properties {
+
+ /** A reference to the settings beans. */
+ protected final Settings settings;
+
+ /**
+ * Constructor for this properties object.
+ * @param s The settings object.
+ */
+ public SettingsProperties(Settings s) {
+ this.settings = s;
+ }
+
+ /**
+ * @param key The name of the property.
+ * @param defaultValue The default value of the property.
+ * @return The value of the property or the default value.
+ * @see java.util.Properties#getProperty(java.lang.String, java.lang.String)
+ */
+ public String getProperty(String key, String defaultValue) {
+ return this.settings.getProperty(key, defaultValue);
+ }
+
+ /**
+ * @param key The name of the property.
+ * @return The value of the property or null.
+ * @see java.util.Properties#getProperty(java.lang.String)
+ */
+ public String getProperty(String key) {
+ return this.settings.getProperty(key);
+ }
+}
diff --git a/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/java/org/apache/cocoon/spring/configurator/impl/WildcardBeanMap.java b/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/java/org/apache/cocoon/spring/configurator/impl/WildcardBeanMap.java
new file mode 100644
index 0000000..cd0a71a
--- /dev/null
+++ b/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/java/org/apache/cocoon/spring/configurator/impl/WildcardBeanMap.java
@@ -0,0 +1,69 @@
+/*
+ * 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.cocoon.spring.configurator.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.springframework.beans.factory.BeanFactory;
+import org.springframework.beans.factory.ListableBeanFactory;
+import org.springframework.util.PatternMatchUtils;
+
+/**
+ * Similar to the {@link BeanMap} it collects beans from a {@link BeanFactory}. But instead of
+ * checking the type of the bean, its bean name is matched against a wildcard expression (e.g.
+ * <code>some.beans.*</code>).
+ *
+ * @see BeanMap
+ */
+public class WildcardBeanMap extends BeanMap {
+
+ protected String wildcard;
+
+ public String getWildcard() {
+ return this.wildcard;
+ }
+
+ public void setWildcard(String wildcard) {
+ this.wildcard = wildcard;
+ }
+
+ /**
+ * Find all beans that match the wildcard expression. Expression resolving is done based on the
+ * default Spring wildcard pattern matching
+ * {@link PatternMatchUtils#simpleMatch(String, String)}.
+ *
+ * @see org.apache.cocoon.spring.configurator.impl.BeanMap#lookupBeans(org.springframework.beans.factory.ListableBeanFactory)
+ */
+ @Override
+ protected String[] lookupBeans(ListableBeanFactory factory) {
+ List<String> filteredBeanNames = new ArrayList<String>();
+
+ for (String beanName : factory.getBeanNamesForType(null)) {
+ if (PatternMatchUtils.simpleMatch(this.wildcard, beanName)) {
+ filteredBeanNames.add(beanName);
+ }
+ }
+
+ return filteredBeanNames.toArray(new String[0]);
+ }
+
+ @Override
+ protected Object stripPrefix(String beanName) {
+ return beanName;
+ }
+}
diff --git a/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/java/org/apache/cocoon/spring/configurator/impl/WildcardBeanMapElementParser.java b/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/java/org/apache/cocoon/spring/configurator/impl/WildcardBeanMapElementParser.java
new file mode 100644
index 0000000..375c99b
--- /dev/null
+++ b/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/java/org/apache/cocoon/spring/configurator/impl/WildcardBeanMapElementParser.java
@@ -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.cocoon.spring.configurator.impl;
+
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.support.RootBeanDefinition;
+import org.springframework.beans.factory.xml.ParserContext;
+import org.w3c.dom.Element;
+
+/**
+ * The parser for the wildcard-bean-map element.
+ *
+ * @version $Id$
+ * @since 1.0.1
+ */
+public class WildcardBeanMapElementParser extends BeanMapElementParser {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.apache.cocoon.spring.configurator.impl.BeanMapElementParser#parse(org.w3c.dom.Element,
+ * org.springframework.beans.factory.xml.ParserContext)
+ */
+ @Override
+ public BeanDefinition parse(Element element, ParserContext parserContext) {
+ // create a new bean definition for the aspect chain
+ RootBeanDefinition beanDef = this.createBeanDefinition(WildcardBeanMap.class, null, false);
+ beanDef.getPropertyValues().addPropertyValue("wildcard", this.getAttributeValue(element, "wildcard", null));
+ beanDef.getPropertyValues().addPropertyValue("checkParent",
+ this.getAttributeValue(element, "check-parent", "true"));
+ beanDef.getPropertyValues().addPropertyValue("hasProperties",
+ this.getAttributeValue(element, "has-properties", ""));
+ beanDef.getPropertyValues()
+ .addPropertyValue("keyProperty", this.getAttributeValue(element, "key-property", ""));
+
+ // register bean if it's a global definition
+ if (!parserContext.isNested()) {
+ this.register(beanDef, element, parserContext.getRegistry());
+ }
+ return beanDef;
+ }
+}
diff --git a/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/java/org/apache/cocoon/spring/configurator/log4j/Log4JConfigurator.java b/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/java/org/apache/cocoon/spring/configurator/log4j/Log4JConfigurator.java
new file mode 100644
index 0000000..0678470
--- /dev/null
+++ b/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/java/org/apache/cocoon/spring/configurator/log4j/Log4JConfigurator.java
@@ -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.cocoon.spring.configurator.log4j;
+
+import org.apache.cocoon.configuration.PropertyHelper;
+import org.apache.cocoon.configuration.Settings;
+import org.apache.log4j.LogManager;
+import org.apache.log4j.xml.DOMConfigurator;
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.core.io.Resource;
+
+/**
+ * This is a configurator for log4j that supports variable substitution
+ * from the settings object.
+ *
+ * @since 1.0
+ * @version $Id$
+ */
+public class Log4JConfigurator extends DOMConfigurator
+ implements InitializingBean {
+
+ /** The settings object that is used to substitute variable values. */
+ protected Settings settings;
+
+ /** The configuration resources. */
+ protected Resource resource;
+
+ /**
+ * Inject the settings object.
+ * @param s The settings bean.
+ */
+ public void setSettings(final Settings s) {
+ this.settings = s;
+ }
+
+ /**
+ * Set the configuration resource.
+ * @param r The resource.
+ */
+ public void setResource(final Resource r) {
+ this.resource = r;
+ }
+
+ /**
+ * This method is called after the instance is setup and before it is used.
+ * @throws Exception If anything during configuration goes wrong an exception is thrown.
+ * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
+ */
+ public void afterPropertiesSet() throws Exception {
+ doConfigure(this.resource.getInputStream(), LogManager.getLoggerRepository());
+ }
+
+ /**
+ * Substitute variables in the string value.
+ *
+ * @param value The value which might contain variable references.
+ * @return The new value without variables (if defined).
+ * @see org.apache.log4j.xml.DOMConfigurator#subst(java.lang.String)
+ */
+ protected String subst(final String value) {
+ return PropertyHelper.replace(value, this.settings);
+ }
+}
diff --git a/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/resources/META-INF/spring.handlers b/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/resources/META-INF/spring.handlers
new file mode 100644
index 0000000..14548fa
--- /dev/null
+++ b/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/resources/META-INF/spring.handlers
@@ -0,0 +1,16 @@
+# 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.
+#
+http\://cocoon.apache.org/schema/configurator=org.apache.cocoon.spring.configurator.impl.ConfiguratorNamespaceHandler
diff --git a/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/resources/META-INF/spring.schemas b/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/resources/META-INF/spring.schemas
new file mode 100644
index 0000000..229f947
--- /dev/null
+++ b/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/resources/META-INF/spring.schemas
@@ -0,0 +1,19 @@
+# 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.
+#
+http\://cocoon.apache.org/schema/configurator/cocoon-configurator-1.0.xsd=org/apache/cocoon/spring/configurator/schema/cocoon-configurator-1.0.xsd
+http\://cocoon.apache.org/schema/configurator/cocoon-configurator-1.0.1.xsd=org/apache/cocoon/spring/configurator/schema/cocoon-configurator-1.0.1.xsd
+http\://cocoon.apache.org/schema/configurator/cocoon-configurator-2.0.0.xsd=org/apache/cocoon/spring/configurator/schema/cocoon-configurator-2.0.0.xsd
+http\://cocoon.apache.org/schema/configurator/cocoon-configurator-2.1.0.xsd=org/apache/cocoon/spring/configurator/schema/cocoon-configurator-2.1.0.xsd
\ No newline at end of file
diff --git a/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/resources/org/apache/cocoon/spring/configurator/schema/cocoon-configurator-1.0.1.xsd b/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/resources/org/apache/cocoon/spring/configurator/schema/cocoon-configurator-1.0.1.xsd
new file mode 100644
index 0000000..38e20bf
--- /dev/null
+++ b/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/resources/org/apache/cocoon/spring/configurator/schema/cocoon-configurator-1.0.1.xsd
@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+
+<!--
+ - $Id$
+ -->
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://cocoon.apache.org/schema/configurator"
+ xmlns:tns="http://cocoon.apache.org/schema/configurator"
+ xmlns="http://cocoon.apache.org/schema/configurator">
+
+ <xsd:element name="settings">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="include-beans" minOccurs="0" maxOccurs="unbounded"/>
+ <xsd:element ref="include-properties" minOccurs="0" maxOccurs="unbounded"/>
+ <xsd:element ref="property" minOccurs="0" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ <xsd:attribute name="runningMode" type="xsd:string" use="optional"/>
+ <xsd:attribute name="readFromClasspath" type="xsd:boolean" use="optional"/>
+ <xsd:attribute name="readFromGlobalLocation" type="xsd:boolean" use="optional"/>
+ <xsd:attribute name="extractBlockResources" type="xsd:boolean" use="optional"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="child-settings">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="include-beans" minOccurs="0" maxOccurs="unbounded"/>
+ <xsd:element ref="include-properties" minOccurs="0" maxOccurs="unbounded"/>
+ <xsd:element ref="property" minOccurs="0" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="include-beans">
+ <xsd:complexType>
+ <xsd:attribute name="dir" type="xsd:string" use="optional"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="include-properties">
+ <xsd:complexType>
+ <xsd:attribute name="dir" type="xsd:string" use="required"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="property">
+ <xsd:complexType>
+ <xsd:attribute name="name" type="xsd:string" use="required"/>
+ <xsd:attribute name="value" type="xsd:string" use="required"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <!--
+ - Since 1.0.1:
+ -->
+ <xsd:element name="bean-map">
+ <xsd:complexType>
+ <xsd:attribute name="id" type="xsd:ID" use="optional"/>
+ <xsd:attribute name="name" type="xsd:string" use="optional"/>
+ <xsd:attribute name="type" type="xsd:string" use="required"/>
+ <xsd:attribute name="check-parent" type="xsd:boolean" use="optional" default="true"/>
+ <xsd:attribute name="strip-prefix" type="xsd:boolean" use="optional" default="true"/>
+ <xsd:attribute name="has-properties" type="xsd:string" use="optional" default="">
+ <xsd:annotation>
+ <xsd:documentation>beans should have all these properties (comma separated list)</xsd:documentation>
+ </xsd:annotation>
+ </xsd:attribute>
+ <xsd:attribute name="key-property" type="xsd:string" use="optional" default="">
+ <xsd:annotation>
+ <xsd:documentation>use value of this bean property to key the map instead of bean id</xsd:documentation>
+ </xsd:annotation>
+ </xsd:attribute>
+ </xsd:complexType>
+ </xsd:element>
+</xsd:schema>
diff --git a/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/resources/org/apache/cocoon/spring/configurator/schema/cocoon-configurator-1.0.xsd b/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/resources/org/apache/cocoon/spring/configurator/schema/cocoon-configurator-1.0.xsd
new file mode 100644
index 0000000..98ed0b5
--- /dev/null
+++ b/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/resources/org/apache/cocoon/spring/configurator/schema/cocoon-configurator-1.0.xsd
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+
+<!--
+ - $Id$
+ -->
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://cocoon.apache.org/schema/configurator"
+ xmlns:tns="http://cocoon.apache.org/schema/configurator"
+ xmlns="http://cocoon.apache.org/schema/configurator">
+
+ <xsd:element name="settings">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="include-beans" minOccurs="0" maxOccurs="unbounded"/>
+ <xsd:element ref="include-properties" minOccurs="0" maxOccurs="unbounded"/>
+ <xsd:element ref="property" minOccurs="0" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ <xsd:attribute name="runningMode" type="xsd:string" use="optional"/>
+ <xsd:attribute name="readFromClasspath" type="xsd:boolean" use="optional"/>
+ <xsd:attribute name="readFromGlobalLocation" type="xsd:boolean" use="optional"/>
+ <xsd:attribute name="extractBlockResources" type="xsd:boolean" use="optional"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="child-settings">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="include-beans" minOccurs="0" maxOccurs="unbounded"/>
+ <xsd:element ref="include-properties" minOccurs="0" maxOccurs="unbounded"/>
+ <xsd:element ref="property" minOccurs="0" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="include-beans">
+ <xsd:complexType>
+ <xsd:attribute name="dir" type="xsd:string" use="optional"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="include-properties">
+ <xsd:complexType>
+ <xsd:attribute name="dir" type="xsd:string" use="required"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="property">
+ <xsd:complexType>
+ <xsd:attribute name="name" type="xsd:string" use="required"/>
+ <xsd:attribute name="value" type="xsd:string" use="required"/>
+ </xsd:complexType>
+ </xsd:element>
+
+</xsd:schema>
diff --git a/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/resources/org/apache/cocoon/spring/configurator/schema/cocoon-configurator-2.0.0.xsd b/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/resources/org/apache/cocoon/spring/configurator/schema/cocoon-configurator-2.0.0.xsd
new file mode 100644
index 0000000..50f5fb6
--- /dev/null
+++ b/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/resources/org/apache/cocoon/spring/configurator/schema/cocoon-configurator-2.0.0.xsd
@@ -0,0 +1,95 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<!-- $Id$ -->
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://cocoon.apache.org/schema/configurator"
+ xmlns:tns="http://cocoon.apache.org/schema/configurator"
+ xmlns="http://cocoon.apache.org/schema/configurator">
+
+ <xsd:element name="settings">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="include-beans" minOccurs="0" maxOccurs="unbounded"/>
+ <xsd:element ref="include-properties" minOccurs="0" maxOccurs="unbounded"/>
+ <xsd:element ref="filter" minOccurs="0" maxOccurs="1"/>
+ <xsd:element ref="property" minOccurs="0" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ <xsd:attribute name="runningMode" type="xsd:string" use="optional"/>
+ <xsd:attribute name="readFromClasspath" type="xsd:boolean" use="optional"/>
+ <xsd:attribute name="readFromGlobalLocation" type="xsd:boolean" use="optional"/>
+ <xsd:attribute name="extractBlockResources" type="xsd:boolean" use="optional"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="child-settings">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="include-beans" minOccurs="0" maxOccurs="unbounded"/>
+ <xsd:element ref="include-properties" minOccurs="0" maxOccurs="unbounded"/>
+ <xsd:element ref="property" minOccurs="0" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="include-beans">
+ <xsd:complexType>
+ <xsd:attribute name="dir" type="xsd:string" use="optional"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="include-properties">
+ <xsd:complexType>
+ <xsd:attribute name="dir" type="xsd:string" use="required"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="filter">
+ <xsd:complexType>
+ <xsd:attribute name="class" type="xsd:string" use="required"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="property">
+ <xsd:complexType>
+ <xsd:attribute name="name" type="xsd:string" use="required"/>
+ <xsd:attribute name="value" type="xsd:string" use="required"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <!-- Since 1.0.1 -->
+ <xsd:element name="bean-map">
+ <xsd:complexType>
+ <xsd:attribute name="id" type="xsd:ID" use="optional"/>
+ <xsd:attribute name="name" type="xsd:string" use="optional"/>
+ <xsd:attribute name="type" type="xsd:string" use="required"/>
+ <xsd:attribute name="check-parent" type="xsd:boolean" use="optional" default="true"/>
+ <xsd:attribute name="strip-prefix" type="xsd:boolean" use="optional" default="true"/>
+ <xsd:attribute name="has-properties" type="xsd:string" use="optional" default="">
+ <xsd:annotation>
+ <xsd:documentation>beans should have all these properties (comma separated list)</xsd:documentation>
+ </xsd:annotation>
+ </xsd:attribute>
+ <xsd:attribute name="key-property" type="xsd:string" use="optional" default="">
+ <xsd:annotation>
+ <xsd:documentation>use value of this bean property to key the map instead of bean id</xsd:documentation>
+ </xsd:annotation>
+ </xsd:attribute>
+ </xsd:complexType>
+ </xsd:element>
+</xsd:schema>
diff --git a/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/resources/org/apache/cocoon/spring/configurator/schema/cocoon-configurator-2.1.0.xsd b/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/resources/org/apache/cocoon/spring/configurator/schema/cocoon-configurator-2.1.0.xsd
new file mode 100644
index 0000000..ced3d67
--- /dev/null
+++ b/cocoon-spring-configurator/cocoon-spring-configurator-2.1.0/src/main/resources/org/apache/cocoon/spring/configurator/schema/cocoon-configurator-2.1.0.xsd
@@ -0,0 +1,116 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<!-- $Id$ -->
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://cocoon.apache.org/schema/configurator"
+ xmlns:tns="http://cocoon.apache.org/schema/configurator"
+ xmlns="http://cocoon.apache.org/schema/configurator">
+
+ <xsd:element name="settings">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="include-beans" minOccurs="0" maxOccurs="unbounded"/>
+ <xsd:element ref="include-properties" minOccurs="0" maxOccurs="unbounded"/>
+ <xsd:element ref="filter" minOccurs="0" maxOccurs="1"/>
+ <xsd:element ref="property" minOccurs="0" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ <xsd:attribute name="runningMode" type="xsd:string" use="optional"/>
+ <xsd:attribute name="readFromClasspath" type="xsd:boolean" use="optional"/>
+ <xsd:attribute name="readFromGlobalLocation" type="xsd:boolean" use="optional"/>
+ <xsd:attribute name="extractBlockResources" type="xsd:boolean" use="optional"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="child-settings">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="include-beans" minOccurs="0" maxOccurs="unbounded"/>
+ <xsd:element ref="include-properties" minOccurs="0" maxOccurs="unbounded"/>
+ <xsd:element ref="property" minOccurs="0" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="include-beans">
+ <xsd:complexType>
+ <xsd:attribute name="dir" type="xsd:string" use="optional"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="include-properties">
+ <xsd:complexType>
+ <xsd:attribute name="dir" type="xsd:string" use="required"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="filter">
+ <xsd:complexType>
+ <xsd:attribute name="class" type="xsd:string" use="required"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="property">
+ <xsd:complexType>
+ <xsd:attribute name="name" type="xsd:string" use="required"/>
+ <xsd:attribute name="value" type="xsd:string" use="required"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <!-- Since 1.0.1 -->
+ <xsd:element name="bean-map">
+ <xsd:complexType>
+ <xsd:attribute name="id" type="xsd:ID" use="optional"/>
+ <xsd:attribute name="name" type="xsd:string" use="optional"/>
+ <xsd:attribute name="type" type="xsd:string" use="required"/>
+ <xsd:attribute name="check-parent" type="xsd:boolean" use="optional" default="true"/>
+ <xsd:attribute name="strip-prefix" type="xsd:boolean" use="optional" default="true"/>
+ <xsd:attribute name="has-properties" type="xsd:string" use="optional" default="">
+ <xsd:annotation>
+ <xsd:documentation>beans should have all these properties (comma separated list)</xsd:documentation>
+ </xsd:annotation>
+ </xsd:attribute>
+ <xsd:attribute name="key-property" type="xsd:string" use="optional" default="">
+ <xsd:annotation>
+ <xsd:documentation>use value of this bean property to key the map instead of bean id</xsd:documentation>
+ </xsd:annotation>
+ </xsd:attribute>
+ </xsd:complexType>
+ </xsd:element>
+
+
+ <!-- Since 2.0.1 -->
+ <xsd:element name="wildcard-bean-map">
+ <xsd:complexType>
+ <xsd:attribute name="id" type="xsd:ID" use="optional"/>
+ <xsd:attribute name="name" type="xsd:string" use="optional"/>
+ <xsd:attribute name="wildcard" type="xsd:string" use="required"/>
+ <xsd:attribute name="check-parent" type="xsd:boolean" use="optional" default="true"/>
+ <xsd:attribute name="has-properties" type="xsd:string" use="optional" default="">
+ <xsd:annotation>
+ <xsd:documentation>beans should have all these properties (comma separated list)</xsd:documentation>
+ </xsd:annotation>
+ </xsd:attribute>
+ <xsd:attribute name="key-property" type="xsd:string" use="optional" default="">
+ <xsd:annotation>
+ <xsd:documentation>use value of this bean property to key the map instead of bean id</xsd:documentation>
+ </xsd:annotation>
+ </xsd:attribute>
+ </xsd:complexType>
+ </xsd:element>
+</xsd:schema>