You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by cz...@apache.org on 2006/09/28 15:41:20 UTC
svn commit: r450853 - in /cocoon/trunk/core/cocoon-core/src/main:
java/org/apache/cocoon/components/
java/org/apache/cocoon/core/container/spring/
resources/org/apache/cocoon/core/container/spring/
Author: cziegeler
Date: Thu Sep 28 06:41:19 2006
New Revision: 450853
URL: http://svn.apache.org/viewvc?view=rev&rev=450853
Log:
Remove unused stuff and make add possibility to specify running mode in spring application context (instead of using a system property)
Modified:
cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/ContextHelper.java
cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/LifecycleHelper.java
cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/AbstractElementParser.java
cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/SettingsBeanFactoryPostProcessor.java
cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/SettingsElementParser.java
cocoon/trunk/core/cocoon-core/src/main/resources/org/apache/cocoon/core/container/spring/cocoon.xsd
Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/ContextHelper.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/ContextHelper.java?view=diff&rev=450853&r1=450852&r2=450853
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/ContextHelper.java (original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/ContextHelper.java Thu Sep 28 06:41:19 2006
@@ -20,16 +20,17 @@
import org.apache.avalon.framework.context.Context;
import org.apache.avalon.framework.context.ContextException;
-import org.apache.avalon.framework.service.ServiceManager;
import org.apache.cocoon.environment.ObjectModelHelper;
import org.apache.cocoon.environment.Request;
import org.apache.cocoon.environment.Response;
+import org.apache.cocoon.processing.ProcessInfoProvider;
/**
* A set of constants and methods to access the content of the context
* object. Some of the constants are defined in {@link org.apache.cocoon.Constants}.
*
* @version $Id$
+ * @deprecated Use the {@link ProcessInfoProvider} instead.
*/
public final class ContextHelper {
@@ -90,20 +91,4 @@
throw new ContextResourceNotFoundException("Unable to get the object model from the context.", ce);
}
}
-
- /**
- * Return the current sitemap service manager
- * @param context The component context
- * @return The sitemap manager if currently a request is processed
- * @since 2.2
- */
- public static final ServiceManager getSitemapServiceManager(Context context) {
- // the service manager is always present
- try {
- return (ServiceManager)context.get(CONTEXT_SITEMAP_SERVICE_MANAGER);
- } catch (ContextException ce) {
- throw new ContextResourceNotFoundException("Unable to get the service manager from the context.", ce);
- }
- }
-
}
Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/LifecycleHelper.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/LifecycleHelper.java?view=diff&rev=450853&r1=450852&r2=450853
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/LifecycleHelper.java (original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/LifecycleHelper.java Thu Sep 28 06:41:19 2006
@@ -34,7 +34,7 @@
* Utility class for setting up Avalon components. Similar to Excalibur's
* <code>DefaultComponentFactory</code>, but on existing objects.
* <p>
- *
+ * @deprecated
* @version $Id$
*/
public class LifecycleHelper {
Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/AbstractElementParser.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/AbstractElementParser.java?view=diff&rev=450853&r1=450852&r2=450853
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/AbstractElementParser.java (original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/AbstractElementParser.java Thu Sep 28 06:41:19 2006
@@ -35,6 +35,7 @@
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
+import org.w3c.dom.Element;
/**
* This is a base class for all bean definition parser used in Cocoon.
@@ -47,6 +48,21 @@
/** Logger (we use the same logging mechanism as Spring!) */
protected final Log logger = LogFactory.getLog(getClass());
+
+ /** Get the value of an attribute or if the attribute is not present
+ * return the default value.
+ * For any strange reason, getAttribute() does not return null if the
+ * attribute is not present but an empty string!
+ */
+ protected String getAttributeValue(Element element,
+ String attributeName,
+ String defaultValue) {
+ String value = element.getAttribute(attributeName);
+ if ( value == null || value.trim().length() == 0 ) {
+ value = defaultValue;
+ }
+ return value;
+ }
/**
* Register a bean definition.
Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/SettingsBeanFactoryPostProcessor.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/SettingsBeanFactoryPostProcessor.java?view=diff&rev=450853&r1=450852&r2=450853
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/SettingsBeanFactoryPostProcessor.java (original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/SettingsBeanFactoryPostProcessor.java Thu Sep 28 06:41:19 2006
@@ -45,6 +45,12 @@
public class SettingsBeanFactoryPostProcessor
extends AbstractSettingsBeanFactoryPostProcessor {
+ protected String runningMode = SettingsDefaults.DEFAULT_RUNNING_MODE;
+
+ public void setRunningMode(String runningMode) {
+ this.runningMode = runningMode;
+ }
+
/**
* Initialize this processor.
* Setup the settings object.
@@ -153,7 +159,7 @@
*/
protected MutableSettings createSettings() {
// get the running mode
- final String mode = getSystemProperty(Settings.PROPERTY_RUNNING_MODE, SettingsDefaults.DEFAULT_RUNNING_MODE);
+ final String mode = getSystemProperty(Settings.PROPERTY_RUNNING_MODE, this.runningMode);
/*
if ( !Arrays.asList(SettingsDefaults.RUNNING_MODES).contains(mode) ) {
Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/SettingsElementParser.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/SettingsElementParser.java?view=diff&rev=450853&r1=450852&r2=450853
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/SettingsElementParser.java (original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/SettingsElementParser.java Thu Sep 28 06:41:19 2006
@@ -21,6 +21,7 @@
import org.apache.cocoon.configuration.Settings;
import org.springframework.beans.factory.BeanDefinitionStoreException;
import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.beans.factory.xml.ParserContext;
import org.w3c.dom.Element;
@@ -37,6 +38,9 @@
/** The name of the configuration attribute to use a different processor class. */
public static final String PROCESSOR_CLASS_NAME_ATTR = "processorClassName";
+ /** The name of the configuration attribute to specify the running mode. */
+ public static final String RUNNING_MODE_ATTR = "runningMode";
+
/**
* @see org.springframework.beans.factory.xml.BeanDefinitionParser#parse(org.w3c.dom.Element, org.springframework.beans.factory.xml.ParserContext)
*/
@@ -46,12 +50,16 @@
} catch (Exception e) {
throw new BeanDefinitionStoreException("Unable to read spring configurations.",e);
}
- String componentClassName = SettingsBeanFactoryPostProcessor.class.getName();
- String value = element.getAttribute(PROCESSOR_CLASS_NAME_ATTR);
- if ( value != null && value.trim().length() > 0 ) {
- componentClassName = element.getAttribute(PROCESSOR_CLASS_NAME_ATTR);
+ // create bean definition for settings object
+ final String componentClassName = this.getAttributeValue(element, PROCESSOR_CLASS_NAME_ATTR, SettingsBeanFactoryPostProcessor.class.getName());
+ final RootBeanDefinition beanDef = this.createBeanDefinition(componentClassName, "init", false);
+ // if running mode is specified add it as a property
+ final String runningMode = this.getAttributeValue(element, RUNNING_MODE_ATTR, null);
+ if ( runningMode != null ) {
+ beanDef.getPropertyValues().addPropertyValue("runningMode", runningMode);
}
- this.addComponent(componentClassName, Settings.ROLE, "init", false, parserContext.getRegistry());
+ // register
+ this.register(beanDef, Settings.ROLE, parserContext.getRegistry());
return null;
}
Modified: cocoon/trunk/core/cocoon-core/src/main/resources/org/apache/cocoon/core/container/spring/cocoon.xsd
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/resources/org/apache/cocoon/core/container/spring/cocoon.xsd?view=diff&rev=450853&r1=450852&r2=450853
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/resources/org/apache/cocoon/core/container/spring/cocoon.xsd (original)
+++ cocoon/trunk/core/cocoon-core/src/main/resources/org/apache/cocoon/core/container/spring/cocoon.xsd Thu Sep 28 06:41:19 2006
@@ -15,6 +15,7 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
+<!-- @version $Id$ -->
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://org.apache.cocoon/core"
xmlns:tns="http://org.apache.cocoon/core">
@@ -23,6 +24,7 @@
<xsd:complexType name="settingsType">
<xsd:attribute name="processorClassName" type="xsd:string" use="optional"></xsd:attribute>
+ <xsd:attribute name="runningMode" type="xsd:string" use="optional"></xsd:attribute>
</xsd:complexType>
<xsd:element name="sitemap" type="tns:sitemapType"/>