[COCOON-2347] Merge to trunk from BRANCH_2_2_COCOON-2347 - thanks Gabriel Gruber @ggruber4711
git-svn-id: https://svn.apache.org/repos/asf/cocoon/trunk@1828354 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/blocks/cocoon-flowscript/cocoon-flowscript-impl/src/main/java/org/apache/cocoon/components/flow/javascript/ScriptablePropertyPointer.java b/blocks/cocoon-flowscript/cocoon-flowscript-impl/src/main/java/org/apache/cocoon/components/flow/javascript/ScriptablePropertyPointer.java
index 8c3cc94..fb2a3be 100644
--- a/blocks/cocoon-flowscript/cocoon-flowscript-impl/src/main/java/org/apache/cocoon/components/flow/javascript/ScriptablePropertyPointer.java
+++ b/blocks/cocoon-flowscript/cocoon-flowscript-impl/src/main/java/org/apache/cocoon/components/flow/javascript/ScriptablePropertyPointer.java
@@ -160,7 +160,7 @@
return buffer.toString();
}
- private String escape(String string){
+ protected String escape(String string){
int index = string.indexOf('\'');
while (index != -1){
string = string.substring(0, index) + "'" + string.substring(index + 1);
diff --git a/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/spring/AspectsBeanDefinitionParser.java b/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/spring/AspectsBeanDefinitionParser.java
index d863030..711ab6e 100644
--- a/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/spring/AspectsBeanDefinitionParser.java
+++ b/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/spring/AspectsBeanDefinitionParser.java
@@ -92,7 +92,7 @@
}
}
try {
- beanDef.getConstructorArgumentValues().addIndexedArgumentValue(0, ClassUtils.forName(this.baseClass));
+ beanDef.getConstructorArgumentValues().addIndexedArgumentValue(0, ClassUtils.forName(this.baseClass, getClass().getClassLoader()));
} catch (ClassNotFoundException e) {
throw new BeanDefinitionStoreException("Unable to load aspect class: " + this.baseClass, e);
}
@@ -105,7 +105,7 @@
List aliases = new ArrayList();
if (StringUtils.hasLength(nameAttr)) {
- String[] nameArr = StringUtils.tokenizeToStringArray(nameAttr, BeanDefinitionParserDelegate.BEAN_NAME_DELIMITERS);
+ String[] nameArr = StringUtils.tokenizeToStringArray(nameAttr, BeanDefinitionParserDelegate.MULTI_VALUE_ATTRIBUTE_DELIMITERS);
aliases.addAll(Arrays.asList(nameArr));
}
diff --git a/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/formatDate-output.xml b/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/formatDate-output.xml
index 7438420..5b1b334 100644
--- a/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/formatDate-output.xml
+++ b/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/formatDate-output.xml
@@ -16,6 +16,6 @@
limitations under the License.
-->
<root xmlns:jx="http://apache.org/cocoon/templates/jx/1.0">
- <date locale="pl_PL">01 styczeń 1979</date>
+ <date locale="de_DE">01 Januar 1979</date>
<date locale="sv_SE">01 januari 1979</date>
</root>
diff --git a/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/formatDate.xml b/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/formatDate.xml
index 4c1685e..cb1fb78 100644
--- a/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/formatDate.xml
+++ b/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/formatDate.xml
@@ -16,6 +16,6 @@
limitations under the License.
-->
<root xmlns:jx="http://apache.org/cocoon/templates/jx/1.0">
- <date locale="pl_PL"><jx:formatDate value="${date}" pattern="dd MMMM yyyy" locale="pl_PL"/></date>
+ <date locale="de_DE"><jx:formatDate value="${date}" pattern="dd MMMM yyyy" locale="de_DE"/></date>
<date locale="sv_SE"><jx:formatDate value="${date}" pattern="dd MMMM yyyy" locale="sv_SE"/></date>
</root>
diff --git a/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxAttribute-output.xml b/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxAttribute-output.xml
index c204742..c3f9ca2 100644
--- a/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxAttribute-output.xml
+++ b/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxAttribute-output.xml
@@ -21,5 +21,5 @@
<three foo="bar" foo2="bar2" dd="dd">
<abc>def</abc>
</three>
- <nestedjx value="01 styczeń 1979"/>
+ <nestedjx value="01 Januar 1979"/>
</root>
diff --git a/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxAttribute.xml b/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxAttribute.xml
index 7b150c5..2a87cdd 100644
--- a/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxAttribute.xml
+++ b/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxAttribute.xml
@@ -30,6 +30,6 @@
<abc>def</abc>
</three>
<nestedjx>
- <jx:attribute name="value"><jx:formatDate value="${date}" pattern="dd MMMM yyyy" locale="pl_PL"/></jx:attribute>
+ <jx:attribute name="value"><jx:formatDate value="${date}" pattern="dd MMMM yyyy" locale="de_DE"/></jx:attribute>
</nestedjx>
</root>
diff --git a/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxElement-output.xml b/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxElement-output.xml
index c4503a2..fb3d54e 100644
--- a/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxElement-output.xml
+++ b/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxElement-output.xml
@@ -1,35 +1,35 @@
-<?xml version="1.0"?>
-<!--
- 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.
--->
-<root xmlns:jx="http://apache.org/cocoon/templates/jx/1.0">
- <Empty/>
- <ElementWithValue>value</ElementWithValue>
- <OneFixedValueChildNode><ChildNode>Test</ChildNode></OneFixedValueChildNode>
- <WithChildGeneratedNode><ChildNode>dd</ChildNode></WithChildGeneratedNode>
- <DynamicElement>01 styczeń 1979</DynamicElement>
- <WithAttribute attribute="attr"/>
- <AttributeAndChildNode attribute="attr"><ChildNode>A</ChildNode></AttributeAndChildNode>
- <MixedContent attribute="attr">A<B/></MixedContent>
- <MixedContent2 attribute="attr">A<B/></MixedContent2>
- <EmptyElementWithNamespace xmlns="http://cocoon.apache.org/kamal"/>
- <EmptyElementWithGeneratedNamespace xmlns="http://cocoon.apache.org/kamalbhatt"/>
- <GeneratedElementWithGeneratedChild xmlns="http://cocoon.apache.org/kamalbhatt">
- <GeneratedChild xmlns="http://cocoon.apache.org/kamal">Test</GeneratedChild>
- </GeneratedElementWithGeneratedChild>
- <prefix:ElementWithNamespaceAndHardCodedPrefix xmlns:prefix="http://cocoon.apache.org/kamalbhatt"/>
- <kb:ElementWithNamespaceAndGeneratedPrefix xmlns:kb="http://cocoon.apache.org/kamalbhatt"/>
-</root>
+<?xml version="1.0"?>
+<!--
+ 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.
+-->
+<root xmlns:jx="http://apache.org/cocoon/templates/jx/1.0">
+ <Empty/>
+ <ElementWithValue>value</ElementWithValue>
+ <OneFixedValueChildNode><ChildNode>Test</ChildNode></OneFixedValueChildNode>
+ <WithChildGeneratedNode><ChildNode>dd</ChildNode></WithChildGeneratedNode>
+ <DynamicElement>01 Januar 1979</DynamicElement>
+ <WithAttribute attribute="attr"/>
+ <AttributeAndChildNode attribute="attr"><ChildNode>A</ChildNode></AttributeAndChildNode>
+ <MixedContent attribute="attr">A<B/></MixedContent>
+ <MixedContent2 attribute="attr">A<B/></MixedContent2>
+ <EmptyElementWithNamespace xmlns="http://cocoon.apache.org/kamal"/>
+ <EmptyElementWithGeneratedNamespace xmlns="http://cocoon.apache.org/kamalbhatt"/>
+ <GeneratedElementWithGeneratedChild xmlns="http://cocoon.apache.org/kamalbhatt">
+ <GeneratedChild xmlns="http://cocoon.apache.org/kamal">Test</GeneratedChild>
+ </GeneratedElementWithGeneratedChild>
+ <prefix:ElementWithNamespaceAndHardCodedPrefix xmlns:prefix="http://cocoon.apache.org/kamalbhatt"/>
+ <kb:ElementWithNamespaceAndGeneratedPrefix xmlns:kb="http://cocoon.apache.org/kamalbhatt"/>
+</root>
diff --git a/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxElement.xml b/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxElement.xml
index 98ab317..275537e 100644
--- a/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxElement.xml
+++ b/blocks/cocoon-template/cocoon-template-impl/src/test/resources/org/apache/cocoon/template/jxtg/jxElement.xml
@@ -1,42 +1,42 @@
-<?xml version="1.0"?>
-<!--
- 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.
--->
-<root xmlns:jx="http://apache.org/cocoon/templates/jx/1.0">
- <jx:set var="a" value="dd"/>
- <jx:set var="elem" value="DynamicElement"/>
- <jx:set var="namespace" value="http://cocoon.apache.org/kamalbhatt"/>
- <jx:set var="prefix" value="kb"/>
- <jx:element name="Empty"/>
- <jx:element name="ElementWithValue">value</jx:element>
- <jx:element name="OneFixedValueChildNode"><ChildNode>Test</ChildNode></jx:element>
- <jx:element name="WithChildGeneratedNode"><ChildNode><jx:out value="${a}"/></ChildNode></jx:element>
- <jx:element name="${elem}"><jx:formatDate value="${date}" pattern="dd MMMM yyyy" locale="pl_PL"/></jx:element>
- <jx:element name="WithAttribute"><jx:attribute name="attribute" value="attr"/></jx:element>
- <jx:element name="AttributeAndChildNode">
- <jx:attribute name="attribute" value="attr"/>
- <ChildNode>A</ChildNode>
- </jx:element>
- <jx:element name="MixedContent"><jx:attribute name="attribute" value="attr"/>A<B/></jx:element>
- <jx:element name="MixedContent2">A<jx:attribute name="attribute" value="attr"/><B/></jx:element>
- <jx:element name="EmptyElementWithNamespace" uri="http://cocoon.apache.org/kamal"></jx:element>
- <jx:element name="EmptyElementWithGeneratedNamespace" uri="${namespace}"></jx:element>
- <jx:element name="GeneratedElementWithGeneratedChild" uri="${namespace}">
- <jx:element name="GeneratedChild" uri="http://cocoon.apache.org/kamal">Test</jx:element>
- </jx:element>
- <jx:element name="ElementWithNamespaceAndHardCodedPrefix" uri="${namespace}" prefix="prefix"/>
- <jx:element name="ElementWithNamespaceAndGeneratedPrefix" uri="${namespace}" prefix="${prefix}"/>
-</root>
+<?xml version="1.0"?>
+<!--
+ 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.
+-->
+<root xmlns:jx="http://apache.org/cocoon/templates/jx/1.0">
+ <jx:set var="a" value="dd"/>
+ <jx:set var="elem" value="DynamicElement"/>
+ <jx:set var="namespace" value="http://cocoon.apache.org/kamalbhatt"/>
+ <jx:set var="prefix" value="kb"/>
+ <jx:element name="Empty"/>
+ <jx:element name="ElementWithValue">value</jx:element>
+ <jx:element name="OneFixedValueChildNode"><ChildNode>Test</ChildNode></jx:element>
+ <jx:element name="WithChildGeneratedNode"><ChildNode><jx:out value="${a}"/></ChildNode></jx:element>
+ <jx:element name="${elem}"><jx:formatDate value="${date}" pattern="dd MMMM yyyy" locale="de_DE"/></jx:element>
+ <jx:element name="WithAttribute"><jx:attribute name="attribute" value="attr"/></jx:element>
+ <jx:element name="AttributeAndChildNode">
+ <jx:attribute name="attribute" value="attr"/>
+ <ChildNode>A</ChildNode>
+ </jx:element>
+ <jx:element name="MixedContent"><jx:attribute name="attribute" value="attr"/>A<B/></jx:element>
+ <jx:element name="MixedContent2">A<jx:attribute name="attribute" value="attr"/><B/></jx:element>
+ <jx:element name="EmptyElementWithNamespace" uri="http://cocoon.apache.org/kamal"></jx:element>
+ <jx:element name="EmptyElementWithGeneratedNamespace" uri="${namespace}"></jx:element>
+ <jx:element name="GeneratedElementWithGeneratedChild" uri="${namespace}">
+ <jx:element name="GeneratedChild" uri="http://cocoon.apache.org/kamal">Test</jx:element>
+ </jx:element>
+ <jx:element name="ElementWithNamespaceAndHardCodedPrefix" uri="${namespace}" prefix="prefix"/>
+ <jx:element name="ElementWithNamespaceAndGeneratedPrefix" uri="${namespace}" prefix="${prefix}"/>
+</root>
diff --git a/core/cocoon-expression-language/cocoon-expression-language-api/src/main/java/org/apache/cocoon/el/objectmodel/ObjectModel.java b/core/cocoon-expression-language/cocoon-expression-language-api/src/main/java/org/apache/cocoon/el/objectmodel/ObjectModel.java
index d6e6712..5a123d9 100644
--- a/core/cocoon-expression-language/cocoon-expression-language-api/src/main/java/org/apache/cocoon/el/objectmodel/ObjectModel.java
+++ b/core/cocoon-expression-language/cocoon-expression-language-api/src/main/java/org/apache/cocoon/el/objectmodel/ObjectModel.java
@@ -18,7 +18,7 @@
import java.util.Map;
-import org.apache.commons.collections.MultiMap;
+import org.apache.cocoon.el.util.MultiMap;
/**
* ObjectModel is a special {@link Map} that cannot be modified using standard {@link Map} methods, except
diff --git a/core/cocoon-expression-language/cocoon-expression-language-api/src/main/java/org/apache/cocoon/el/util/MultiMap.java b/core/cocoon-expression-language/cocoon-expression-language-api/src/main/java/org/apache/cocoon/el/util/MultiMap.java
new file mode 100644
index 0000000..c8b9d31
--- /dev/null
+++ b/core/cocoon-expression-language/cocoon-expression-language-api/src/main/java/org/apache/cocoon/el/util/MultiMap.java
@@ -0,0 +1,160 @@
+package org.apache.cocoon.el.util;
+
+/*
+ * Copyright 2001-2004 The Apache Software Foundation
+ *
+ * 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.
+ */
+
+import java.util.Collection;
+import java.util.Map;
+
+/**
+ * Defines a map that holds a collection of values against each key.
+ * <p>
+ * A <code>MultiMap</code> is a Map with slightly different semantics.
+ * Putting a value into the map will add the value to a Collection at that key.
+ * Getting a value will return a Collection, holding all the values put to that key.
+ * <p>
+ * For example:
+ * <pre>
+ * MultiMap mhm = new MultiHashMap();
+ * mhm.put(key, "A");
+ * mhm.put(key, "B");
+ * mhm.put(key, "C");
+ * Collection coll = (Collection) mhm.get(key);</pre>
+ * <p>
+ * <code>coll</code> will be a collection containing "A", "B", "C".
+ * <p>
+ * NOTE: Additional methods were added to this interface in Commons Collections 3.1.
+ * These were added solely for documentation purposes and do not change the interface
+ * as they were defined in the superinterface <code>Map</code> anyway.
+ *
+ * @since Commons Collections 2.0
+ * @version $Revision: 155406 $ $Date: 2005-02-26 12:55:26 +0000 (Sat, 26 Feb 2005) $
+ *
+ * @author Christopher Berry
+ * @author James Strachan
+ * @author Stephen Colebourne
+ */
+public interface MultiMap extends Map {
+
+ /**
+ * Removes a specific value from map.
+ * <p>
+ * The item is removed from the collection mapped to the specified key.
+ * Other values attached to that key are unaffected.
+ * <p>
+ * If the last value for a key is removed, implementations typically
+ * return <code>null</code> from a subsequant <code>get(Object)</code>, however
+ * they may choose to return an empty collection.
+ *
+ * @param key the key to remove from
+ * @param item the item to remove
+ * @return the value removed (which was passed in), null if nothing removed
+ * @throws UnsupportedOperationException if the map is unmodifiable
+ * @throws ClassCastException if the key or value is of an invalid type
+ * @throws NullPointerException if the key or value is null and null is invalid
+ */
+ public boolean remove(Object key, Object item);
+
+ //-----------------------------------------------------------------------
+ /**
+ * Gets the number of keys in this map.
+ * <p>
+ * Implementations typically return only the count of keys in the map
+ * This cannot be mandated due to backwards compatability of this interface.
+ *
+ * @return the number of key-collection mappings in this map
+ */
+ int size();
+
+ /**
+ * Gets the collection of values associated with the specified key.
+ * <p>
+ * The returned value will implement <code>Collection</code>. Implementations
+ * are free to declare that they return <code>Collection</code> subclasses
+ * such as <code>List</code> or <code>Set</code>.
+ * <p>
+ * Implementations typically return <code>null</code> if no values have
+ * been mapped to the key, however the implementation may choose to
+ * return an empty collection.
+ * <p>
+ * Implementations may choose to return a clone of the internal collection.
+ *
+ * @param key the key to retrieve
+ * @return the <code>Collection</code> of values, implementations should
+ * return <code>null</code> for no mapping, but may return an empty collection
+ * @throws ClassCastException if the key is of an invalid type
+ * @throws NullPointerException if the key is null and null keys are invalid
+ */
+ Object get(Object key);
+
+ /**
+ * Checks whether the map contains the value specified.
+ * <p>
+ * Implementations typically check all collections against all keys for the value.
+ * This cannot be mandated due to backwards compatability of this interface.
+ *
+ * @param value the value to search for
+ * @return true if the map contains the value
+ * @throws ClassCastException if the value is of an invalid type
+ * @throws NullPointerException if the value is null and null value are invalid
+ */
+ boolean containsValue(Object value);
+
+ /**
+ * Adds the value to the collection associated with the specified key.
+ * <p>
+ * Unlike a normal <code>Map</code> the previous value is not replaced.
+ * Instead the new value is added to the collection stored against the key.
+ * The collection may be a <code>List</code>, <code>Set</code> or other
+ * collection dependent on implementation.
+ *
+ * @param key the key to store against
+ * @param value the value to add to the collection at the key
+ * @return typically the value added if the map changed and null if the map did not change
+ * @throws UnsupportedOperationException if the map is unmodifiable
+ * @throws ClassCastException if the key or value is of an invalid type
+ * @throws NullPointerException if the key or value is null and null is invalid
+ * @throws IllegalArgumentException if the key or value is invalid
+ */
+ Object put(Object key, Object value);
+
+ /**
+ * Removes all values associated with the specified key.
+ * <p>
+ * Implementations typically return <code>null</code> from a subsequant
+ * <code>get(Object)</code>, however they may choose to return an empty collection.
+ *
+ * @param key the key to remove values from
+ * @return the <code>Collection</code> of values removed, implementations should
+ * return <code>null</code> for no mapping found, but may return an empty collection
+ * @throws UnsupportedOperationException if the map is unmodifiable
+ * @throws ClassCastException if the key is of an invalid type
+ * @throws NullPointerException if the key is null and null keys are invalid
+ */
+ Object remove(Object key);
+
+ /**
+ * Gets a collection containing all the values in the map.
+ * <p>
+ * Inplementations typically return a collection containing the combination
+ * of values from all keys.
+ * This cannot be mandated due to backwards compatability of this interface.
+ *
+ * @return a collection view of the values contained in this map
+ */
+ Collection values();
+
+}
diff --git a/core/cocoon-expression-language/cocoon-expression-language-api/src/main/java/org/apache/cocoon/el/util/MultiValueMap.java b/core/cocoon-expression-language/cocoon-expression-language-api/src/main/java/org/apache/cocoon/el/util/MultiValueMap.java
new file mode 100644
index 0000000..221277c
--- /dev/null
+++ b/core/cocoon-expression-language/cocoon-expression-language-api/src/main/java/org/apache/cocoon/el/util/MultiValueMap.java
@@ -0,0 +1,439 @@
+package org.apache.cocoon.el.util;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation
+ *
+ * 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.
+ */
+import java.util.AbstractCollection;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.commons.collections.Factory;
+import org.apache.commons.collections.FunctorException;
+import org.apache.commons.collections.iterators.EmptyIterator;
+import org.apache.commons.collections.iterators.IteratorChain;
+import org.apache.commons.collections.map.AbstractMapDecorator;
+
+/**
+ * A MultiValueMap decorates another map, allowing it to have
+ * more than one value for a key.
+ * <p>
+ * A <code>MultiMap</code> is a Map with slightly different semantics.
+ * Putting a value into the map will add the value to a Collection at that key.
+ * Getting a value will return a Collection, holding all the values put to that key.
+ * <p>
+ * This implementation is a decorator, allowing any Map implementation
+ * to be used as the base.
+ * <p>
+ * In addition, this implementation allows the type of collection used
+ * for the values to be controlled. By default, an <code>ArrayList</code>
+ * is used, however a <code>Class</code> to instantiate may be specified,
+ * or a factory that returns a <code>Collection</code> instance.
+ * <p>
+ * <strong>Note that MultiValueMap is not synchronized and is not thread-safe.</strong>
+ * If you wish to use this map from multiple threads concurrently, you must use
+ * appropriate synchronization. This class may throw exceptions when accessed
+ * by concurrent threads without synchronization.
+ *
+ * @author James Carman
+ * @author Christopher Berry
+ * @author James Strachan
+ * @author Steve Downey
+ * @author Stephen Colebourne
+ * @author Julien Buret
+ * @author Serhiy Yevtushenko
+ * @version $Revision: 348007 $ $Date: 2005-11-21 22:52:57 +0000 (Mon, 21 Nov 2005) $
+ * @since Commons Collections 3.2
+ */
+public class MultiValueMap extends AbstractMapDecorator implements MultiMap {
+
+ /** The factory for creating value collections. */
+ private final Factory collectionFactory;
+ /** The cached values. */
+ private transient Collection values;
+
+ /**
+ * Creates a map which wraps the given map and
+ * maps keys to ArrayLists.
+ *
+ * @param map the map to wrap
+ */
+ public static MultiValueMap decorate(Map map) {
+ return new MultiValueMap(map, new ReflectionFactory(ArrayList.class));
+ }
+
+ /**
+ * Creates a map which decorates the given <code>map</code> and
+ * maps keys to collections of type <code>collectionClass</code>.
+ *
+ * @param map the map to wrap
+ * @param collectionClass the type of the collection class
+ */
+ public static MultiValueMap decorate(Map map, Class collectionClass) {
+ return new MultiValueMap(map, new ReflectionFactory(collectionClass));
+ }
+
+ /**
+ * Creates a map which decorates the given <code>map</code> and
+ * creates the value collections using the supplied <code>collectionFactory</code>.
+ *
+ * @param map the map to decorate
+ * @param collectionFactory the collection factory (must return a Collection object).
+ */
+ public static MultiValueMap decorate(Map map, Factory collectionFactory) {
+ return new MultiValueMap(map, collectionFactory);
+ }
+
+ //-----------------------------------------------------------------------
+ /**
+ * Creates a MultiValueMap based on a <code>HashMap</code> and
+ * storing the multiple values in an <code>ArrayList</code>.
+ */
+ public MultiValueMap() {
+ this(new HashMap(), new ReflectionFactory(ArrayList.class));
+ }
+
+ /**
+ * Creates a MultiValueMap which decorates the given <code>map</code> and
+ * creates the value collections using the supplied <code>collectionFactory</code>.
+ *
+ * @param map the map to decorate
+ * @param collectionFactory the collection factory which must return a Collection instance
+ */
+ protected MultiValueMap(Map map, Factory collectionFactory) {
+ super(map);
+ if (collectionFactory == null) {
+ throw new IllegalArgumentException("The factory must not be null");
+ }
+ this.collectionFactory = collectionFactory;
+ }
+
+ //-----------------------------------------------------------------------
+ /**
+ * Clear the map.
+ */
+ public void clear() {
+ // If you believe that you have GC issues here, try uncommenting this code
+// Set pairs = getMap().entrySet();
+// Iterator pairsIterator = pairs.iterator();
+// while (pairsIterator.hasNext()) {
+// Map.Entry keyValuePair = (Map.Entry) pairsIterator.next();
+// Collection coll = (Collection) keyValuePair.getValue();
+// coll.clear();
+// }
+ getMap().clear();
+ }
+
+ /**
+ * Removes a specific value from map.
+ * <p>
+ * The item is removed from the collection mapped to the specified key.
+ * Other values attached to that key are unaffected.
+ * <p>
+ * If the last value for a key is removed, <code>null</code> will be returned
+ * from a subsequant <code>get(key)</code>.
+ *
+ * @param key the key to remove from
+ * @param value the value to remove
+ * @return true if something was removed, false if nothing was removed
+ */
+ public boolean remove(Object key, Object value) {
+ Collection valuesForKey = getCollection(key);
+ if (valuesForKey == null) {
+ return false;
+ }
+ boolean removed = valuesForKey.remove(value);
+ if (removed == false) {
+ return false;
+ }
+ if (valuesForKey.isEmpty()) {
+ remove(key);
+ }
+ return true;
+ }
+
+ /**
+ * Checks whether the map contains the value specified.
+ * <p>
+ * This checks all collections against all keys for the value, and thus could be slow.
+ *
+ * @param value the value to search for
+ * @return true if the map contains the value
+ */
+ public boolean containsValue(Object value) {
+ Set pairs = getMap().entrySet();
+ if (pairs == null) {
+ return false;
+ }
+ Iterator pairsIterator = pairs.iterator();
+ while (pairsIterator.hasNext()) {
+ Map.Entry keyValuePair = (Map.Entry) pairsIterator.next();
+ Collection coll = (Collection) keyValuePair.getValue();
+ if (coll.contains(value)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Adds the value to the collection associated with the specified key.
+ * <p>
+ * Unlike a normal <code>Map</code> the previous value is not replaced.
+ * Instead the new value is added to the collection stored against the key.
+ *
+ * @param key the key to store against
+ * @param value the value to add to the collection at the key
+ * @return the value added if the map changed and null if the map did not change
+ */
+ public Object put(Object key, Object value) {
+ boolean result = false;
+ Collection coll = getCollection(key);
+ if (coll == null) {
+ coll = createCollection(1);
+ result = coll.add(value);
+ if (coll.size() > 0) {
+ // only add if non-zero size to maintain class state
+ getMap().put(key, coll);
+ result = false;
+ }
+ } else {
+ result = coll.add(value);
+ }
+ return (result ? value : null);
+ }
+
+ /**
+ * Override superclass to ensure that MultiMap instances are
+ * correctly handled.
+ * <p>
+ * If you call this method with a normal map, each entry is
+ * added using <code>put(Object,Object)</code>.
+ * If you call this method with a multi map, each entry is
+ * added using <code>putAll(Object,Collection)</code>.
+ *
+ * @param map the map to copy (either a normal or multi map)
+ */
+ public void putAll(Map map) {
+ if (map instanceof MultiMap) {
+ for (Iterator it = map.entrySet().iterator(); it.hasNext();) {
+ Map.Entry entry = (Map.Entry) it.next();
+ Collection coll = (Collection) entry.getValue();
+ putAll(entry.getKey(), coll);
+ }
+ } else {
+ for (Iterator it = map.entrySet().iterator(); it.hasNext();) {
+ Map.Entry entry = (Map.Entry) it.next();
+ put(entry.getKey(), entry.getValue());
+ }
+ }
+ }
+
+ /**
+ * Gets a collection containing all the values in the map.
+ * <p>
+ * This returns a collection containing the combination of values from all keys.
+ *
+ * @return a collection view of the values contained in this map
+ */
+ public Collection values() {
+ Collection vs = values;
+ return (vs != null ? vs : (values = new Values()));
+ }
+
+ /**
+ * Checks whether the collection at the specified key contains the value.
+ *
+ * @param value the value to search for
+ * @return true if the map contains the value
+ */
+ public boolean containsValue(Object key, Object value) {
+ Collection coll = getCollection(key);
+ if (coll == null) {
+ return false;
+ }
+ return coll.contains(value);
+ }
+
+ /**
+ * Gets the collection mapped to the specified key.
+ * This method is a convenience method to typecast the result of <code>get(key)</code>.
+ *
+ * @param key the key to retrieve
+ * @return the collection mapped to the key, null if no mapping
+ */
+ public Collection getCollection(Object key) {
+ return (Collection) getMap().get(key);
+ }
+
+ /**
+ * Gets the size of the collection mapped to the specified key.
+ *
+ * @param key the key to get size for
+ * @return the size of the collection at the key, zero if key not in map
+ */
+ public int size(Object key) {
+ Collection coll = getCollection(key);
+ if (coll == null) {
+ return 0;
+ }
+ return coll.size();
+ }
+
+ /**
+ * Adds a collection of values to the collection associated with
+ * the specified key.
+ *
+ * @param key the key to store against
+ * @param values the values to add to the collection at the key, null ignored
+ * @return true if this map changed
+ */
+ public boolean putAll(Object key, Collection values) {
+ if (values == null || values.size() == 0) {
+ return false;
+ }
+ Collection coll = getCollection(key);
+ if (coll == null) {
+ coll = createCollection(values.size());
+ boolean result = coll.addAll(values);
+ if (coll.size() > 0) {
+ // only add if non-zero size to maintain class state
+ getMap().put(key, coll);
+ result = false;
+ }
+ return result;
+ } else {
+ return coll.addAll(values);
+ }
+ }
+
+ /**
+ * Gets an iterator for the collection mapped to the specified key.
+ *
+ * @param key the key to get an iterator for
+ * @return the iterator of the collection at the key, empty iterator if key not in map
+ */
+ public Iterator iterator(Object key) {
+ if (!containsKey(key)) {
+ return EmptyIterator.INSTANCE;
+ } else {
+ return new ValuesIterator(key);
+ }
+ }
+
+ /**
+ * Gets the total size of the map by counting all the values.
+ *
+ * @return the total size of the map counting all values
+ */
+ public int totalSize() {
+ int total = 0;
+ Collection values = getMap().values();
+ for (Iterator it = values.iterator(); it.hasNext();) {
+ Collection coll = (Collection) it.next();
+ total += coll.size();
+ }
+ return total;
+ }
+
+ /**
+ * Creates a new instance of the map value Collection container
+ * using the factory.
+ * <p>
+ * This method can be overridden to perform your own processing
+ * instead of using the factory.
+ *
+ * @param size the collection size that is about to be added
+ * @return the new collection
+ */
+ protected Collection createCollection(int size) {
+ return (Collection) collectionFactory.create();
+ }
+
+ //-----------------------------------------------------------------------
+ /**
+ * Inner class that provides the values view.
+ */
+ private class Values extends AbstractCollection {
+ public Iterator iterator() {
+ final IteratorChain chain = new IteratorChain();
+ for (Iterator it = keySet().iterator(); it.hasNext();) {
+ chain.addIterator(new ValuesIterator(it.next()));
+ }
+ return chain;
+ }
+
+ public int size() {
+ return totalSize();
+ }
+
+ public void clear() {
+ MultiValueMap.this.clear();
+ }
+ }
+
+ /**
+ * Inner class that provides the values iterator.
+ */
+ private class ValuesIterator implements Iterator {
+ private final Object key;
+ private final Collection values;
+ private final Iterator iterator;
+
+ public ValuesIterator(Object key) {
+ this.key = key;
+ this.values = getCollection(key);
+ this.iterator = values.iterator();
+ }
+
+ public void remove() {
+ iterator.remove();
+ if (values.isEmpty()) {
+ MultiValueMap.this.remove(key);
+ }
+ }
+
+ public boolean hasNext() {
+ return iterator.hasNext();
+ }
+
+ public Object next() {
+ return iterator.next();
+ }
+ }
+
+ /**
+ * Inner class that provides a simple reflection factory.
+ */
+ private static class ReflectionFactory implements Factory {
+ private final Class clazz;
+
+ public ReflectionFactory(Class clazz) {
+ this.clazz = clazz;
+ }
+
+ public Object create() {
+ try {
+ return clazz.newInstance();
+ } catch (Exception ex) {
+ throw new FunctorException("Cannot instantiate class: " + clazz, ex);
+ }
+ }
+ }
+
+}
diff --git a/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/java/org/apache/cocoon/el/impl/objectmodel/ObjectModelImpl.java b/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/java/org/apache/cocoon/el/impl/objectmodel/ObjectModelImpl.java
index c5a9839..68bcded 100644
--- a/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/java/org/apache/cocoon/el/impl/objectmodel/ObjectModelImpl.java
+++ b/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/java/org/apache/cocoon/el/impl/objectmodel/ObjectModelImpl.java
@@ -23,15 +23,15 @@
import java.util.ListIterator;
import java.util.Map;
+import org.apache.cocoon.el.util.MultiMap;
+import org.apache.cocoon.el.util.MultiValueMap;
import org.apache.cocoon.el.objectmodel.ObjectModel;
import org.apache.cocoon.el.objectmodel.ObjectModelProvider;
import org.apache.commons.collections.ArrayStack;
import org.apache.commons.collections.KeyValue;
-import org.apache.commons.collections.MultiMap;
import org.apache.commons.collections.iterators.ReverseListIterator;
import org.apache.commons.collections.keyvalue.DefaultKeyValue;
import org.apache.commons.collections.map.AbstractMapDecorator;
-import org.apache.commons.collections.map.MultiValueMap;
import org.apache.commons.jxpath.DynamicPropertyHandler;
import org.apache.commons.jxpath.JXPathBeanInfo;
import org.apache.commons.jxpath.JXPathIntrospector;
diff --git a/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/java/org/apache/cocoon/el/impl/objectmodel/UnmodifiableMultiMap.java b/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/java/org/apache/cocoon/el/impl/objectmodel/UnmodifiableMultiMap.java
index 72ecf86..8183248 100644
--- a/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/java/org/apache/cocoon/el/impl/objectmodel/UnmodifiableMultiMap.java
+++ b/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/java/org/apache/cocoon/el/impl/objectmodel/UnmodifiableMultiMap.java
@@ -20,9 +20,9 @@
import java.util.Map;
import java.util.Set;
+import org.apache.cocoon.el.util.MultiMap;
import org.apache.commons.collections.IterableMap;
import org.apache.commons.collections.MapIterator;
-import org.apache.commons.collections.MultiMap;
import org.apache.commons.collections.Unmodifiable;
import org.apache.commons.collections.collection.UnmodifiableCollection;
import org.apache.commons.collections.iterators.EntrySetMapIterator;
@@ -103,7 +103,7 @@
throw new UnsupportedOperationException();
}
- public Object remove(Object key, Object item) {
+ public boolean remove(Object key, Object item) {
throw new UnsupportedOperationException();
}
diff --git a/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/spring/PipelineComponentScope.java b/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/spring/PipelineComponentScope.java
index a2ec51a..3bb1309 100644
--- a/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/spring/PipelineComponentScope.java
+++ b/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/spring/PipelineComponentScope.java
@@ -22,14 +22,14 @@
/**
* Pipeline component scope that scopes objects per one pipeline component.
- *
+ *
* @version $Id$
* @since 2.2
*/
public final class PipelineComponentScope implements Scope {
-
+
private PipelineComponentScopeHolder holder;
-
+
public PipelineComponentScopeHolder getHolder() {
return holder;
}
@@ -39,16 +39,18 @@
}
/* (non-Javadoc)
- * @see org.springframework.beans.factory.config.Scope#get(java.lang.String, org.springframework.beans.factory.ObjectFactory)
+ * @see org.springframework.beans.factory.config.Scope#get(java.lang.String,
+ * org.springframework.beans.factory.ObjectFactory)
*/
- public Object get(String name, ObjectFactory objectFactory) {
+ @Override
+ public Object get(String name, ObjectFactory<?> objectFactory) {
Object bean = holder.getBeans().get(name);
if (bean == null) {
bean = objectFactory.getObject();
holder.getBeans().put(name, bean);
if (bean instanceof ObjectModel && holder.getInScope()) {
//FIXME: This should be moved to separate BeanPostProcessor
- ((ObjectModel)bean).setParent((ObjectModel)holder.getParentBeans().get(name));
+ ((ObjectModel) bean).setParent((ObjectModel) holder.getParentBeans().get(name));
}
}
return bean;
@@ -57,14 +59,17 @@
/* (non-Javadoc)
* @see org.springframework.beans.factory.config.Scope#getConversationId()
*/
+ @Override
public String getConversationId() {
// There is no conversation id concept for the pipeline component scope
return null;
}
/* (non-Javadoc)
- * @see org.springframework.beans.factory.config.Scope#registerDestructionCallback(java.lang.String, java.lang.Runnable)
+ * @see org.springframework.beans.factory.config.Scope#registerDestructionCallback(java.lang.String,
+ * java.lang.Runnable)
*/
+ @Override
public void registerDestructionCallback(String name, Runnable callback) {
holder.getDestructionCallbacks().put(name, callback);
}
@@ -72,8 +77,9 @@
/* (non-Javadoc)
* @see org.springframework.beans.factory.config.Scope#remove(java.lang.String)
*/
+ @Override
public Object remove(String name) {
- Object bean = holder.getBeans().get(name);
+ Object bean = holder.getBeans().get(name);
if (bean != null) {
holder.getBeans().remove(name);
holder.getDestructionCallbacks().remove(name);
@@ -81,4 +87,8 @@
return bean;
}
+ @Override
+ public Object resolveContextualObject(String key) {
+ return null;
+ }
}
diff --git a/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/spring/PipelineComponentScopeHolder.java b/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/spring/PipelineComponentScopeHolder.java
index c4824a0..1c6870f 100644
--- a/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/spring/PipelineComponentScopeHolder.java
+++ b/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/spring/PipelineComponentScopeHolder.java
@@ -21,24 +21,24 @@
public interface PipelineComponentScopeHolder {
//FIXME: This interface needs redesign
- public Map getBeans();
+ public Map<String, Object> getBeans();
- public void setBeans(Map beans);
-
- public Map getParentBeans();
-
- public void setParentBeans(Map parentBeans);
+ public void setBeans(Map<String, Object> beans);
- public Map getDestructionCallbacks();
+ public Map<String, Object> getParentBeans();
- public void setDestructionCallbacks(Map destructionCallbacks);
-
- public Map getParentDestructionCallbacks();
+ public void setParentBeans(Map<String, Object> parentBeans);
- public void setParentDestructionCallbacks(Map destructionCallbacks);
-
+ public Map<String, Object> getDestructionCallbacks();
+
+ public void setDestructionCallbacks(Map<String, Object> destructionCallbacks);
+
+ public Map<String, Object> getParentDestructionCallbacks();
+
+ public void setParentDestructionCallbacks(Map<String, Object> destructionCallbacks);
+
public void setInScope(boolean inScope);
-
+
public boolean getInScope();
-}
\ No newline at end of file
+}
diff --git a/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/core/container/spring/pipeline/PipelineComponentInfoInitializerDecorator.java b/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/core/container/spring/pipeline/PipelineComponentInfoInitializerDecorator.java
index 6b3a98d..3e22b72 100644
--- a/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/core/container/spring/pipeline/PipelineComponentInfoInitializerDecorator.java
+++ b/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/core/container/spring/pipeline/PipelineComponentInfoInitializerDecorator.java
@@ -23,6 +23,7 @@
import java.util.List;
import org.apache.cocoon.components.pipeline.impl.PipelineComponentInfo;
+import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.BeanDefinitionHolder;
import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
@@ -35,14 +36,14 @@
* @version $Id$
* @since 2.2
*/
-public class PipelineComponentInfoInitializerDecorator implements
- BeanDefinitionDecorator {
-
- private static final String[] EMPTY_STRING_ARRAY = new String[0];
+public class PipelineComponentInfoInitializerDecorator implements BeanDefinitionDecorator {
/* (non-Javadoc)
- * @see org.springframework.beans.factory.xml.BeanDefinitionDecorator#decorate(org.w3c.dom.Node, org.springframework.beans.factory.config.BeanDefinitionHolder, org.springframework.beans.factory.xml.ParserContext)
+ * @see org.springframework.beans.factory.xml.BeanDefinitionDecorator#decorate(org.w3c.dom.Node,
+ * org.springframework.beans.factory.config.BeanDefinitionHolder,
+ * org.springframework.beans.factory.xml.ParserContext)
*/
+ @Override
public BeanDefinitionHolder decorate(Node source, BeanDefinitionHolder holder, ParserContext ctx) {
registerPipelineComponentInfo(ctx);
String initializerBeanName = registerPipelineComponentInfoInitializer(source, holder, ctx);
@@ -52,8 +53,9 @@
private void registerPipelineComponentInfo(ParserContext ctx) {
if (!ctx.getRegistry().containsBeanDefinition(PipelineComponentInfo.ROLE)) {
- BeanDefinitionBuilder defBuilder = BeanDefinitionBuilder.rootBeanDefinition(PipelineComponentInfoFactoryBean.class);
- defBuilder.setSingleton(true);
+ BeanDefinitionBuilder defBuilder = BeanDefinitionBuilder.rootBeanDefinition(
+ PipelineComponentInfoFactoryBean.class);
+ defBuilder.setScope(BeanDefinition.SCOPE_SINGLETON);
defBuilder.setLazyInit(false);
defBuilder.setInitMethodName("init");
ctx.getRegistry().registerBeanDefinition(PipelineComponentInfo.ROLE, defBuilder.getBeanDefinition());
@@ -62,19 +64,29 @@
private String registerPipelineComponentInfoInitializer(Node source, BeanDefinitionHolder holder, ParserContext ctx) {
String componentName = holder.getBeanName();
- String mimeType = ((Element)source).hasAttribute("mime-type") ? ((Element)source).getAttribute("mime-type") : null;
- String label = ((Element)source).hasAttribute("label") ? ((Element)source).getAttribute("label") : null;
- String hint = ((Element)source).hasAttribute("hint") ? ((Element)source).getAttribute("hint") : null;
+ String mimeType = ((Element) source).hasAttribute("mime-type")
+ ? ((Element) source).getAttribute("mime-type")
+ : null;
+ String label = ((Element) source).hasAttribute("label")
+ ? ((Element) source).getAttribute("label")
+ : null;
+ String hint = ((Element) source).hasAttribute("hint")
+ ? ((Element) source).getAttribute("hint")
+ : null;
- BeanDefinitionBuilder initializer = BeanDefinitionBuilder.rootBeanDefinition(PipelineComponentInfoInitializer.class);
+ BeanDefinitionBuilder initializer =
+ BeanDefinitionBuilder.rootBeanDefinition(PipelineComponentInfoInitializer.class);
initializer.addPropertyReference("info", PipelineComponentInfo.ROLE);
initializer.addPropertyValue("componentName", componentName);
- if (mimeType != null)
+ if (mimeType != null) {
initializer.addPropertyValue("mimeType", mimeType);
- if (label != null)
+ }
+ if (label != null) {
initializer.addPropertyValue("label", label);
- if (hint != null)
+ }
+ if (hint != null) {
initializer.addPropertyValue("hint", hint);
+ }
initializer.setInitMethodName("init");
String beanName = componentName + "/info";
@@ -83,15 +95,16 @@
return beanName;
}
- private void createDependencyOnPipelineComponentInfoInitializer(BeanDefinitionHolder holder, String initializerBeanName) {
+ private void createDependencyOnPipelineComponentInfoInitializer(BeanDefinitionHolder holder,
+ String initializerBeanName) {
AbstractBeanDefinition definition = ((AbstractBeanDefinition) holder.getBeanDefinition());
String[] dependsOn = definition.getDependsOn();
if (dependsOn == null) {
- dependsOn = new String[]{initializerBeanName};
+ dependsOn = new String[] { initializerBeanName };
} else {
- List dependencies = new ArrayList(Arrays.asList(dependsOn));
- dependencies.add(initializerBeanName);
- dependsOn = (String[]) dependencies.toArray(EMPTY_STRING_ARRAY);
+ List<String> dependencies = new ArrayList<String>(Arrays.asList(dependsOn));
+ dependencies.add(initializerBeanName);
+ dependsOn = dependencies.toArray(new String[dependencies.size()]);
}
definition.setDependsOn(dependsOn);
}
diff --git a/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/AvalonBeanPostProcessor.java b/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/AvalonBeanPostProcessor.java
index 5021e4b..1e48bfd 100644
--- a/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/AvalonBeanPostProcessor.java
+++ b/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/AvalonBeanPostProcessor.java
@@ -272,4 +272,8 @@
}
ContainerUtil.dispose(bean);
}
+
+ public boolean requiresDestruction(Object bean) {
+ return true;
+ }
}
diff --git a/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/BridgeElementParser.java b/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/BridgeElementParser.java
index e37721b..ae4dbbf 100644
--- a/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/BridgeElementParser.java
+++ b/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/BridgeElementParser.java
@@ -26,12 +26,6 @@
import org.apache.avalon.excalibur.pool.Poolable;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.thread.ThreadSafe;
-import org.springframework.beans.factory.BeanDefinitionStoreException;
-import org.springframework.beans.factory.config.BeanDefinition;
-import org.springframework.beans.factory.config.RuntimeBeanReference;
-import org.springframework.beans.factory.support.*;
-import org.springframework.beans.factory.xml.ParserContext;
-import org.springframework.core.io.ResourceLoader;
import org.apache.cocoon.acting.Action;
import org.apache.cocoon.components.pipeline.ProcessingPipeline;
@@ -49,6 +43,16 @@
import org.apache.cocoon.spring.configurator.impl.AbstractElementParser;
import org.apache.cocoon.transformation.Transformer;
+import org.springframework.beans.factory.support.BeanDefinitionBuilder;
+import org.springframework.beans.factory.support.BeanDefinitionReader;
+import org.springframework.beans.factory.support.BeanDefinitionRegistry;
+import org.springframework.beans.factory.support.RootBeanDefinition;
+import org.springframework.beans.factory.BeanDefinitionStoreException;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.config.RuntimeBeanReference;
+import org.springframework.beans.factory.xml.ParserContext;
+import org.springframework.core.io.ResourceLoader;
+
import org.w3c.dom.Element;
/**
@@ -68,6 +72,7 @@
/**
* @see org.springframework.beans.factory.xml.BeanDefinitionParser#parse(Element, ParserContext)
*/
+ @Override
public BeanDefinition parse(Element element, ParserContext parserContext) {
final ResourceLoader resourceLoader = parserContext.getReaderContext().getReader().getResourceLoader();
@@ -118,12 +123,12 @@
addLogger(registry, info.getRootLogger());
// handle includes of spring configurations
- final Iterator includeIter = info.getImports().iterator();
+ final Iterator<String> includeIter = info.getImports().iterator();
while ( includeIter.hasNext() ) {
if ( reader == null ) {
throw new Exception("Import of spring configuration files not supported. (Reader is null)");
}
- final String uri = (String)includeIter.next();
+ final String uri = includeIter.next();
reader.loadBeanDefinitions(resourceLoader.getResource(uri));
}
@@ -135,18 +140,24 @@
// and finally add avalon bean post processor
final RootBeanDefinition beanDef = createBeanDefinition(AvalonBeanPostProcessor.class, "init", true);
- beanDef.getPropertyValues().addPropertyValue("context", new RuntimeBeanReference(AvalonUtils.CONTEXT_ROLE));
- beanDef.getPropertyValues().addPropertyValue("configurationInfo", new RuntimeBeanReference(ConfigurationInfo.class.getName()));
- beanDef.getPropertyValues().addPropertyValue("resourceLoader", resourceLoader);
- beanDef.getPropertyValues().addPropertyValue("location", this.getConfigurationLocation());
+ beanDef.getPropertyValues().addPropertyValue(
+ "context", new RuntimeBeanReference(AvalonUtils.CONTEXT_ROLE));
+ beanDef.getPropertyValues().addPropertyValue(
+ "configurationInfo", new RuntimeBeanReference(ConfigurationInfo.class.getName()));
+ beanDef.getPropertyValues().addPropertyValue(
+ "resourceLoader", resourceLoader);
+ beanDef.getPropertyValues().addPropertyValue(
+ "location", this.getConfigurationLocation());
this.register(beanDef, AvalonBeanPostProcessor.class.getName(), registry);
final RootBeanDefinition resolverDef = new RootBeanDefinition();
resolverDef.setBeanClassName("org.apache.cocoon.components.treeprocessor.variables.PreparedVariableResolver");
resolverDef.setLazyInit(false);
resolverDef.setScope("prototype");
- resolverDef.getPropertyValues().addPropertyValue("manager", new RuntimeBeanReference("org.apache.avalon.framework.service.ServiceManager"));
- this.register(resolverDef, "org.apache.cocoon.components.treeprocessor.variables.VariableResolver", null, registry);
+ resolverDef.getPropertyValues().addPropertyValue(
+ "manager", new RuntimeBeanReference("org.apache.avalon.framework.service.ServiceManager"));
+ this.register(
+ resolverDef, "org.apache.cocoon.components.treeprocessor.variables.VariableResolver", null, registry);
}
protected ConfigurationInfo readConfiguration(String location, ResourceLoader resourceLoader)
@@ -181,14 +192,14 @@
public void createConfig(ConfigurationInfo info,
BeanDefinitionRegistry registry)
throws Exception {
- final Map components = info.getComponents();
- final List pooledRoles = new ArrayList();
+ final Map<String, ComponentInfo> components = info.getComponents();
+ final List<String> pooledRoles = new ArrayList<String>();
// Iterate over all definitions
- final Iterator i = components.entrySet().iterator();
+ final Iterator<Map.Entry<String, ComponentInfo>> i = components.entrySet().iterator();
while ( i.hasNext() ) {
- final Map.Entry entry = (Map.Entry)i.next();
- final ComponentInfo current = (ComponentInfo)entry.getValue();
+ Map.Entry<String, ComponentInfo> entry = i.next();
+ final ComponentInfo current = entry.getValue();
final String role = current.getRole();
String className = current.getComponentClassName();
@@ -213,9 +224,13 @@
current.setModel(ComponentInfo.MODEL_PRIMITIVE);
}
} catch (NoClassDefFoundError ncdfe) {
- throw new ConfigurationException("Unable to create class for component with role " + current.getRole() + " with class: " + className, ncdfe);
+ throw new ConfigurationException(
+ "Unable to create class for component with role " + current.getRole()
+ + " with class: " + className, ncdfe);
} catch (ClassNotFoundException cnfe) {
- throw new ConfigurationException("Unable to create class for component with role " + current.getRole() + " with class: " + className, cnfe);
+ throw new ConfigurationException(
+ "Unable to create class for component with role " + current.getRole()
+ + " with class: " + className, cnfe);
}
}
if ( current.getModel() == ComponentInfo.MODEL_POOLED ) {
@@ -239,10 +254,13 @@
if ( current.getDestroyMethodName() != null ) {
beanDef.setDestroyMethodName(current.getDestroyMethodName());
}
- beanDef.setSingleton(singleton);
+
+ beanDef.setScope( singleton ? BeanDefinition.SCOPE_SINGLETON : BeanDefinition.SCOPE_PROTOTYPE );
+
beanDef.setLazyInit(singleton && current.isLazyInit());
if ( isSelector ) {
- beanDef.getConstructorArgumentValues().addGenericArgumentValue(role.substring(0, role.length()-8), "java.lang.String");
+ beanDef.getConstructorArgumentValues().
+ addGenericArgumentValue(role.substring(0, role.length()-8), "java.lang.String");
if ( current.getDefaultValue() != null ) {
beanDef.getPropertyValues().addPropertyValue("default", current.getDefaultValue());
}
@@ -253,12 +271,14 @@
// add the factory for poolables
final RootBeanDefinition poolableBeanDef = new RootBeanDefinition();
poolableBeanDef.setBeanClass(PoolableFactoryBean.class);
- poolableBeanDef.setSingleton(true);
+ poolableBeanDef.setScope(BeanDefinition.SCOPE_SINGLETON);
poolableBeanDef.setLazyInit(false);
poolableBeanDef.setInitMethodName("initialize");
poolableBeanDef.setDestroyMethodName("dispose");
- poolableBeanDef.getConstructorArgumentValues().addIndexedArgumentValue(0, beanName, "java.lang.String");
- poolableBeanDef.getConstructorArgumentValues().addIndexedArgumentValue(1, className, "java.lang.String");
+ poolableBeanDef.getConstructorArgumentValues().
+ addIndexedArgumentValue(0, beanName, "java.lang.String");
+ poolableBeanDef.getConstructorArgumentValues().
+ addIndexedArgumentValue(1, className, "java.lang.String");
if ( current.getConfiguration() != null ) {
// we treat poolMax as a string to allow property replacements
final String poolMax = current.getConfiguration().getAttribute("pool-max", null);
@@ -268,10 +288,12 @@
}
}
if ( current.getPoolInMethodName() != null ) {
- poolableBeanDef.getPropertyValues().addPropertyValue("poolInMethodName", current.getPoolInMethodName());
+ poolableBeanDef.getPropertyValues().
+ addPropertyValue("poolInMethodName", current.getPoolInMethodName());
}
if ( current.getPoolOutMethodName() != null ) {
- poolableBeanDef.getPropertyValues().addPropertyValue("poolOutMethodName", current.getPoolOutMethodName());
+ poolableBeanDef.getPropertyValues().
+ addPropertyValue("poolOutMethodName", current.getPoolOutMethodName());
}
this.register(poolableBeanDef, role, registry);
pooledRoles.add(role);
@@ -279,10 +301,10 @@
}
// now change roles for pooled components (from {role} to {role}Pooled
- final Iterator prI = pooledRoles.iterator();
+ final Iterator<String> prI = pooledRoles.iterator();
while ( prI.hasNext() ) {
- final String role = (String)prI.next();
- final Object pooledInfo = components.remove(role);
+ final String role = prI.next();
+ final ComponentInfo pooledInfo = components.remove(role);
components.put(role + "Pooled", pooledInfo);
}
}
@@ -307,7 +329,7 @@
if (!registry.containsBeanDefinition(PipelineComponentInfo.ROLE)) {
final RootBeanDefinition beanDef = new RootBeanDefinition();
beanDef.setBeanClass(PipelineComponentInfoFactoryBean.class);
- beanDef.setSingleton(true);
+ beanDef.setScope(BeanDefinition.SCOPE_SINGLETON);
beanDef.setLazyInit(false);
beanDef.setInitMethodName("init");
this.register(beanDef, PipelineComponentInfo.ROLE, registry);
@@ -315,7 +337,7 @@
BeanDefinitionBuilder initDefBuilder =
BeanDefinitionBuilder.rootBeanDefinition(PipelineComponentInfoInitializer.class);
initDefBuilder.addPropertyReference("info", PipelineComponentInfo.ROLE);
- initDefBuilder.setSingleton(true);
+ initDefBuilder.setScope(BeanDefinition.SCOPE_SINGLETON);
initDefBuilder.setLazyInit(false);
initDefBuilder.setInitMethodName("init");
initDefBuilder.addPropertyValue("data", info.getData());
@@ -324,7 +346,7 @@
final RootBeanDefinition ciBeanDef = new RootBeanDefinition();
ciBeanDef.setBeanClass(ConfigurationInfoFactoryBean.class);
- ciBeanDef.setSingleton(true);
+ ciBeanDef.setScope(BeanDefinition.SCOPE_SINGLETON);
ciBeanDef.setLazyInit(false);
ciBeanDef.getPropertyValues().addPropertyValue("configurationInfo", configInfo);
this.register(ciBeanDef, ConfigurationInfo.class.getName(), registry);
@@ -333,7 +355,7 @@
protected static void prepareSelector(PipelineComponentInfo info,
ConfigurationInfo configInfo,
String category) {
- final ComponentInfo component = (ComponentInfo) configInfo.getComponents().get(category + "Selector");
+ final ComponentInfo component = configInfo.getComponents().get(category + "Selector");
if (component != null) {
info.setDefaultType(category, component.getDefaultValue());
}
diff --git a/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/ConfigurationInfo.java b/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/ConfigurationInfo.java
index f5c848a..8a864d8 100644
--- a/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/ConfigurationInfo.java
+++ b/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/ConfigurationInfo.java
@@ -36,44 +36,46 @@
protected String rootLogger;
/** Map for shorthand to role mapping. */
- private final Map shorthands;
+ private final Map<String, String> shorthands;
- /** Map for role to default classname mapping.
+ /** Map for role to default classname mapping.
* As soon as a component is configured for this role, the info
* will be removed from this map.
+ *
* @see #allRoles */
- private final Map currentRoles;
+ private final Map<String, ComponentInfo> currentRoles;
/** Map for role to default classname mapping. This map contains
* all definitions to be available for maps in child containers.
+ *
* @see #currentRoles
*/
- private final Map allRoles;
+ private final Map<String, ComponentInfo> allRoles;
/** Map for role->key to classname mapping. */
- private final Map keyClassNames;
+ private final Map<String, Map<String, ComponentInfo>> keyClassNames;
/** List of components. */
- private final Map components = new HashMap();
+ private final Map<String, ComponentInfo> components = new HashMap<String, ComponentInfo>();
/** List of imports for spring configurations. */
- private final List imports = new ArrayList();
+ private final List<String> imports = new ArrayList<String>();
public ConfigurationInfo() {
- this.shorthands = new HashMap();
- this.currentRoles = new HashMap();
- this.keyClassNames = new HashMap();
- this.allRoles = new HashMap();
+ this.shorthands = new HashMap<String, String>();
+ this.currentRoles = new HashMap<String, ComponentInfo>();
+ this.keyClassNames = new HashMap<String, Map<String, ComponentInfo>>();
+ this.allRoles = new HashMap<String, ComponentInfo>();
}
public ConfigurationInfo(ConfigurationInfo parent) {
- this.shorthands = new HashMap(parent.shorthands);
- this.currentRoles = new HashMap();
- this.keyClassNames = new HashMap(parent.keyClassNames);
- this.allRoles = new HashMap(parent.allRoles);
+ this.shorthands = new HashMap<String, String>(parent.shorthands);
+ this.currentRoles = new HashMap<String, ComponentInfo>();
+ this.keyClassNames = new HashMap<String, Map<String, ComponentInfo>>(parent.keyClassNames);
+ this.allRoles = new HashMap<String, ComponentInfo>(parent.allRoles);
}
- public Map getComponents() {
+ public Map<String, ComponentInfo> getComponents() {
return components;
}
@@ -89,7 +91,7 @@
this.components.put(info.getRole(), info);
}
- public Collection getRoles() {
+ public Collection<ComponentInfo> getRoles() {
return this.currentRoles.values();
}
@@ -99,9 +101,9 @@
}
public ComponentInfo getRole(String role) {
- ComponentInfo info = (ComponentInfo) this.currentRoles.get(role);
- if (info == null ) {
- info = (ComponentInfo) this.allRoles.get(role);
+ ComponentInfo info = this.currentRoles.get(role);
+ if (info == null) {
+ info = this.allRoles.get(role);
}
return info;
}
@@ -114,11 +116,11 @@
this.currentRoles.clear();
}
- public Map getShorthands() {
+ public Map<String, String> getShorthands() {
return this.shorthands;
}
- public Map getKeyClassNames() {
+ public Map<String, Map<String, ComponentInfo>> getKeyClassNames() {
return this.keyClassNames;
}
@@ -126,12 +128,12 @@
this.imports.add(uri);
}
- public List getImports() {
+ public List<String> getImports() {
return this.imports;
}
public String getRoleForName(String alias) {
- final String value = (String) this.shorthands.get(alias);
+ final String value = this.shorthands.get(alias);
if (value != null) {
return value;
}
diff --git a/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/ConfigurationReader.java b/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/ConfigurationReader.java
index 2b83bca..37648b4 100644
--- a/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/ConfigurationReader.java
+++ b/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/ConfigurationReader.java
@@ -61,7 +61,7 @@
protected final ConfigurationInfo configInfo;
/** All component configurations. */
- protected final List componentConfigs = new ArrayList();
+ protected final List<Configuration> componentConfigs = new ArrayList<Configuration>();
/** Is this the root context? */
protected final boolean isRootContext;
@@ -126,9 +126,9 @@
if (parentInfo != null) {
this.configInfo = new ConfigurationInfo(parentInfo);
- final Iterator i = parentInfo.getComponents().values().iterator();
+ final Iterator<ComponentInfo> i = parentInfo.getComponents().values().iterator();
while (i.hasNext()) {
- final ComponentInfo current = (ComponentInfo) i.next();
+ final ComponentInfo current = i.next();
if (current.isSelector()) {
this.configInfo.addRole(current.getRole(), current.copy());
}
@@ -218,7 +218,7 @@
*
* @param rsrc Resource for the input source
* @return Input source
- * @throws Exception if resource URL is not valid or input stream is not available
+ * @throws IOException if resource URL is not valid or input stream is not available
*/
protected InputSource getInputSource(Resource rsrc)
throws IOException {
@@ -288,7 +288,7 @@
this.configInfo.setRootLogger(config.getAttribute("logger", null));
// and load configuration with a empty list of loaded configurations
- final Set loadedConfigs = new HashSet();
+ final Set<String> loadedConfigs = new HashSet<String>();
// what is it?
if ("role-list".equals(config.getName()) || "roles".equals(config.getName())) {
configureRoles(config);
@@ -321,9 +321,9 @@
processComponents();
// add roles as components
- final Iterator i = this.configInfo.getRoles().iterator();
+ final Iterator<ComponentInfo> i = this.configInfo.getRoles().iterator();
while (i.hasNext()) {
- final ComponentInfo current = (ComponentInfo) i.next();
+ final ComponentInfo current = i.next();
if (!current.hasConfiguredLazyInit()) {
current.setLazyInit(true);
}
@@ -334,7 +334,7 @@
protected void parseConfiguration(final Configuration configuration,
String contextURI,
- Set loadedURIs)
+ Set<String> loadedURIs)
throws ConfigurationException {
final Configuration[] configurations = configuration.getChildren();
@@ -361,9 +361,9 @@
protected void processComponents()
throws ConfigurationException {
- final Iterator i = this.componentConfigs.iterator();
+ final Iterator<Configuration> i = this.componentConfigs.iterator();
while (i.hasNext()) {
- final Configuration componentConfig = (Configuration) i.next();
+ final Configuration componentConfig = i.next();
final String componentName = componentConfig.getName();
// Find the role
@@ -371,7 +371,7 @@
String alias = null;
if (role == null) {
// Get the role from the role manager if not explicitely specified
- role = (String) this.configInfo.getShorthands().get(componentName);
+ role = this.configInfo.getShorthands().get(componentName);
alias = componentName;
if (role == null) {
// Unknown role
@@ -434,7 +434,8 @@
if (this.logger.isDebugEnabled()) {
this.logger.debug("Duplicate component definition for role " + role +
" at " + componentConfig.getLocation() + ". Component " +
- "has already been defined at " + ((ComponentInfo) this.configInfo.getComponents().get(role)).getConfiguration().getLocation());
+ "has already been defined at " +
+ this.configInfo.getComponents().get(role).getConfiguration().getLocation());
}
}
@@ -458,14 +459,15 @@
}
componentRole += '/';
Configuration[] children = info.getConfiguration().getChildren();
- final Map hintConfigs = (Map) this.configInfo.getKeyClassNames().get(role);
+ final Map<String, ComponentInfo> hintConfigs = this.configInfo.getKeyClassNames().get(role);
for (int j = 0; j < children.length; j++) {
final Configuration current = children[j];
final ComponentInfo childInfo = new ComponentInfo();
childInfo.fill(current);
childInfo.setConfiguration(current);
- final ComponentInfo hintInfo = hintConfigs == null ? null
- : (ComponentInfo) hintConfigs.get(current.getName());
+ final ComponentInfo hintInfo = hintConfigs == null
+ ? null
+ : hintConfigs.get(current.getName());
if (current.getAttribute(classAttribute, null) != null || hintInfo == null) {
childInfo.setComponentClassName(current.getAttribute(classAttribute));
} else {
@@ -488,7 +490,7 @@
* @throws ConfigurationException
*/
protected void handleInclude(final String contextURI,
- final Set loadedURIs,
+ final Set<String> loadedURIs,
final Configuration includeStatement)
throws ConfigurationException {
final String includeURI = includeStatement.getAttribute("src", null);
@@ -526,7 +528,8 @@
if (load) {
final String pattern = includeStatement.getAttribute("pattern", null);
try {
- Resource[] resources = this.resolver.getResources(this.getUrl(directoryURI + '/' + pattern, contextURI));
+ Resource[] resources = this.resolver.getResources(
+ this.getUrl(directoryURI + '/' + pattern, contextURI));
if (resources != null) {
Arrays.sort(resources, ResourceUtils.getResourceComparator());
for (int i = 0; i < resources.length; i++) {
@@ -534,14 +537,15 @@
}
}
} catch (Exception e) {
- throw new ConfigurationException("Cannot load from directory '" + directoryURI + "' at " + includeStatement.getLocation(), e);
+ throw new ConfigurationException("Cannot load from directory '" + directoryURI
+ + "' at " + includeStatement.getLocation(), e);
}
}
}
}
protected void loadURI(final Resource src,
- final Set loadedURIs,
+ final Set<String> loadedURIs,
final Configuration includeStatement)
throws ConfigurationException, IOException {
// If already loaded: do nothing
@@ -612,7 +616,8 @@
if ( dirResource.exists() ) {
final String pattern = includeStatement.getAttribute("pattern", null);
try {
- Resource[] resources = this.resolver.getResources(this.getUrl(directoryURI + '/' + pattern, contextURI));
+ Resource[] resources = this.resolver.getResources(
+ this.getUrl(directoryURI + '/' + pattern, contextURI));
if ( resources != null ) {
Arrays.sort(resources, ResourceUtils.getResourceComparator());
for(int i=0; i < resources.length; i++) {
@@ -652,7 +657,8 @@
continue;
}
if (!"role".equals(role.getName())) {
- throw new ConfigurationException("Unexpected '" + role.getName() + "' element at " + role.getLocation());
+ throw new ConfigurationException(
+ "Unexpected '" + role.getName() + "' element at " + role.getLocation());
}
final String roleName = role.getAttribute("name");
@@ -682,7 +688,8 @@
} else {
// Check that it's consistent with the existing info
if (!defaultClassName.equals(info.getComponentClassName())) {
- throw new ConfigurationException("Invalid redeclaration: default class already set to " + info.getComponentClassName() +
+ throw new ConfigurationException(
+ "Invalid redeclaration: default class already set to " + info.getComponentClassName() +
" for role " + roleName + " at " + role.getLocation());
}
//FIXME: should check also other ServiceInfo members
@@ -691,9 +698,9 @@
final Configuration[] keys = role.getChildren("hint");
if (keys.length > 0) {
- Map keyMap = (Map) this.configInfo.getKeyClassNames().get(roleName);
+ Map<String, ComponentInfo> keyMap = this.configInfo.getKeyClassNames().get(roleName);
if (keyMap == null) {
- keyMap = new HashMap();
+ keyMap = new HashMap<String, ComponentInfo>();
this.configInfo.getKeyClassNames().put(roleName, keyMap);
}
@@ -703,7 +710,7 @@
final String shortHand = key.getAttribute("shorthand").trim();
final String className = key.getAttribute("class").trim();
- ComponentInfo info = (ComponentInfo) keyMap.get(shortHand);
+ ComponentInfo info = keyMap.get(shortHand);
if (info == null) {
info = new ComponentInfo();
info.setComponentClassName(className);
@@ -714,7 +721,8 @@
} else {
// Check that it's consistent with the existing info
if (!className.equals(info.getComponentClassName())) {
- throw new ConfigurationException("Invalid redeclaration: class already set to " + info.getComponentClassName() +
+ throw new ConfigurationException(
+ "Invalid redeclaration: class already set to " + info.getComponentClassName() +
" for hint " + shortHand + " at " + key.getLocation());
}
//FIXME: should check also other ServiceInfo members
diff --git a/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/SitemapElementParser.java b/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/SitemapElementParser.java
index 13a9bde..581f017 100644
--- a/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/SitemapElementParser.java
+++ b/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/SitemapElementParser.java
@@ -22,6 +22,7 @@
import org.apache.cocoon.core.container.spring.logger.LoggerUtils;
import org.apache.cocoon.spring.configurator.WebAppContextUtils;
import org.apache.excalibur.source.SourceResolver;
+import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.RuntimeBeanReference;
import org.springframework.beans.factory.support.BeanDefinitionReader;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
@@ -41,30 +42,40 @@
/**
* @see org.apache.cocoon.core.container.spring.avalon.BridgeElementParser#createComponents(org.w3c.dom.Element, org.apache.cocoon.core.container.spring.avalon.ConfigurationInfo, org.springframework.beans.factory.support.BeanDefinitionRegistry, org.springframework.beans.factory.support.BeanDefinitionReader, org.springframework.core.io.ResourceLoader)
*/
+ @Override
public void createComponents(Element element, ConfigurationInfo info,
BeanDefinitionRegistry registry, BeanDefinitionReader reader,
ResourceLoader resourceLoader) throws Exception {
+
super.createComponents(element, info, registry, reader, resourceLoader);
// add string template parser for sitemap variable substitution
- final ChildBeanDefinition beanDef = new ChildBeanDefinition("org.apache.cocoon.template.expression.AbstractStringTemplateParser");
- beanDef.setBeanClassName("org.apache.cocoon.components.treeprocessor.variables.LegacySitemapStringTemplateParser");
- beanDef.setSingleton(true);
+ final ChildBeanDefinition beanDef =
+ new ChildBeanDefinition("org.apache.cocoon.template.expression.AbstractStringTemplateParser");
+ beanDef.setBeanClassName(
+ "org.apache.cocoon.components.treeprocessor.variables.LegacySitemapStringTemplateParser");
+ beanDef.setScope(BeanDefinition.SCOPE_SINGLETON);
beanDef.setLazyInit(false);
- beanDef.getPropertyValues().addPropertyValue("serviceManager", new RuntimeBeanReference("org.apache.avalon.framework.service.ServiceManager"));
+ beanDef.getPropertyValues().addPropertyValue(
+ "serviceManager", new RuntimeBeanReference("org.apache.avalon.framework.service.ServiceManager"));
this.register(beanDef, "org.apache.cocoon.el.parsing.StringTemplateParser/legacySitemap", null, registry);
final RootBeanDefinition resolverDef = new RootBeanDefinition();
- resolverDef.setBeanClassName("org.apache.cocoon.components.treeprocessor.variables.StringTemplateParserVariableResolver");
+ resolverDef.setBeanClassName(
+ "org.apache.cocoon.components.treeprocessor.variables.StringTemplateParserVariableResolver");
resolverDef.setLazyInit(false);
resolverDef.setScope("prototype");
- resolverDef.getPropertyValues().addPropertyValue("stringTemplateParser", new RuntimeBeanReference("org.apache.cocoon.el.parsing.StringTemplateParser/legacySitemap"));
- resolverDef.getPropertyValues().addPropertyValue("objectModel", new RuntimeBeanReference("org.apache.cocoon.el.objectmodel.ObjectModel"));
- this.register(resolverDef, "org.apache.cocoon.components.treeprocessor.variables.VariableResolver", null, registry);
+ resolverDef.getPropertyValues().addPropertyValue(
+ "stringTemplateParser", new RuntimeBeanReference("org.apache.cocoon.el.parsing.StringTemplateParser/legacySitemap"));
+ resolverDef.getPropertyValues().addPropertyValue(
+ "objectModel", new RuntimeBeanReference("org.apache.cocoon.el.objectmodel.ObjectModel"));
+ this.register(resolverDef,
+ "org.apache.cocoon.components.treeprocessor.variables.VariableResolver", null, registry);
}
/**
* @see BridgeElementParser#addContext(Element, BeanDefinitionRegistry)
*/
+ @Override
protected void addContext(Element element, BeanDefinitionRegistry registry) {
// we get the uriPrefix from the configuration
final String uriPrefix = element.getAttribute("uriPrefix");
@@ -81,6 +92,7 @@
* @param registry The bean registry.
* @param loggerCategory The optional category for the logger.
*/
+ @Override
protected void addLogger(BeanDefinitionRegistry registry,
String loggerCategory) {
final RootBeanDefinition beanDef = createBeanDefinition(ChildLoggerFactoryBean.class, "init", false);
@@ -93,14 +105,16 @@
/**
* @see BridgeElementParser#readConfiguration(String, ResourceLoader)
*/
- protected ConfigurationInfo readConfiguration(String location, ResourceLoader resourceLoader)
- throws Exception {
+ @Override
+ protected ConfigurationInfo readConfiguration(String location, ResourceLoader resourceLoader) throws Exception {
WebApplicationContext parentContext = WebAppContextUtils.getCurrentWebApplicationContext();
- return ConfigurationReader.readSitemap((ConfigurationInfo) parentContext.getBean(ConfigurationInfo.class.getName()),
- location,
- new SourceResourceLoader(resourceLoader, (SourceResolver) parentContext.getBean(SourceResolver.ROLE)));
+ return ConfigurationReader.readSitemap(
+ (ConfigurationInfo) parentContext.getBean(ConfigurationInfo.class.getName()),
+ location,
+ new SourceResourceLoader(resourceLoader, (SourceResolver) parentContext.getBean(SourceResolver.ROLE)));
}
+ @Override
protected String getConfigurationLocation() {
return "config/avalon";
}
diff --git a/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/SourceResource.java b/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/SourceResource.java
index 61579f9..1b1811a 100644
--- a/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/SourceResource.java
+++ b/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/SourceResource.java
@@ -36,18 +36,20 @@
public class SourceResource implements Resource {
protected Source source;
- protected SourceResolver resolver;
- protected boolean open;
+ protected SourceResolver resolver;
+
+ protected boolean open;
public SourceResource(Source s, SourceResolver r) {
this.source = s;
- this.resolver =r;
+ this.resolver = r;
}
/**
* @see org.springframework.core.io.InputStreamSource#getInputStream()
*/
+ @Override
public InputStream getInputStream() throws IOException {
this.open = true;
return new SourceIOInputStream(this.resolver, this.source);
@@ -56,14 +58,17 @@
/**
* @see org.springframework.core.io.Resource#createRelative(java.lang.String)
*/
+ @Override
public Resource createRelative(String uri) throws IOException {
int pos = this.source.getURI().lastIndexOf('/');
- return new SourceResource(this.resolver.resolveURI(uri, this.source.getURI().substring(0, pos), null), this.resolver);
+ return new SourceResource(
+ this.resolver.resolveURI(uri, this.source.getURI().substring(0, pos), null), this.resolver);
}
/**
* @see org.springframework.core.io.Resource#exists()
*/
+ @Override
public boolean exists() {
return this.source.exists();
}
@@ -71,6 +76,7 @@
/**
* @see org.springframework.core.io.Resource#getDescription()
*/
+ @Override
public String getDescription() {
return "Source: " + this.source;
}
@@ -78,6 +84,7 @@
/**
* @see org.springframework.core.io.Resource#getFile()
*/
+ @Override
public File getFile() throws IOException {
return SourceUtil.getFile(this.source);
}
@@ -85,6 +92,7 @@
/**
* @see org.springframework.core.io.Resource#getFilename()
*/
+ @Override
public String getFilename() {
int pos = this.source.getURI().lastIndexOf('/');
return this.source.getURI().substring(pos + 1);
@@ -93,6 +101,7 @@
/**
* @see org.springframework.core.io.Resource#getURL()
*/
+ @Override
public URL getURL() throws IOException {
return new URL(this.source.getURI());
}
@@ -104,15 +113,17 @@
/**
* @see org.springframework.core.io.Resource#isOpen()
*/
+ @Override
public boolean isOpen() {
return this.open;
}
+
+ @Override
public URI getURI() throws IOException {
try {
return new URI(this.source.getURI());
} catch (URISyntaxException e) {
- IOException ioe = new IOException("Exception because of the URI syntax.");
- ioe.initCause(e);
+ IOException ioe = new IOException("Exception because of the URI syntax.", e);
throw ioe;
}
}
@@ -120,12 +131,19 @@
/**
* @see org.springframework.core.io.Resource#isReadable()
*/
+ @Override
public boolean isReadable() {
return this.source.exists();
}
- public long lastModified() throws IOException {
- return this.source.getLastModified();
- }
+ @Override
+ public long lastModified() throws IOException {
+ return this.source.getLastModified();
+ }
+
+ @Override
+ public long contentLength() throws IOException {
+ return this.source.getContentLength();
+ }
}
diff --git a/core/cocoon-sitemap/cocoon-sitemap-impl/src/test/java/org/apache/cocoon/AbstractTestCase.java b/core/cocoon-sitemap/cocoon-sitemap-impl/src/test/java/org/apache/cocoon/AbstractTestCase.java
index 982b75e..14cb8aa 100644
--- a/core/cocoon-sitemap/cocoon-sitemap-impl/src/test/java/org/apache/cocoon/AbstractTestCase.java
+++ b/core/cocoon-sitemap/cocoon-sitemap-impl/src/test/java/org/apache/cocoon/AbstractTestCase.java
@@ -25,7 +25,6 @@
import org.springframework.beans.factory.support.BeanDefinitionReaderUtils;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.support.RootBeanDefinition;
-import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.ClassPathResource;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.request.RequestContextHolder;
@@ -42,6 +41,8 @@
import org.apache.cocoon.spring.configurator.impl.SettingsBeanFactoryPostProcessor;
import junit.framework.TestCase;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
/**
* This class sets up all necessary environment information to implement own test cases.
@@ -52,16 +53,18 @@
public abstract class AbstractTestCase extends TestCase {
private MockRequest request;
+
private MockResponse response;
+
private MockContext context;
- private Map objectmodel;
+
+ private Map<String, Object> objectmodel;
private MockRequestAttributes requestAttributes;
/** The bean factory. */
private DefaultListableBeanFactory beanFactory;
-
public final MockRequest getRequest() {
return this.request;
}
@@ -74,7 +77,7 @@
return this.context;
}
- public final Map getObjectModel() {
+ public final Map<String, Object> getObjectModel() {
return this.objectmodel;
}
@@ -86,6 +89,7 @@
/**
* @see junit.framework.TestCase#setUp()
*/
+ @Override
protected void setUp() throws Exception {
super.setUp();
@@ -111,6 +115,7 @@
/**
* @see junit.framework.TestCase#tearDown()
*/
+ @Override
protected void tearDown() throws Exception {
if (this.requestAttributes != null) {
this.requestAttributes.requestCompleted();
@@ -148,14 +153,20 @@
MockWebApplicationContext ctx = new MockWebApplicationContext(this.beanFactory, getContext());
getContext().setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, ctx);
+
+ // COCOON-2374
+ // needed to avoid problem with
+ // java.lang.IllegalStateException: org.apache.cocoon.MockWebApplicationContext@7d898981 has not been refreshed yet
+ ctx.refresh();
}
protected void createBeanFactory() throws Exception {
+ this.beanFactory = new DefaultListableBeanFactory();
+
ClassPathResource cpr = new ClassPathResource(getClass().getName().replace('.', '/') + ".spring.xml");
if (cpr.exists()) {
- this.beanFactory = new XmlBeanFactory(cpr);
- } else {
- this.beanFactory = new DefaultListableBeanFactory();
+ XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(this.beanFactory);
+ reader.loadBeanDefinitions(cpr);
}
File base = new File("target");
@@ -178,7 +189,7 @@
protected void addSettings() {
RootBeanDefinition def = new RootBeanDefinition();
def.setBeanClass(SettingsBeanFactoryPostProcessor.class);
- def.setSingleton(true);
+ def.setScope(BeanDefinition.SCOPE_SINGLETON);
def.setLazyInit(false);
def.setInitMethodName("init");
BeanDefinitionHolder holder = new BeanDefinitionHolder(def, Settings.ROLE);
@@ -188,7 +199,7 @@
protected void addProcessingInfoProvider() {
RootBeanDefinition def = new RootBeanDefinition();
def.setBeanClass(MockProcessInfoProvider.class);
- def.setSingleton(true);
+ def.setScope(BeanDefinition.SCOPE_SINGLETON);
def.setLazyInit(false);
def.getPropertyValues().addPropertyValue("objectModel", getObjectModel());
def.getPropertyValues().addPropertyValue("request", new MockProcessInfoProvider.StubRequest(getRequest()));
@@ -212,8 +223,8 @@
return new MockResponse();
}
- protected Map createObjectModel() {
- return new HashMap();
+ protected Map<String, Object> createObjectModel() {
+ return new HashMap<String, Object>();
}
protected MockContext createContext() {
diff --git a/core/cocoon-sitemap/cocoon-sitemap-impl/src/test/java/org/apache/cocoon/MockWebApplicationContext.java b/core/cocoon-sitemap/cocoon-sitemap-impl/src/test/java/org/apache/cocoon/MockWebApplicationContext.java
index 66ae6f5..eeb8980 100644
--- a/core/cocoon-sitemap/cocoon-sitemap-impl/src/test/java/org/apache/cocoon/MockWebApplicationContext.java
+++ b/core/cocoon-sitemap/cocoon-sitemap-impl/src/test/java/org/apache/cocoon/MockWebApplicationContext.java
@@ -1,19 +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.
-*/
+ * 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;
import javax.servlet.ServletContext;
@@ -23,6 +23,7 @@
import org.springframework.web.context.WebApplicationContext;
public class MockWebApplicationContext extends GenericApplicationContext implements WebApplicationContext {
+
ServletContext sc;
public MockWebApplicationContext(DefaultListableBeanFactory parent, ServletContext context) {
@@ -34,6 +35,7 @@
this.sc = context;
}
+ @Override
public ServletContext getServletContext() {
return this.sc;
}
diff --git a/core/cocoon-sitemap/cocoon-sitemap-impl/src/test/java/org/apache/cocoon/environment/mock/MockRequestAttributes.java b/core/cocoon-sitemap/cocoon-sitemap-impl/src/test/java/org/apache/cocoon/environment/mock/MockRequestAttributes.java
index 54c2c13..dd1bc41 100644
--- a/core/cocoon-sitemap/cocoon-sitemap-impl/src/test/java/org/apache/cocoon/environment/mock/MockRequestAttributes.java
+++ b/core/cocoon-sitemap/cocoon-sitemap-impl/src/test/java/org/apache/cocoon/environment/mock/MockRequestAttributes.java
@@ -18,11 +18,11 @@
*/
package org.apache.cocoon.environment.mock;
-import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpSession;
@@ -39,29 +39,29 @@
* @version $Id$
* @since 2.2
*/
-public class MockRequestAttributes
- implements RequestAttributes {
+public class MockRequestAttributes implements RequestAttributes {
final protected Request request;
- final protected Map callbacks = new HashMap();
+ final protected Map<String, Runnable> callbacks = new HashMap<String, Runnable>();
- public MockRequestAttributes(Request r) {
- this.request = r;
+ public MockRequestAttributes(Request request) {
+ this.request = request;
}
/**
* @see org.springframework.web.context.scope.RequestAttributes#getAttribute(java.lang.String, int)
*/
+ @Override
public Object getAttribute(String key, int scope) {
- if ( scope == RequestAttributes.SCOPE_REQUEST ) {
+ if (scope == RequestAttributes.SCOPE_REQUEST) {
return this.request.getLocalAttribute(key);
}
- if ( scope == RequestAttributes.SCOPE_SESSION ) {
+ if (scope == RequestAttributes.SCOPE_SESSION) {
return this.request.getAttribute(key);
}
final HttpSession session = this.request.getSession(false);
- if ( session != null ) {
+ if (session != null) {
return session.getAttribute(key);
}
return null;
@@ -70,39 +70,43 @@
/**
* @see org.springframework.web.context.scope.RequestAttributes#getSessionMutex()
*/
- public Object getSessionMutex() {
+ @Override
+ public HttpSession getSessionMutex() {
return this.request.getSession();
}
/**
* @see org.springframework.web.context.scope.RequestAttributes#removeAttribute(java.lang.String, int)
*/
+ @Override
public void removeAttribute(String key, int scope) {
- if ( scope == RequestAttributes.SCOPE_REQUEST ) {
+ if (scope == RequestAttributes.SCOPE_REQUEST) {
this.request.removeLocalAttribute(key);
}
- if ( scope == RequestAttributes.SCOPE_SESSION ) {
+ if (scope == RequestAttributes.SCOPE_SESSION) {
this.request.removeAttribute(key);
}
- if ( scope == RequestAttributes.SCOPE_GLOBAL_SESSION ) {
+ if (scope == RequestAttributes.SCOPE_GLOBAL_SESSION) {
final HttpSession session = this.request.getSession(false);
- if ( session != null ) {
+ if (session != null) {
session.removeAttribute(key);
}
}
}
/**
- * @see org.springframework.web.context.scope.RequestAttributes#setAttribute(java.lang.String, java.lang.Object, int)
+ * @see org.springframework.web.context.scope.RequestAttributes#setAttribute(java.lang.String, java.lang.Object,
+ * int)
*/
+ @Override
public void setAttribute(String key, Object value, int scope) {
- if ( scope == RequestAttributes.SCOPE_REQUEST ) {
+ if (scope == RequestAttributes.SCOPE_REQUEST) {
this.request.setLocalAttribute(key, value);
}
- if ( scope == RequestAttributes.SCOPE_SESSION ) {
+ if (scope == RequestAttributes.SCOPE_SESSION) {
this.request.setAttribute(key, value);
}
- if ( scope == RequestAttributes.SCOPE_GLOBAL_SESSION ) {
+ if (scope == RequestAttributes.SCOPE_GLOBAL_SESSION) {
final HttpSession session = this.request.getSession(true);
session.setAttribute(key, value);
}
@@ -111,42 +115,52 @@
/**
* @see org.springframework.web.context.request.RequestAttributes#getSessionId()
*/
+ @Override
public String getSessionId() {
return this.request.getSession().getId();
}
/**
- * @see org.springframework.web.context.request.RequestAttributes#registerDestructionCallback(java.lang.String, java.lang.Runnable, int)
+ * @see org.springframework.web.context.request.RequestAttributes#registerDestructionCallback(java.lang.String,
+ * java.lang.Runnable, int)
*/
+ @Override
public void registerDestructionCallback(String name, Runnable task, int scope) {
this.callbacks.put(name, task);
}
public void requestCompleted() {
- final Iterator i = this.callbacks.values().iterator();
- while ( i.hasNext() ) {
- final Runnable task = (Runnable)i.next();
+ final Iterator<Runnable> i = this.callbacks.values().iterator();
+ while (i.hasNext()) {
+ final Runnable task = i.next();
task.run();
}
}
+ @Override
+ @SuppressWarnings("unchecked")
public String[] getAttributeNames(int scope) {
- Enumeration names = null;
- if ( scope == RequestAttributes.SCOPE_REQUEST ) {
+ Enumeration<String> names = null;
+ if (scope == RequestAttributes.SCOPE_REQUEST) {
names = this.request.getLocalAttributeNames();
- } else if ( scope == RequestAttributes.SCOPE_SESSION ) {
+ } else if (scope == RequestAttributes.SCOPE_SESSION) {
names = this.request.getAttributeNames();
} else {
final HttpSession session = this.request.getSession(false);
- if ( session != null ) {
+ if (session != null) {
names = session.getAttributeNames();
}
}
- if ( names == null ) {
+ if (names == null) {
return new String[0];
}
- ArrayList attributeNames = Collections.list(names);
- return (String[]) attributeNames.toArray(new String[attributeNames.size()]);
+ List<String> attributeNames = Collections.list(names);
+ return attributeNames.toArray(new String[attributeNames.size()]);
+ }
+
+ @Override
+ public Object resolveReference(String string) {
+ return null;
}
}
diff --git a/parent/pom.xml b/parent/pom.xml
index 5ef2ee2..f8c6b96 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -24,7 +24,7 @@
<parent>
<groupId>org.apache</groupId>
<artifactId>apache</artifactId>
- <version>13</version>
+ <version>17</version>
<relativePath/>
</parent>
@@ -1357,7 +1357,7 @@
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
- <version>1.3</version>
+ <version>1.10</version>
</dependency>
<dependency>
<groupId>commons-dbcp</groupId>
@@ -1372,7 +1372,7 @@
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
- <version>3.2</version>
+ <version>3.2.1</version>
</dependency>
<dependency>
<groupId>commons-configuration</groupId>
@@ -1382,27 +1382,27 @@
<dependency>
<groupId>commons-discovery</groupId>
<artifactId>commons-discovery</artifactId>
- <version>0.2</version>
+ <version>0.5</version>
</dependency>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
- <version>3.0.1</version>
+ <version>3.1</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
- <version>1.3.1</version>
+ <version>2.4</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-jci-core</artifactId>
- <version>1.0</version>
+ <version>1.1</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-jci-fam</artifactId>
- <version>1.0</version>
+ <version>1.1</version>
</dependency>
<dependency>
<groupId>commons-jelly</groupId>
@@ -1412,12 +1412,12 @@
<dependency>
<groupId>commons-jexl</groupId>
<artifactId>commons-jexl</artifactId>
- <version>1.0</version>
+ <version>1.1</version>
</dependency>
<dependency>
<groupId>commons-jxpath</groupId>
<artifactId>commons-jxpath</artifactId>
- <version>1.2</version>
+ <version>1.3</version>
<exclusions>
<exclusion>
<artifactId>ant-optional</artifactId>
@@ -1452,12 +1452,12 @@
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
- <version>2.3</version>
+ <version>2.6</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
- <version>1.1</version>
+ <version>1.2</version>
<exclusions>
<exclusion>
<artifactId>logkit</artifactId>
@@ -1476,7 +1476,7 @@
<dependency>
<groupId>commons-transaction</groupId>
<artifactId>commons-transaction</artifactId>
- <version>1.1</version>
+ <version>1.2</version>
</dependency>
<dependency>
<groupId>concurrent</groupId>
@@ -1683,7 +1683,7 @@
<dependency>
<groupId>org.apache.xmlgraphics</groupId>
<artifactId>fop</artifactId>
- <version>0.93</version>
+ <version>0.95-1</version>
<exclusions>
<exclusion>
<groupId>org.apache.avalon.framework</groupId>
@@ -1717,7 +1717,7 @@
<dependency>
<groupId>hsqldb</groupId>
<artifactId>hsqldb</artifactId>
- <version>1.8.0.7</version>
+ <version>1.8.0.10</version>
</dependency>
<dependency>
<groupId>com.ibm.icu</groupId>
@@ -1748,7 +1748,7 @@
<dependency>
<groupId>jdom</groupId>
<artifactId>jdom</artifactId>
- <version>1.0</version>
+ <version>1.1</version>
</dependency>
<dependency>
<groupId>eclipse</groupId>
@@ -1800,18 +1800,18 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>4.4</version>
+ <version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
- <version>1.2.14</version>
+ <version>1.2.17</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
- <version>1.4.3</version>
+ <version>1.7.12</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
@@ -1826,32 +1826,32 @@
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
- <version>2.0.1</version>
+ <version>${maven.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId>
- <version>2.0.1</version>
+ <version>${maven.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
- <version>2.0.1</version>
+ <version>${maven.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-project</artifactId>
- <version>2.0.1</version>
+ <version>${maven.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-settings</artifactId>
- <version>2.0.5</version>
+ <version>${maven.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
- <version>2.0.2</version>
+ <version>2.6</version>
</dependency>
<dependency>
<groupId>myfaces</groupId>
@@ -1949,93 +1949,58 @@
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
- <version>2.5.5</version>
- <exclusions>
- <exclusion>
- <groupId>avalon-framework</groupId>
- <artifactId>avalon-framework</artifactId>
- </exclusion>
- <exclusion>
- <groupId>logkit</groupId>
- <artifactId>logkit</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.aspectj</groupId>
- <artifactId>aspectjrt</artifactId>
- <version>1.5.4</version>
+ <version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
- <version>1.5.4</version>
+ <version>1.8.7</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
- <version>2.5.5</version>
- <exclusions>
- <exclusion>
- <groupId>avalon-framework</groupId>
- <artifactId>avalon-framework</artifactId>
- </exclusion>
- </exclusions>
+ <version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
- <version>2.5.5</version>
- <exclusions>
- <exclusion>
- <groupId>avalon-framework</groupId>
- <artifactId>avalon-framework</artifactId>
- </exclusion>
- <exclusion>
- <groupId>logkit</groupId>
- <artifactId>logkit</artifactId>
- </exclusion>
- <exclusion>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- </exclusion>
- </exclusions>
+ <version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
- <version>2.5.5</version>
+ <version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
- <version>2.5.5</version>
+ <version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
- <version>2.5.5</version>
+ <version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jms</artifactId>
- <version>2.5.5</version>
+ <version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
- <version>2.5.5</version>
+ <version>${spring.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
- <version>2.5.5</version>
+ <version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
- <version>2.5.5</version>
+ <version>${spring.version}</version>
</dependency>
<dependency>
<groupId>stax</groupId>
@@ -2178,7 +2143,7 @@
<dependency>
<groupId>xmlunit</groupId>
<artifactId>xmlunit</artifactId>
- <version>1.1</version>
+ <version>1.6</version>
<scope>test</scope>
</dependency>
@@ -2317,7 +2282,7 @@
<dependency>
<groupId>org.apache.cocoon</groupId>
<artifactId>cocoon-configuration-api</artifactId>
- <version>1.0.2</version>
+ <version>1.0.4</version>
</dependency>
<dependency>
<groupId>org.apache.cocoon</groupId>
@@ -2540,7 +2505,7 @@
<dependency>
<groupId>org.apache.cocoon</groupId>
<artifactId>cocoon-jnet</artifactId>
- <version>1.2.0</version>
+ <version>1.2.2</version>
</dependency>
<dependency>
<groupId>org.apache.cocoon</groupId>
@@ -2812,7 +2777,7 @@
<dependency>
<groupId>org.apache.cocoon</groupId>
<artifactId>cocoon-servlet-service-impl</artifactId>
- <version>1.2.0</version>
+ <version>1.3.3-COCOON-2347-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cocoon</groupId>
@@ -2874,7 +2839,7 @@
<dependency>
<groupId>org.apache.cocoon</groupId>
<artifactId>cocoon-spring-configurator</artifactId>
- <version>2.1.0</version>
+ <version>2.2.2-COCOON-2347-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cocoon</groupId>
@@ -3064,19 +3029,22 @@
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
- <version>2.12</version>
+ <version>2.19</version>
+ <configuration>
+ <redirectTestOutputToFile>true</redirectTestOutputToFile>
+ </configuration>
</plugin>
<plugin>
<artifactId>maven-site-plugin</artifactId>
- <version>3.0</version>
+ <version>3.4</version>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
- <version>2.2</version>
+ <version>2.6</version>
</plugin>
<plugin>
<artifactId>maven-plugin-plugin</artifactId>
- <version>2.9</version>
+ <version>3.4</version>
</plugin>
<plugin>
<groupId>org.apache.rat</groupId>
@@ -3100,39 +3068,38 @@
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
- <version>2.5</version>
+ <version>3.3</version>
<configuration>
- <source>1.5</source>
- <target>1.5</target>
+ <source>${targetJdk}</source>
+ <target>${targetJdk}</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-eclipse-plugin</artifactId>
- <version>2.9</version>
+ <version>2.10</version>
</plugin>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
- <version>2.4.1</version>
+ <version>2.6.1</version>
</plugin>
<plugin>
<artifactId>maven-idea-plugin</artifactId>
- <version>2.2</version>
+ <version>2.2.1</version>
<configuration>
- <!-- Cocoon 2.2 requires JDK 1.5 -->
- <jdkName>1.5</jdkName>
- <jdkLevel>1.5</jdkLevel>
+ <jdkName>${targetJdk}</jdkName>
+ <jdkLevel>${targetJdk}</jdkLevel>
</configuration>
</plugin>
<plugin>
<artifactId>maven-release-plugin</artifactId>
- <version>2.2.2</version>
+ <version>2.5.2</version>
<configuration>
<tagBase>https://svn.apache.org/repos/asf/cocoon/tags/cocoon-2.2/${project.artifactId}</tagBase>
</configuration>
</plugin>
<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
- <version>1.0.1</version>
+ <version>1.4</version>
<executions>
<execution>
<id>enforce-maven</id>
@@ -3151,16 +3118,15 @@
</plugin>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
- <version>2.8.1</version>
+ <version>2.10.3</version>
<!-- keep this in-sync with the configuration in /project/profiles/profile[id='javadocs']
- (unfortunatly this has to be set twice) -->
+ (unfortunatly this has to be set twice) -->
<configuration>
<maxmemory>512m</maxmemory>
<links>
- <link>http://docs.oracle.com/javase/1.5.0/docs/api/</link>
+ <link>http://docs.oracle.com/javase/6/docs/api//</link>
<link>http://static.springframework.org/spring/docs/2.5.x/api/</link>
<link>http://excalibur.apache.org/apidocs/</link>
- <link>http://docs.oracle.com/javase/1.5.0/docs/api/</link>
<link>http://jakarta.apache.org/commons/collections/apidocs-COLLECTIONS_3_0/</link>
<link>http://jakarta.apache.org/commons/dbcp/apidocs/</link>
<link>http://jakarta.apache.org/commons/fileupload/apidocs/</link>
@@ -3184,7 +3150,7 @@
<plugins>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
- <version>2.0.1</version>
+ <version>2.8</version>
<reportSets>
<reportSet>
<reports>
@@ -3198,7 +3164,7 @@
</plugin>
<plugin>
<artifactId>maven-changes-plugin</artifactId>
- <version>2.0-beta-2</version>
+ <version>2.11</version>
<reportSets>
<reportSet>
<reports>
@@ -3211,6 +3177,10 @@
</reporting>
<properties>
+ <targetJdk>1.6</targetJdk>
+ <maven.version>2.0.11</maven.version>
+ <spring.version>4.3.15.RELEASE</spring.version>
+
<!-- General doc properties -->
<docs.deploymentBaseUrl>file://${basedir}/../../../site/site</docs.deploymentBaseUrl>
<docs.urlRelativizer>../../../../</docs.urlRelativizer>
@@ -3383,14 +3353,13 @@
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.2</version>
<!-- keep this in-sync with the configuration in /project/build/plugins/plugin[id='maven-javadoc-plugin']
- (unfortunatly this has to be set twice) -->
+ (unfortunatly this has to be set twice) -->
<configuration>
<maxmemory>512m</maxmemory>
<links>
- <link>http://java.sun.com/j2se/1.5.0/docs/api/</link>
- <link>http://static.springframework.org/spring/docs/2.0.x/api/</link>
+ <link>http://docs.oracle.com/javase/6/docs/api//</link>
+ <link>http://static.springframework.org/spring/docs/2.5.x/api/</link>
<link>http://excalibur.apache.org/apidocs/</link>
- <link>http://java.sun.com/j2se/1.5.0/docs/api/</link>
<link>http://jakarta.apache.org/commons/collections/apidocs-COLLECTIONS_3_0/</link>
<link>http://jakarta.apache.org/commons/dbcp/apidocs/</link>
<link>http://jakarta.apache.org/commons/fileupload/apidocs/</link>
@@ -3536,80 +3505,5 @@
</pluginRepository>
</pluginRepositories>
</profile>
- <profile>
- <id>spring-2.1</id>
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-aop</artifactId>
- <version>2.1-m3</version>
- <exclusions>
- <exclusion>
- <groupId>avalon-framework</groupId>
- <artifactId>avalon-framework</artifactId>
- </exclusion>
- <exclusion>
- <groupId>logkit</groupId>
- <artifactId>logkit</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-beans</artifactId>
- <version>2.1-m3</version>
- <exclusions>
- <exclusion>
- <groupId>avalon-framework</groupId>
- <artifactId>avalon-framework</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-context</artifactId>
- <version>2.1-m3</version>
- <exclusions>
- <exclusion>
- <groupId>avalon-framework</groupId>
- <artifactId>avalon-framework</artifactId>
- </exclusion>
- <exclusion>
- <groupId>logkit</groupId>
- <artifactId>logkit</artifactId>
- </exclusion>
- <exclusion>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-core</artifactId>
- <version>2.1-m3</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-mock</artifactId>
- <version>2.1-m3</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-web</artifactId>
- <version>2.1-m3</version>
- </dependency>
- </dependencies>
- </dependencyManagement>
- <repositories>
- <repository>
- <id>i21-s3-maven-repo</id>
- <name>i21 S3 milestone repo</name>
- <url>http://s3.amazonaws.com/maven.springframework.org/milestone</url>
- </repository>
- </repositories>
- </profile>
</profiles>
</project>
diff --git a/pom.xml b/pom.xml
index fbf3848..a28116b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -24,7 +24,7 @@
<parent>
<groupId>org.apache</groupId>
<artifactId>apache</artifactId>
- <version>12</version>
+ <version>19</version>
</parent>
<groupId>org.apache.cocoon</groupId>
@@ -54,7 +54,7 @@
<plugins>
<plugin>
<artifactId>maven-eclipse-plugin</artifactId>
- <version>2.4</version>
+ <version>2.10</version>
</plugin>
</plugins>
</build>