mpoeschl    02/02/06 09:26:34

  Modified:    src/java/org/apache/turbine/pipeline DefaultTargetValve.java
                        DefaultSessionTimeoutValve.java
               src/java/org/apache/turbine/services/pull
                        TurbinePullService.java
               src/java/org/apache/turbine/modules ModuleLoader.java
               src/java/org/apache/turbine Turbine.java
  Log:
  use stratum.configuration instead of ExtendedProperties
  
  Revision  Changes    Path
  1.11      +34 -12    
jakarta-turbine-3/src/java/org/apache/turbine/pipeline/DefaultTargetValve.java
  
  Index: DefaultTargetValve.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-3/src/java/org/apache/turbine/pipeline/DefaultTargetValve.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- DefaultTargetValve.java   6 Feb 2002 03:08:33 -0000       1.10
  +++ DefaultTargetValve.java   6 Feb 2002 17:26:34 -0000       1.11
  @@ -3,7 +3,7 @@
   /* ====================================================================
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 2001 The Apache Software Foundation.  All rights
  + * Copyright (c) 2001-2002 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -57,8 +57,8 @@
   import java.io.IOException;
   import java.util.Enumeration;
   
  -import org.apache.commons.collections.ExtendedProperties;
   import org.apache.fulcrum.security.util.AccessControlList;
  +import org.apache.stratum.configuration.Configuration;
   import org.apache.turbine.DynamicURI;
   import org.apache.turbine.Turbine;
   import org.apache.turbine.TurbineConstants;
  @@ -81,12 +81,17 @@
    * @author <a href="mailto:[EMAIL PROTECTED]";>Daniel Rall</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Mike Haberman</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>James Taylor</a>
  - * @version $Id: DefaultTargetValve.java,v 1.10 2002/02/06 03:08:33 jmcnally Exp $
  +<<<<<<< DefaultTargetValve.java
  + * @author <a href="mailto:[EMAIL PROTECTED]";>Martin Poeschl</a>
  + * @version $Id: DefaultTargetValve.java,v 1.11 2002/02/06 17:26:34 mpoeschl Exp $
  +=======
  + * @version $Id: DefaultTargetValve.java,v 1.11 2002/02/06 17:26:34 mpoeschl Exp $
  +>>>>>>> 1.10
    */
   public class DefaultTargetValve
       extends AbstractValve
   {
  -    private static final Category log = 
  +    private static final Category log =
            Category.getInstance(DefaultTargetValve.class);
   
       protected static final String DEFAULT_MODULE_TYPE = "screens";
  @@ -100,12 +105,12 @@
        */
       public DefaultTargetValve()
       {
  -        ExtendedProperties cfg = Turbine.getConfiguration();
  +        Configuration cfg = Turbine.getConfiguration();
   
           if (cfg != null)
           {
               // Get the module type
  -            targetModuleType = 
  +            targetModuleType =
                   cfg.getString("pipeline.default.targetModuleType",
                                 DEFAULT_MODULE_TYPE);
           }
  @@ -118,7 +123,7 @@
           throws IOException, TurbineException
       {
           try
  -        { 
  +        {
               execute(data);
               finished(data);
           }
  @@ -143,9 +148,25 @@
           data.getResponse().setContentType(data.getContentType());
   
           // Get the target that will determine the template / layout
  -        
  +
           String target = data.getTarget();
   
  +<<<<<<< DefaultTargetValve.java
  +        // Get the template context, already populated by any context
  +        // builders that were found for this target
  +
  +        TemplateContext context = Module.getTemplateContext( data );
  +
  +        context.put( "template", target );
  +
  +        // Resolve the layout template for this target
  +
  +        String layout = Turbine.getResolver().getTemplate("layouts", target);
  +
  +        // Use the renderer to render the layout,
  +
  +        render( data, context, layout );
  +=======
           if ( target != null ) 
           {
               // Get the template context, already populated by any context
  @@ -171,6 +192,7 @@
                   log.debug( "Target was null." );
               }
           }
  +>>>>>>> 1.10
       }
   
       protected void render( RunData data, TemplateContext context, String target  )
  @@ -182,17 +204,17 @@
           }
   
           Renderer r = new Renderer( data );
  -        
  +
           // FIXME: Can we remove hardcoding here?
  -        
  +
           context.put( "renderer", r );
   
           // Render the target
  -        
  +
           String out = r.render( target );
   
           // Write the composed string to the response
  -        
  +
           data.getOut().print( out );
       }
   
  
  
  
  1.4       +6 -5      
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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DefaultSessionTimeoutValve.java   24 Jan 2002 03:55:26 -0000      1.3
  +++ DefaultSessionTimeoutValve.java   6 Feb 2002 17:26:34 -0000       1.4
  @@ -3,7 +3,7 @@
   /* ====================================================================
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 2001 The Apache Software Foundation.  All rights
  + * Copyright (c) 2001-2002 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -57,7 +57,7 @@
   import java.io.IOException;
   import java.util.Enumeration;
   
  -import org.apache.commons.collections.ExtendedProperties;
  +import org.apache.stratum.configuration.Configuration;
   import org.apache.turbine.Turbine;
   import org.apache.turbine.TurbineConstants;
   import org.apache.turbine.RunData;
  @@ -71,7 +71,8 @@
    * pipeline (from the Turbine 2.x series).
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Jason van Zyl</a>
  - * @version $Id: DefaultSessionTimeoutValve.java,v 1.3 2002/01/24 03:55:26 jvanzyl 
Exp $
  + * @author <a href="mailto:[EMAIL PROTECTED]";>Martin Poeschl</a>
  + * @version $Id: DefaultSessionTimeoutValve.java,v 1.4 2002/02/06 17:26:34 mpoeschl 
Exp $
    */
   public class DefaultSessionTimeoutValve
       extends AbstractValve
  @@ -79,7 +80,7 @@
   {
       private static final Category log =
           Category.getInstance(DefaultSessionTimeoutValve.class);
  -        
  +
       /**
        * The default session timeout.
        */
  @@ -94,7 +95,7 @@
       public DefaultSessionTimeoutValve()
           throws Exception
       {
  -        ExtendedProperties cfg = Turbine.getConfiguration();
  +        Configuration cfg = Turbine.getConfiguration();
           if (cfg != null)
           {
               // Get the session timeout.
  
  
  
  1.10      +6 -6      
jakarta-turbine-3/src/java/org/apache/turbine/services/pull/TurbinePullService.java
  
  Index: TurbinePullService.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-3/src/java/org/apache/turbine/services/pull/TurbinePullService.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- TurbinePullService.java   21 Jan 2002 01:25:45 -0000      1.9
  +++ TurbinePullService.java   6 Feb 2002 17:26:34 -0000       1.10
  @@ -3,7 +3,7 @@
   /* ====================================================================
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 2001 The Apache Software Foundation.  All rights
  + * Copyright (c) 2001-2002 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -71,7 +71,7 @@
   import org.apache.turbine.TemplateContext;
   import org.apache.turbine.modules.DefaultTemplateContext;
   
  -import org.apache.commons.collections.ExtendedProperties;
  +import org.apache.stratum.configuration.Configuration;
   
   /**
    * <p>
  @@ -144,7 +144,8 @@
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Jason van Zyl</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Sean Legassick</a>
  - * @version $Id: TurbinePullService.java,v 1.9 2002/01/21 01:25:45 jmcnally Exp $
  + * @author <a href="mailto:[EMAIL PROTECTED]";>Martin Poeschl</a>
  + * @version $Id: TurbinePullService.java,v 1.10 2002/02/06 17:26:34 mpoeschl Exp $
    */
   public class TurbinePullService
       extends BaseService
  @@ -310,8 +311,7 @@
       {
           List classes = new ArrayList();
   
  -        ExtendedProperties toolResources =
  -            getConfiguration().subset(keyPrefix);
  +        Configuration toolResources = getConfiguration().subset(keyPrefix);
   
           // There might not be any tools for this prefix
           // so return an empty list.
  @@ -374,7 +374,7 @@
           while (i.hasNext())
           {
               String key = (String)i.next();
  -            tc.put (key, getGlobalContext().get(key));            
  +            tc.put (key, getGlobalContext().get(key));
           }
           return tc;
       }
  
  
  
  1.8       +19 -18    
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.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ModuleLoader.java 30 Dec 2001 08:38:52 -0000      1.7
  +++ ModuleLoader.java 6 Feb 2002 17:26:34 -0000       1.8
  @@ -3,7 +3,7 @@
   /* ====================================================================
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 2001 The Apache Software Foundation.  All rights
  + * Copyright (c) 2001-2002 The Apache Software Foundation. All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -59,13 +59,13 @@
   import java.util.List;
   import java.util.Vector;
   import java.util.Map;
  +import org.apache.stratum.configuration.Configuration;
   import org.apache.turbine.RunData;
   import org.apache.turbine.Turbine;
   import org.apache.turbine.TurbineException;
   import org.apache.turbine.Resolver;
   import org.apache.commons.collections.FastArrayList;
   import org.apache.commons.collections.FastHashMap;
  -import org.apache.commons.collections.ExtendedProperties;
   import org.apache.turbine.Log;
   
   import org.apache.turbine.pipeline.PipelineUtil;
  @@ -74,7 +74,8 @@
    * Load modules for use in the view pipeline.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Jason van Zyl</a>
  - * @version $Id: ModuleLoader.java,v 1.7 2001/12/30 08:38:52 dlr Exp $
  + * @author <a href="mailto:[EMAIL PROTECTED]";>Martin Poeschl</a>
  + * @version $Id: ModuleLoader.java,v 1.8 2002/02/06 17:26:34 mpoeschl Exp $
    */
   public class ModuleLoader
   {
  @@ -106,7 +107,7 @@
        */
       protected boolean scriptingEnabled;
   
  -    protected ExtendedProperties configuration;
  +    protected Configuration configuration;
   
       /**
        * Default constructor.
  @@ -133,7 +134,7 @@
       /**
        * Set the configuration for the module loader
        */
  -    public void setConfiguration(ExtendedProperties configuration)
  +    public void setConfiguration(Configuration configuration)
       {
           this.configuration = configuration;
       }
  @@ -144,7 +145,7 @@
       public void init()
           throws TurbineException
       {
  -        ExtendedProperties moduleTypes = configuration.subset("module.default");
  +        Configuration moduleTypes = configuration.subset("module.default");
   
           if (moduleTypes == null)
           {
  @@ -174,7 +175,7 @@
           {
               addModulePackage((String) i.next());
           }
  -        
  +
           // Add the package for Turbine's default modules.
           // This package must be added last so it is searched
           // for last.
  @@ -196,8 +197,8 @@
       public Module getModule(String type, String name)
           throws Exception
       {
  -        Module module = null; 
  -        
  +        Module module = null;
  +
           Iterator k;
           if (type.equals("actions"))
           {
  @@ -210,18 +211,18 @@
               List names = getPossibleModules(sb.toString());
               k = getAllPossibleModules(names, type);
           }
  -        
  +
           while (k.hasNext())
           {
               String moduleClass = (String) k.next();
  -          
  +
               try
               {
                   Log.debug("[ModuleLoader] Looking for " + moduleClass);
                   module = (Module) Class.forName(moduleClass).newInstance();
                   Log.debug("[ModuleLoader] " + name + " => " + moduleClass);
                   break;
  -            }                        
  +            }
               catch (Exception ignored)
               {
                   // Likely a non-existant class name combination.
  @@ -258,12 +259,12 @@
               {
                   String module = modulePackage + "." + type + "." + m.next();
                   modules.add(module);
  -                
  +
               }
  -            
  +
               // Add default for type
               defaultModules.add(modulePackage + "." + getDefaultModule(type));
  -        }            
  +        }
   
           modules.addAll(defaultModules);
   
  @@ -283,8 +284,8 @@
           {
               String action = (String) i.next() + ".actions." + name;
               actions.add(action);
  -        }            
  -        
  +        }
  +
           return actions.iterator();
       }
   
  @@ -354,7 +355,7 @@
                   }
               }
           }
  - 
  +
           // Remove a possible file extension.
           for (int j = i + 1; j < pckage.length(); j++)
           {
  
  
  
  1.26      +47 -30    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.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- Turbine.java      4 Feb 2002 17:19:26 -0000       1.25
  +++ Turbine.java      6 Feb 2002 17:26:34 -0000       1.26
  @@ -3,7 +3,7 @@
   /* ====================================================================
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 2001 The Apache Software Foundation.  All rights
  + * Copyright (c) 2001-2002 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -72,10 +72,11 @@
   import javax.servlet.http.HttpServletResponse;
   import org.apache.commons.util.StringUtils;
   import org.apache.commons.util.http.HttpUtils;
  -import org.apache.commons.collections.ExtendedProperties;
   import org.apache.fulcrum.ServiceManager;
   import org.apache.fulcrum.TurbineServices;
   import org.apache.log4j.Category;
  +import org.apache.stratum.configuration.Configuration;
  +import org.apache.stratum.configuration.PropertiesConfiguration;
   import org.apache.stratum.xo.Mapper;
   import org.apache.turbine.modules.ModuleLoader;
   import org.apache.turbine.pipeline.DefaultTargetValve;
  @@ -109,8 +110,8 @@
    * If this servlet will always be invoked from another, set the TR.prop
    * turbine.mode = integrated.  If this servlet will operate in a mixed
    * case of standalone and integrated, set turbine.mode = standalone and
  - * integrated operation can be specified on a request basis by 
  - * <code>request.setAttribute("org.apache.turbine.integrated.request.key", 
  + * integrated operation can be specified on a request basis by
  + * <code>request.setAttribute("org.apache.turbine.integrated.request.key",
    * Boolean.TRUE);</code> prior to passing control to this servlet.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Jon S. Stevens</a>
  @@ -121,7 +122,12 @@
    * @author <a href="mailto:[EMAIL PROTECTED]";>Rafal Krzewski</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Jason van Zyl</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Daniel Rall</a>
  - * @version $Id: Turbine.java,v 1.25 2002/02/04 17:19:26 dlr Exp $
  +<<<<<<< Turbine.java
  + * @author <a href="mailto:[EMAIL PROTECTED]";>Martin Poeschl</a>
  + * @version $Id: Turbine.java,v 1.26 2002/02/06 17:26:34 mpoeschl Exp $
  +=======
  + * @version $Id: Turbine.java,v 1.26 2002/02/06 17:26:34 mpoeschl Exp $
  +>>>>>>> 1.25
    */
   public class Turbine
       extends HttpServlet
  @@ -148,7 +154,7 @@
       /**
        * Turbine application configuration.
        */
  -    private static ExtendedProperties configuration;
  +    private static Configuration configuration;
   
       /**
        * This init method will load the default resources from a
  @@ -257,19 +263,19 @@
               // Get general RunData here...
               // Perform turbine specific initialization below.
               // look for a RunData in the request, in the event this servlet
  -            // was called from another servlet that already started 
  +            // was called from another servlet that already started
               // processing the request
               data = (RunData)req.getAttribute(RUNDATA_REQUEST_KEY);
  -            if ( data == null ) 
  +            if ( data == null )
               {
                   data = runDataService.getRunData(req, res, getServletConfig());
               }
  -            else 
  +            else
               {
                   data.setRequest(req);
                   data.setResponse(res);
               }
  -            
  +
   
               // If this is the first invocation, perform some
               // initialization.  Certain services need RunData to initialize
  @@ -305,7 +311,7 @@
               // if the RunData has been added to the request, we assume
               // Turbine is being invoked from another servlet that will
               // handle returning the RunData.
  -            if ( req.getAttribute(RUNDATA_REQUEST_KEY) == null ) 
  +            if ( req.getAttribute(RUNDATA_REQUEST_KEY) == null )
               {
                   // Return the used RunData to the factory for recycling.
                   runDataService.putRunData(data);
  @@ -378,14 +384,14 @@
           Log.error("Turbine.handleException: " + t.getMessage());
           Log.error(t);
   
  -        if ( INTEGRATED.equals(configuration.getProperty(MODE)) ||
  -             req.getAttribute(INTEGRATED_REQUEST_KEY) != null ) 
  +        if ( INTEGRATED.equals(configuration.getString(MODE)) ||
  +             req.getAttribute(INTEGRATED_REQUEST_KEY) != null )
           {
               // leave error handling to the invoking application
               throw new ServletException(t);
           }
  -        else 
  -        {        
  +        else
  +        {
               try
               {
                   // try again with a different target
  @@ -399,7 +405,7 @@
               catch (Exception f)
               {
                   String mimeType = "text/plain";
  -                
  +
                   try
                   {
                       // TODO: Make output formatting more flexible --
  @@ -428,7 +434,7 @@
                                                "source code.");
                       }
                       catch (IOException ignored) {}
  -                    
  +
                       Log.info ( data.getStackTrace() );
                       Log.error ( e.getMessage(), e );
                   }
  @@ -553,22 +559,27 @@
           // Set the application root. This defaults to the webapp
           // context if not otherwise set.
           applicationRoot = config.getInitParameter(APPLICATION_ROOT);
  -                
  +
           if (applicationRoot == null || applicationRoot.equals(WEB_CONTEXT))
           {
               applicationRoot = config.getServletContext().getRealPath("");
  -        }                    
  -        
  +        }
  +
           // Set the applicationRoot for this webapp.
           setApplicationRoot(applicationRoot);
  -        
  +
           // Once we have the application root, we will create
           // any of the directories that are required during
           // runtime. Right now this creates the directories
           // for logging but we might have more of these
           // directories in the future.
  +<<<<<<< Turbine.java
  +        createRuntimeDirectories();
  +
  +=======
           createRuntimeDirectories(config.getInitParameter(LOGGING_ROOT));
           
  +>>>>>>> 1.25
           // Get the full path to the properties file.
           if (propsFile == null)
           {
  @@ -614,17 +625,17 @@
           // This should eventually be a Configuration
           // interface so that service and app configuration
           // can be stored anywhere.
  -        configuration = new ExtendedProperties(propsPath);
  -        
  +        configuration = (Configuration) new PropertiesConfiguration(propsPath);
  +
           // We want to set a few values in the configuration so
           // that ${variable} interpolation will work for
  -        // 
  +        //
           // ${applicationRoot}
           // ${webappRoot}
           configuration.setProperty(APPLICATION_ROOT, applicationRoot);
  -        configuration.setProperty(WEBAPP_ROOT, 
  +        configuration.setProperty(WEBAPP_ROOT,
               config.getServletContext().getRealPath(""));
  -        
  +
           serviceManager.setConfiguration(configuration);
   
           // Initialize the service manager. Services
  @@ -651,7 +662,7 @@
           resolver.init();
   
           // Set some system properties
  -        ExtendedProperties systemProperties = configuration.subset(SYSTEM);
  +        Configuration systemProperties = configuration.subset(SYSTEM);
   
           if (systemProperties != null)
           {
  @@ -669,16 +680,16 @@
           // but we'll set a standard one up here for now.
           Class pipelineClass = Class.forName
               (configuration.getString("pipeline.default", STANDARD_PIPELINE));
  -        
  +
           Log.debug("[Turbine] Using Pipeline: " + pipelineClass.getName());
  -        
  +
           if (TurbinePipeline.class.isAssignableFrom(pipelineClass))
           {
               // Turbine's standard Pipeline implementation uses
               // descriptors to define what Valves are attached to it.
               String descriptorPath = configuration.getString(
                   "pipeline.default.descriptor", TurbinePipeline.CLASSIC_PIPELINE);
  -            
  +
               Log.debug("[Turbine] Using descriptor path: " + descriptorPath);
               Mapper m = new Mapper();
               pipeline = (Pipeline) m.map(descriptorPath,pipelineClass.getName());
  @@ -710,12 +721,18 @@
        */
       private static void createRuntimeDirectories(String path)
       {
  +<<<<<<< Turbine.java
  +        // Create the logging directory
  +        File logDir = new File(getRealPath("/logs"));
  +
  +=======
           if (StringUtils.isEmpty(path))
           {
               path = "/logs";
           }
   
           File logDir = new File(getRealPath(path));
  +>>>>>>> 1.25
           if (!logDir.exists())
           {
               // Create the logging directory
  @@ -879,7 +896,7 @@
        *
        * @return Turbine configuration.
        */
  -    public static ExtendedProperties getConfiguration()
  +    public static Configuration getConfiguration()
       {
           return configuration;
       }
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to