You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by da...@apache.org on 2006/02/26 10:48:03 UTC
svn commit: r381074 - in
/cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon:
components/treeprocessor/ components/treeprocessor/sitemap/
core/container/spring/
Author: danielf
Date: Sun Feb 26 01:48:01 2006
New Revision: 381074
URL: http://svn.apache.org/viewcvs?rev=381074&view=rev
Log:
Made the tree processor dependencies on the component container, a little bit stricter. Now only the SitemapLanguage know about the CocoonXmlWebApplicationContext.
Added:
cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/NameForAliasAware.java (with props)
Modified:
cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/ConcreteTreeProcessor.java
cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/DefaultTreeBuilder.java
cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/TreeBuilder.java
cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/SitemapLanguage.java
cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/CocoonXmlWebApplicationContext.java
Modified: cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/ConcreteTreeProcessor.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/ConcreteTreeProcessor.java?rev=381074&r1=381073&r2=381074&view=diff
==============================================================================
--- cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/ConcreteTreeProcessor.java (original)
+++ cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/ConcreteTreeProcessor.java Sun Feb 26 01:48:01 2006
@@ -31,7 +31,7 @@
import org.apache.cocoon.Processor;
import org.apache.cocoon.components.ChainedConfiguration;
import org.apache.cocoon.components.source.impl.SitemapSourceInfo;
-import org.apache.cocoon.core.container.spring.CocoonXmlWebApplicationContext;
+import org.apache.cocoon.core.container.spring.NameForAliasAware;
import org.apache.cocoon.environment.Environment;
import org.apache.cocoon.environment.ForwardRedirector;
import org.apache.cocoon.environment.Redirector;
@@ -48,6 +48,8 @@
import org.apache.cocoon.util.location.Location;
import org.apache.cocoon.util.location.LocationImpl;
import org.apache.commons.jci.listeners.NotificationListener;
+import org.springframework.beans.factory.BeanFactory;
+import org.springframework.beans.factory.DisposableBean;
/**
* The concrete implementation of {@link Processor}, containing the evaluation tree and associated
@@ -99,8 +101,8 @@
/** no listeners by default */
private Map classpathListeners = Collections.EMPTY_MAP;
- /** Application Context for this sitemap. */
- protected CocoonXmlWebApplicationContext applicationContext;
+ /** Bean Factory for this sitemap. */
+ protected BeanFactory beanFactory;
/**
* Builds a concrete processig, given the wrapping processor
@@ -130,7 +132,7 @@
}
/** Set the processor data, result of the treebuilder job */
- public void setProcessorData(CocoonXmlWebApplicationContext appContext,
+ public void setProcessorData(BeanFactory beanFactory,
ClassLoader classloader,
ProcessingNode rootNode,
List disposableNodes,
@@ -140,8 +142,8 @@
throw new IllegalStateException("setProcessorData() can only be called once");
}
- this.applicationContext = appContext;
- this.manager = (ServiceManager)this.applicationContext.getBean(ServiceManager.class.getName());
+ this.beanFactory = beanFactory;
+ this.manager = (ServiceManager)this.beanFactory.getBean(ServiceManager.class.getName());
this.classloader = classloader;
this.rootNode = rootNode;
this.disposableNodes = disposableNodes;
@@ -182,7 +184,9 @@
// and now check for new configurations
for(int m = 0; m < childs.length; m++) {
- final String r = this.applicationContext.getNameForAlias(childs[m].getName());
+ String r = childs[m].getName();
+ if (this.beanFactory instanceof NameForAliasAware)
+ r = ((NameForAliasAware)this.beanFactory).getNameForAlias(r);
this.sitemapComponentConfigurations.put(r, new ChainedConfiguration(childs[m],
(ChainedConfiguration)this.sitemapComponentConfigurations.get(r)));
}
@@ -421,9 +425,15 @@
// dispose listeners
this.disposeListeners(this.enterSitemapEventListeners);
this.disposeListeners(this.leaveSitemapEventListeners);
- if ( this.applicationContext != null ) {
- this.applicationContext.destroy();
- this.applicationContext = null;
+ if ( this.beanFactory != null ) {
+ if (this.beanFactory instanceof DisposableBean)
+ try {
+ ((DisposableBean)this.beanFactory).destroy();
+ } catch (Exception e) {
+ // Not much to do
+ this.getLogger().error("Can't destory the Spring context", e);
+ }
+ this.beanFactory = null;
}
}
Modified: cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/DefaultTreeBuilder.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/DefaultTreeBuilder.java?rev=381074&r1=381073&r2=381074&view=diff
==============================================================================
--- cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/DefaultTreeBuilder.java (original)
+++ cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/DefaultTreeBuilder.java Sun Feb 26 01:48:01 2006
@@ -41,7 +41,6 @@
import org.apache.cocoon.components.source.SourceUtil;
import org.apache.cocoon.components.treeprocessor.variables.VariableResolverFactory;
import org.apache.cocoon.components.treeprocessor.variables.VariableResolver;
-import org.apache.cocoon.core.container.spring.CocoonXmlWebApplicationContext;
import org.apache.cocoon.sitemap.PatternException;
import org.apache.cocoon.sitemap.SitemapParameters;
import org.apache.cocoon.util.location.Location;
@@ -49,6 +48,7 @@
import org.apache.cocoon.util.location.LocationUtils;
import org.apache.excalibur.source.Source;
import org.apache.excalibur.source.SourceResolver;
+import org.springframework.beans.factory.BeanFactory;
/**
*
@@ -96,7 +96,7 @@
*/
private ServiceManager itsManager;
- private CocoonXmlWebApplicationContext itsApplicationContext;
+ private BeanFactory itsApplicationContext;
/**
* The classloader for the processor that we are building.
@@ -218,7 +218,7 @@
*
* @return a component manager
*/
- protected abstract CocoonXmlWebApplicationContext createApplicationContext(ClassLoader classloader, Context context, Configuration tree)
+ protected abstract BeanFactory createApplicationContext(ClassLoader classloader, Context context, Configuration tree)
throws Exception;
@@ -239,7 +239,7 @@
/**
* @see org.apache.cocoon.components.treeprocessor.TreeBuilder#getApplicationContext()
*/
- public CocoonXmlWebApplicationContext getApplicationContext() {
+ public BeanFactory getApplicationContext() {
return this.itsApplicationContext;
}
Modified: cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/TreeBuilder.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/TreeBuilder.java?rev=381074&r1=381073&r2=381074&view=diff
==============================================================================
--- cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/TreeBuilder.java (original)
+++ cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/TreeBuilder.java Sun Feb 26 01:48:01 2006
@@ -19,7 +19,7 @@
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
-import org.apache.cocoon.core.container.spring.CocoonXmlWebApplicationContext;
+import org.springframework.beans.factory.BeanFactory;
/**
*
@@ -40,7 +40,7 @@
}
}
- CocoonXmlWebApplicationContext getApplicationContext();
+ BeanFactory getApplicationContext();
ClassLoader getBuiltProcessorClassLoader();
Modified: cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/SitemapLanguage.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/SitemapLanguage.java?rev=381074&r1=381073&r2=381074&view=diff
==============================================================================
--- cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/SitemapLanguage.java (original)
+++ cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/SitemapLanguage.java Sun Feb 26 01:48:01 2006
@@ -59,6 +59,7 @@
import org.apache.regexp.RE;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanCreationException;
+import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
@@ -103,7 +104,7 @@
* Build a component manager with the contents of the <map:components> element of
* the tree.
*/
- protected CocoonXmlWebApplicationContext createApplicationContext(ClassLoader classloader, Context context, Configuration config)
+ protected BeanFactory createApplicationContext(ClassLoader classloader, Context context, Configuration config)
throws Exception {
// Create the classloader, if needed.
Modified: cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/CocoonXmlWebApplicationContext.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/CocoonXmlWebApplicationContext.java?rev=381074&r1=381073&r2=381074&view=diff
==============================================================================
--- cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/CocoonXmlWebApplicationContext.java (original)
+++ cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/CocoonXmlWebApplicationContext.java Sun Feb 26 01:48:01 2006
@@ -59,7 +59,7 @@
*/
public class CocoonXmlWebApplicationContext
extends XmlWebApplicationContext
- implements EnterSitemapEventListener, LeaveSitemapEventListener, ApplicationListener {
+ implements EnterSitemapEventListener, LeaveSitemapEventListener, ApplicationListener, NameForAliasAware {
public static final String APPLICATION_CONTEXT_REQUEST_ATTRIBUTE = "application-context";
Added: cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/NameForAliasAware.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/NameForAliasAware.java?rev=381074&view=auto
==============================================================================
--- cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/NameForAliasAware.java (added)
+++ cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/NameForAliasAware.java Sun Feb 26 01:48:01 2006
@@ -0,0 +1,29 @@
+/*
+ * Copyright 1999-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.
+ */
+package org.apache.cocoon.core.container.spring;
+
+/**
+ * $Id$
+ */
+public interface NameForAliasAware {
+ /**
+ * Give the real component name given a alias name, return the given name if
+ * its not an alias.
+ * @param alias
+ * @return
+ */
+ public String getNameForAlias(String alias);
+}
Propchange: cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/NameForAliasAware.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/trunk/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/NameForAliasAware.java
------------------------------------------------------------------------------
svn:keywords = Id