[COCOON-2347] Applying provided patches + small reworks (removing deprecates and adding Override)
git-svn-id: https://svn.apache.org/repos/asf/cocoon/branches/BRANCH_2_2_COCOON-2347@1711430 13f79535-47bb-0310-9956-ffa450edef68
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/BridgeElementParser.java b/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/BridgeElementParser.java
index e37721b..a89acf0 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);
+ if (singleton) {
+ beanDef.setScope(BeanDefinition.SCOPE_SINGLETON);
+ }
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..9b73973 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();
@@ -151,11 +156,12 @@
}
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 +184,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 +194,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 +218,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 9aec888..2f9cdc0 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -1953,13 +1953,8 @@
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
- <artifactId>aspectjrt</artifactId>
- <version>1.5.4</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>
@@ -2287,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>
@@ -2510,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>
@@ -2782,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>
@@ -2844,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>
@@ -3184,7 +3179,7 @@
<properties>
<targetJdk>1.6</targetJdk>
<maven.version>2.0.11</maven.version>
- <spring.version>2.5.5</spring.version>
+ <spring.version>4.2.2.RELEASE</spring.version>
<!-- General doc properties -->
<docs.deploymentBaseUrl>file://${basedir}/../../../site/site</docs.deploymentBaseUrl>