cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From giac...@apache.org
Subject svn commit: r472163 - in /cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon: configuration/ core/container/spring/
Date Tue, 07 Nov 2006 16:52:51 GMT
Author: giacomo
Date: Tue Nov  7 08:52:50 2006
New Revision: 472163

URL: http://svn.apache.org/viewvc?view=rev&rev=472163
Log:
get the running mode determination fixed

Added:
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/RunningModeHelper.java
  (with props)
Modified:
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/configuration/Settings.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/java/org/apache/cocoon/core/container/spring/SitemapElementParser.java

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/configuration/Settings.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/configuration/Settings.java?view=diff&rev=472163&r1=472162&r2=472163
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/configuration/Settings.java
(original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/configuration/Settings.java
Tue Nov  7 08:52:50 2006
@@ -32,9 +32,6 @@
     /** Name of the property specifying a custom user properties file. */
     String PROPERTY_USER_SETTINGS = "org.apache.cocoon.settings";
 
-    /** Name of the property specifying the running mode. */
-    String PROPERTY_RUNNING_MODE = "org.apache.cocoon.mode";
-
     /**
      * This parameter is used to list classes that should be loaded at
      * initialization time of the servlet. For example, JDBC Drivers used need to

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=472163&r1=472162&r2=472163
==============================================================================
--- 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
Tue Nov  7 08:52:50 2006
@@ -280,5 +280,4 @@
         beanDef.getPropertyValues().addPropertyValue("beanNameSeparator", "/");
         this.register(beanDef, CocoonPropertyOverrideConfigurer.class.getName(), parserContext.getRegistry());
     }
-
 }

Added: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/RunningModeHelper.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/RunningModeHelper.java?view=auto&rev=472163
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/RunningModeHelper.java
(added)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/RunningModeHelper.java
Tue Nov  7 08:52:50 2006
@@ -0,0 +1,66 @@
+/* 
+ * 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.core.container.spring;
+
+import org.apache.cocoon.configuration.SettingsDefaults;
+
+/**
+ * Helper class to determine the running mode
+ *
+ * @since 2.2
+ * @version $Id$
+ */
+public class RunningModeHelper
+{
+
+    public final static String PROPERTY_RUNNING_MODE = "org.apache.cocoon.mode";
+    
+    // determine an ev. set running mode from the system properties
+    private static final String SYSTEM_RUNNING_MODE;
+    static {
+        String mode = null;
+        try {
+            mode = System.getProperty( PROPERTY_RUNNING_MODE, null );
+        } catch (SecurityException se) {
+            // we ignore this
+        }
+        SYSTEM_RUNNING_MODE = mode;
+    }
+
+    /** Name of the property specifying the running mode. */
+    private RunningModeHelper()
+    {
+        // never initiate
+    }
+
+    /** 
+     * Determine the runningmode. 
+     * A non-null system property will have precedence over everything else.
+     * The system default running mode will be used if the passed parameter mode is null.
+     */
+    public static String determineRunningMode(String mode) {
+        if(SYSTEM_RUNNING_MODE != null) {
+            return SYSTEM_RUNNING_MODE;
+        }
+        if(mode == null) {
+            return SettingsDefaults.DEFAULT_RUNNING_MODE;
+        }
+        return mode;
+    }
+}

Propchange: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/RunningModeHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native

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=472163&r1=472162&r2=472163
==============================================================================
--- 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
Tue Nov  7 08:52:50 2006
@@ -169,7 +169,7 @@
      */
     protected MutableSettings createSettings() {
         // get the running mode
-        final String mode = getSystemProperty(Settings.PROPERTY_RUNNING_MODE, this.runningMode);
+        final String mode = RunningModeHelper.determineRunningMode( 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=472163&r1=472162&r2=472163
==============================================================================
--- 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
Tue Nov  7 08:52:50 2006
@@ -60,7 +60,7 @@
                 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);
+        final String runningMode = RunningModeHelper.determineRunningMode( this.getAttributeValue(element,
RUNNING_MODE_ATTR, null) );
         if (runningMode != null) {
             beanDef.getPropertyValues().addPropertyValue("runningMode", runningMode);
         }

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/SitemapElementParser.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/SitemapElementParser.java?view=diff&rev=472163&r1=472162&r2=472163
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/SitemapElementParser.java
(original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/SitemapElementParser.java
Tue Nov  7 08:52:50 2006
@@ -119,7 +119,7 @@
      * @see org.springframework.beans.factory.xml.BeanDefinitionParser#parse(org.w3c.dom.Element,
org.springframework.beans.factory.xml.ParserContext)
      */
     public BeanDefinition parse(Element element, ParserContext parserContext) {
-        final String runningMode = this.getAttributeValue(element, SettingsElementParser.RUNNING_MODE_ATTR,
SettingsDefaults.DEFAULT_RUNNING_MODE);
+        final String runningMode = RunningModeHelper.determineRunningMode( this.getAttributeValue(element,
SettingsElementParser.RUNNING_MODE_ATTR, null) );
         final String location = element.getAttribute("location");
         final ResourceLoader resourceLoader = parserContext.getReaderContext().getReader().getResourceLoader();
         try {



Mime
View raw message