You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by ep...@apache.org on 2004/01/31 02:34:51 UTC

cvs commit: jakarta-turbine-3/src/java/org/apache/turbine/modules ModuleLoader.java

epugh       2004/01/30 17:34:51

  Modified:    src/java/org/apache/turbine TurbineConfig.java Turbine.java
               .        project.xml project.properties
               src/java/org/apache/turbine/pipeline
                        DefaultSessionTimeoutValve.java
               src/java/org/apache/turbine/modules ModuleLoader.java
  Log:
  Fixes for latest commons-configuration and updated fulcrum.
  
  Revision  Changes    Path
  1.8       +7 -1      jakarta-turbine-3/src/java/org/apache/turbine/TurbineConfig.java
  
  Index: TurbineConfig.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-3/src/java/org/apache/turbine/TurbineConfig.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- TurbineConfig.java	16 Apr 2002 21:58:53 -0000	1.7
  +++ TurbineConfig.java	31 Jan 2004 01:34:50 -0000	1.8
  @@ -111,6 +111,12 @@
           = LogFactory.getLog( TurbineConfig.class );
   
       /**
  +     * Servlet initialization parameter name for the path to
  +     * TurbineConfiguration.xml file used by Turbine
  +     */
  +    public static final String CONFIGURATION_PATH_KEY = "configuration"; 
  +    
  +    /**
        * Servlet initialization parameter name for the path to the
        * TurbineResources.properties file (<code>properties</code>).
        */
  
  
  
  1.46      +91 -42    jakarta-turbine-3/src/java/org/apache/turbine/Turbine.java
  
  Index: Turbine.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-3/src/java/org/apache/turbine/Turbine.java,v
  retrieving revision 1.45
  retrieving revision 1.46
  diff -u -r1.45 -r1.46
  --- Turbine.java	17 Jul 2003 02:36:31 -0000	1.45
  +++ Turbine.java	31 Jan 2004 01:34:50 -0000	1.46
  @@ -78,6 +78,7 @@
   import org.apache.fulcrum.TurbineServices;
   
   import org.apache.commons.configuration.Configuration;
  +import org.apache.commons.configuration.ConfigurationFactory;
   import org.apache.commons.configuration.PropertiesConfiguration;
   
   import org.apache.turbine.modules.ModuleLoader;
  @@ -182,11 +183,8 @@
               {
                   // Setup static configuration (using default properties file).
                   ServletContext context = config.getServletContext();
  -                String trProps =
  -                    findInitParameter(context, config,
  -                                      TurbineConfig.PROPERTIES_KEY,
  -                                      "TurbineResources.properties");
  -                configure(config, context, trProps);
  +            
  +                configure(config, context);
               }
               catch ( Exception e )
               {
  @@ -544,15 +542,10 @@
        * servlet.
        * @param context Servlet container communication channel.
        * Provides access to global initialization parameters.
  -     * @param propsFile The abstract path to your
  -     * <code>TurbineResources.properties</code> file (including file
  -     * name), relative to web application root.  Defaults to {@link
  -     * org.apache.turbine.TurbineConstants#DEFAULT_TURBINE_RESOURCES}.
        * @exception Exception a generic exception.
        */
       public static synchronized void configure(ServletConfig config,
  -                                              ServletContext context,
  -                                              String propsFile)
  +                                              ServletContext context)
           throws Exception
       {
           try
  @@ -577,33 +570,9 @@
           // directories in the future.
           createRuntimeDirectories(context, config);
   
  -        // Get the full path to the properties file.
  -        if (propsFile == null)
  -        {
  -            propsFile = DEFAULT_TURBINE_RESOURCES;
  -        }
  -        String propsPath = getRealPath(propsFile);
  +      
   
  -        // This is for our log4j setup. We are embedding
  -        // the log4j configuration in the TRP but log4j
  -        // must be initialized with a Properties object.
  -        // We load it here so that we can add a "webapp"
  -        // property that will be used in the form of
  -        // ${webapp} in log4j properties. We need this
  -        // so that the log files can be placed in
  -        // the webapp space.
  -        Properties p = new Properties();
  -        p.load(new FileInputStream(propsPath));
  -        p.setProperty(APPLICATION_ROOT, getApplicationRoot());
  -
  -        // FIXME: Configures log4j directly with the supplied properties. The
  -        //        plan is to eliminate this, and instead allow logging to be
  -        //        initialized by a component, which could init any logging
  -        //        mechanism supported by commons-logging. However it is
  -        //        important that logging be intialized early, so we will need
  -        //        to address that in the component loader.
  -
  -        PropertyConfigurator.configure(p);
  +      
   
           // We want to save the ServletConfig and
           // ServletContext so that we can share these objects
  @@ -623,10 +592,64 @@
           // case it is the webapp context.
           serviceManager.setApplicationRoot(getApplicationRoot());
   
  -        // This should eventually be a Configuration
  -        // interface so that service and app configuration
  -        // can be stored anywhere.
  -        configuration = (Configuration) new PropertiesConfiguration(propsPath);
  +        
  +        //
  +        // Now we run the Turbine configuration code. There are two ways
  +        // to configure Turbine:
  +        //
  +        // a) By supplying an web.xml init parameter called "configuration"
  +        //
  +        // <init-param>
  +        //   <param-name>configuration</param-name>
  +        //   <param-value>/WEB-INF/conf/turbine.xml</param-value>
  +        // </init-param>
  +        //
  +        // This loads an XML based configuration file.
  +        //
  +        // b) By supplying an web.xml init parameter called "properties"
  +        //
  +        // <init-param>
  +        //   <param-name>properties</param-name>
  +        //   <param-value>/WEB-INF/conf/TurbineResources.properties</param-value>
  +        // </init-param>
  +        //
  +        // This loads a Properties based configuration file. Actually, these are
  +        // extended properties as provided by commons-configuration
  +        //
  +        // If neither a) nor b) is supplied, Turbine will fall back to the
  +        // known behaviour of loading a properties file called
  +        // /WEB-INF/conf/TurbineResources.properties relative to the
  +        // web application root.
  +
  +        String confFile= findInitParameter(context, config, 
  +        		TurbineConfig.CONFIGURATION_PATH_KEY, 
  +				null);
  +
  +        String confPath;
  +        String confStyle = "unset";
  +
  +        if (StringUtils.isNotEmpty(confFile))
  +        {
  +        	confPath = getRealPath(confFile);
  +        	ConfigurationFactory configurationFactory = new ConfigurationFactory(confPath);
  +        	configurationFactory.setBasePath(getApplicationRoot());
  +        	configuration = configurationFactory.getConfiguration();
  +        	confStyle = "XML";
  +        }
  +        else
  +        {
  +        	confFile = findInitParameter(context, config,
  +        			TurbineConfig.PROPERTIES_KEY,
  +        	"TurbineResources.properties");
  +
  +        	confPath = getRealPath(confFile);
  +
  +        	// This should eventually be a Configuration
  +        	// interface so that service and app configuration
  +        	// can be stored anywhere.
  +        	configuration = (Configuration) new PropertiesConfiguration(confPath);
  +        	confStyle = "Properties";
  +        }        
   
           // We want to set a few values in the configuration so
           // that ${variable} interpolation will work for
  @@ -637,6 +660,32 @@
           configuration.setProperty(WEBAPP_ROOT,
               config.getServletContext().getRealPath(""));
   
  +        // This is for our log4j setup. We are embedding
  +        // the log4j configuration in the TRP but log4j
  +        // must be initialized with a Properties object.
  +        // We load it here so that we can add a "webapp"
  +        // property that will be used in the form of
  +        // ${webapp} in log4j properties. We need this
  +        // so that the log files can be placed in
  +        // the webapp space.
  +        String trProps =
  +        	findInitParameter(context, config,
  +        			TurbineConfig.PROPERTIES_KEY,
  +        	"TurbineResources.properties");
  +        String trPropsFile = getRealPath(trProps);
  +        Properties p = new Properties();
  +        p.load(new FileInputStream(trPropsFile));
  +        p.setProperty(APPLICATION_ROOT, getApplicationRoot());
  +
  +        // FIXME: Configures log4j directly with the supplied properties. The
  +        //        plan is to eliminate this, and instead allow logging to be
  +        //        initialized by a component, which could init any logging
  +        //        mechanism supported by commons-logging. However it is
  +        //        important that logging be intialized early, so we will need
  +        //        to address that in the component loader.
  +
  +        PropertyConfigurator.configure(p);        
  +        
           serviceManager.setConfiguration(configuration);
   
           // Initialize the service manager. Services
  
  
  
  1.45      +2 -2      jakarta-turbine-3/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-3/project.xml,v
  retrieving revision 1.44
  retrieving revision 1.45
  diff -u -r1.44 -r1.45
  --- project.xml	30 Jan 2004 21:20:57 -0000	1.44
  +++ project.xml	31 Jan 2004 01:34:50 -0000	1.45
  @@ -113,7 +113,7 @@
       </dependency>
       <dependency>
         <id>commons-configuration</id>
  -      <version>1.0-dev-3.20030607.194155</version>
  +      <version>20040130.152659</version>
       </dependency>
       <dependency>
         <id>commons-xo</id>
  @@ -145,7 +145,7 @@
       </dependency>
       <dependency>
         <id>fulcrum</id>
  -      <version>3.0-b2-dev</version>
  +      <version>20040130.235430</version>
       </dependency>
       <dependency>
         <id>commons-httpclient</id>
  
  
  
  1.2       +1 -1      jakarta-turbine-3/project.properties
  
  Index: project.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-3/project.properties,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- project.properties	11 Apr 2003 00:46:43 -0000	1.1
  +++ project.properties	31 Jan 2004 01:34:50 -0000	1.2
  @@ -1,7 +1,7 @@
   # -------------------------------------------------------------------
   # P R O J E C T  P R O P E R T I E S
   # -------------------------------------------------------------------
  -
  +maven.repo.remote=http://www.ibiblio.org/maven/,http://jakarta.apache.org/turbine/repo
   maven.checkstyle.format = turbine
   #maven.home = ${user.home}/maven
   
  
  
  
  1.9       +4 -6      jakarta-turbine-3/src/java/org/apache/turbine/pipeline/DefaultSessionTimeoutValve.java
  
  Index: DefaultSessionTimeoutValve.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-3/src/java/org/apache/turbine/pipeline/DefaultSessionTimeoutValve.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- DefaultSessionTimeoutValve.java	23 Nov 2003 00:42:22 -0000	1.8
  +++ DefaultSessionTimeoutValve.java	31 Jan 2004 01:34:50 -0000	1.9
  @@ -89,11 +89,9 @@
           {
               // Get the session timeout.  Use String so we know whether
               // the timeout was specified or not.
  -            String timeoutString = cfg.getString(SESSION_TIMEOUT);
  -            if (timeoutString != null && timeoutString.length() > 0) 
  -            {
  -                timeout = new Integer(timeoutString);
  -            }
  +        	if(cfg.containsKey(SESSION_TIMEOUT)){
  +        		timeout = Integer.valueOf(cfg.getString(SESSION_TIMEOUT));
  +        	}
           }
       }
   
  
  
  
  1.12      +7 -8      jakarta-turbine-3/src/java/org/apache/turbine/modules/ModuleLoader.java
  
  Index: ModuleLoader.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-3/src/java/org/apache/turbine/modules/ModuleLoader.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- ModuleLoader.java	16 Apr 2002 22:24:02 -0000	1.11
  +++ ModuleLoader.java	31 Jan 2004 01:34:50 -0000	1.12
  @@ -56,16 +56,15 @@
   
   import java.util.Iterator;
   import java.util.List;
  -import java.util.Vector;
   import java.util.Map;
  -import org.apache.commons.configuration.Configuration;
  -import org.apache.turbine.Turbine;
  -import org.apache.turbine.TurbineException;
  +
   import org.apache.commons.collections.FastArrayList;
   import org.apache.commons.collections.FastHashMap;
  -import org.apache.commons.logging.LogFactory;
  +import org.apache.commons.configuration.Configuration;
   import org.apache.commons.logging.Log;
  -
  +import org.apache.commons.logging.LogFactory;
  +import org.apache.turbine.Turbine;
  +import org.apache.turbine.TurbineException;
   import org.apache.turbine.pipeline.PipelineUtil;
   
   /**
  @@ -166,7 +165,7 @@
   
           // Grab our list of module packages so that we can
           // add them to the search list of the ModuleLoader.
  -        Vector modulePackages = configuration.getVector(Turbine.MODULE_PACKAGES);
  +        List modulePackages = configuration.getList(Turbine.MODULE_PACKAGES);
   
           Iterator i = modulePackages.iterator();
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org