epugh       2004/10/18 11:37:40

  Modified:    .        project.xml
               src/java/org/apache/turbine Turbine.java
               conf     turbine-classic-pipeline.xml
  Added:       src/test/org/apache/turbine/pipeline
                        PipelineCreationTest.java
  Log:
  Replace commons-xo with xstream.
  
  Revision  Changes    Path
  1.165     +8 -11     jakarta-turbine-2/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-2/project.xml,v
  retrieving revision 1.164
  retrieving revision 1.165
  diff -u -r1.164 -r1.165
  --- project.xml       16 Oct 2004 16:03:53 -0000      1.164
  +++ project.xml       18 Oct 2004 18:37:40 -0000      1.165
  @@ -336,10 +336,6 @@
     <dependencies>
     <!-- t3 -->
       <dependency>
  -      <id>commons-xo</id>
  -      <version>20040218.104422</version>
  -    </dependency>
  -    <dependency>
         <groupId>mx4j</groupId>
         <artifactId>mx4j-jmx</artifactId>
         <version>1.1.1</version>
  @@ -510,12 +506,7 @@
         <id>commons-fileupload</id>
         <version>1.0</version>
         <url>http://jakarta.apache.org/commons/fileupload/</url>
  -    </dependency>
  -    <dependency>
  -      <id>commons-io</id>
  -      <version>0.2-dev.20020717.100545</version>
  -      <url>http://jakarta.apache.org/commons/io/</url>
  -    </dependency>    
  +    </dependency> 
       <dependency>
         <id>commons-lang</id>
         <version>2.0</version>
  @@ -523,7 +514,7 @@
       </dependency>
       <dependency>
         <id>commons-logging</id>
  -      <version>1.0.3</version>
  +      <version>1.0.4</version>
         <url>http://jakarta.apache.org/commons/logging.html</url>
       </dependency>
       <dependency>
  @@ -752,6 +743,12 @@
         <version>1.2-b1</version>
         <url>http://xml.apache.org/xmlrpc/</url>
       </dependency>
  +    <dependency>
  +      <groupId>xstream</groupId>
  +      <artifactId>xstream</artifactId>
  +      <version>1.0.2</version>
  +      <url>http://xstream.codehaus.org/</url>
  +    </dependency>    
       
       <dependency>
         <groupId>mockobjects</groupId>
  
  
  
  1.52      +41 -46    jakarta-turbine-2/src/java/org/apache/turbine/Turbine.java
  
  Index: Turbine.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/Turbine.java,v
  retrieving revision 1.51
  retrieving revision 1.52
  diff -u -r1.51 -r1.52
  --- Turbine.java      2 Aug 2004 08:57:36 -0000       1.51
  +++ Turbine.java      18 Oct 2004 18:37:40 -0000      1.52
  @@ -54,12 +54,13 @@
    * <http://www.apache.org/>.
    */
   
  +import java.io.BufferedReader;
   import java.io.File;
   import java.io.FileInputStream;
   import java.io.FileNotFoundException;
  +import java.io.FileReader;
   import java.io.IOException;
  -import java.util.HashMap;
  -import java.util.Map;
  +import java.io.Reader;
   import java.util.Properties;
   
   import javax.servlet.ServletConfig;
  @@ -72,39 +73,31 @@
   import org.apache.commons.configuration.Configuration;
   import org.apache.commons.configuration.ConfigurationFactory;
   import org.apache.commons.configuration.PropertiesConfiguration;
  -
   import org.apache.commons.lang.StringUtils;
  -
   import org.apache.commons.lang.exception.ExceptionUtils;
  -
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
  -
  -import org.apache.commons.xo.Mapper;
  -
   import org.apache.log4j.PropertyConfigurator;
  -
   import org.apache.turbine.modules.PageLoader;
  -import org.apache.turbine.pipeline.DefaultPipelineData;
   import org.apache.turbine.pipeline.Pipeline;
   import org.apache.turbine.pipeline.PipelineData;
   import org.apache.turbine.pipeline.TurbinePipeline;
  -
   import org.apache.turbine.services.ServiceManager;
   import org.apache.turbine.services.TurbineServices;
   import org.apache.turbine.services.avaloncomponent.AvalonComponentService;
   import org.apache.turbine.services.component.ComponentService;
  +import org.apache.turbine.services.rundata.RunDataService;
   import org.apache.turbine.services.template.TemplateService;
   import org.apache.turbine.services.template.TurbineTemplate;
  -import org.apache.turbine.services.rundata.RunDataService;
  -import org.apache.turbine.services.rundata.TurbineRunDataFacade;
  -
   import org.apache.turbine.util.RunData;
   import org.apache.turbine.util.ServerData;
   import org.apache.turbine.util.TurbineConfig;
   import org.apache.turbine.util.TurbineException;
   import org.apache.turbine.util.uri.URIConstants;
   
  +import com.thoughtworks.xstream.XStream;
  +import com.thoughtworks.xstream.io.xml.DomDriver;
  +
   /**
    * Turbine is the main servlet for the entire system. It is <code>final</code>
    * because you should <i>not</i> ever need to subclass this servlet.  If you
  @@ -199,12 +192,6 @@
       /** Our internal configuration object */
       private static Configuration configuration = null;
   
  -    /** A reference to the Template Service */
  -    private TemplateService templateService = null;
  -
  -    /** A reference to the RunData Service */
  -    private RunDataService rundataService = null;
  -
       /** Logging class from commons.logging */
       private static Log log = LogFactory.getLog(Turbine.class);
   
  @@ -238,10 +225,13 @@
   
                   configure(config, context);
   
  -                templateService = TurbineTemplate.getService();
  -                rundataService = TurbineRunDataFacade.getService();
  -
  -                if (rundataService == null)
  +                TemplateService templateService = TurbineTemplate.getService();
  +                if (templateService == null)
  +                {
  +                    throw new TurbineException(
  +                            "No Template Service configured!");
  +                }
  +                if (getRunDataService() == null)
                   {
                       throw new TurbineException(
                               "No RunData Service configured!");
  @@ -410,22 +400,19 @@
   
                // Retrieve the pipeline class and then initialize it.  The pipeline
           // handles the processing of a webrequest/response cycle.
  -         Class pipelineClass =
  -               Class.forName(
  -                       configuration.getString("pipeline.default", 
STANDARD_PIPELINE));
  -  
  -                 log.debug("Using Pipeline: " + pipelineClass.getName());
  -         // 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);
  -                     descriptorPath = getRealPath(descriptorPath);
  +             
  +        descriptorPath = getRealPath(descriptorPath);
     
  -                     log.debug("Using descriptor path: " + descriptorPath);
  -             Mapper m = new Mapper();
  -             pipeline = (Pipeline) m.map(descriptorPath, pipelineClass.getName());
  +             log.debug("Using descriptor path: " + descriptorPath);
  +        Reader reader = new BufferedReader(new FileReader(descriptorPath));  
  +        XStream pipelineMapper = new XStream(new DomDriver()); // does not require 
XPP3 library
  +        pipeline = (Pipeline) pipelineMapper.fromXML(reader);
  +            
                log.debug("Initializing pipeline");
          
                pipeline.initialize();
  @@ -680,9 +667,9 @@
           boolean requestRedirected = false;
   
           // Placeholder for the RunData object.
  -        RunData data = null;
  +        //RunData data = null;
           
  -        PipelineData pipelineData = new DefaultPipelineData();
  +        PipelineData pipelineData = null;//new DefaultPipelineData();
           try
           {
               // Check to make sure that we started up properly.
  @@ -711,11 +698,11 @@
   
               // Get general RunData here...
               // Perform turbine specific initialization below.
  -            data = rundataService.getRunData(req, res, getServletConfig());
  -            Map runDataMap = new HashMap();
  -            runDataMap.put(RunData.class, data);
  +            pipelineData = getRunDataService().getRunData(req, res, 
getServletConfig());
  +           // Map runDataMap = new HashMap();
  +            //runDataMap.put(RunData.class, data);
               // put the data into the pipeline
  -            pipelineData.put(RunData.class, runDataMap);            
  +           // pipelineData.put(RunData.class, runDataMap);            
   
               // Stages of Pipeline implementation execution
                        // configurable via attached Valve implementations in a
  @@ -734,7 +721,7 @@
           finally
           {
               // Return the used RunData to the factory for recycling.
  -            rundataService.putRunData(data);
  +            getRunDataService().putRunData((RunData)pipelineData);
           }
       }
   
  @@ -915,7 +902,7 @@
       }
       
       /**
  -     * Get a RunData from the pipelineData. Once RunData is replaced
  +     * Get a RunData from the pipelineData. Once RunData is fully replaced
        * by PipelineData this should not be required. 
        * @param pipelineData
        * @return
  @@ -923,8 +910,16 @@
       private RunData getRunData(PipelineData pipelineData)
       {
           RunData data = null;
  -        Map runDataMap = (Map) pipelineData.get(RunData.class);
  -        data = (RunData)runDataMap.get(RunData.class);
  +        data = (RunData)pipelineData;
           return data;
       }
  +    
  +    /**
  +     * Static Helper method for looking up the RunDataService
  +     * @return A RunDataService
  +     */
  +    private static RunDataService getRunDataService(){
  +        return (RunDataService) TurbineServices
  +        .getInstance().getService(RunDataService.SERVICE_NAME);
  +    }    
   }
  
  
  
  1.1                  
jakarta-turbine-2/src/test/org/apache/turbine/pipeline/PipelineCreationTest.java
  
  Index: PipelineCreationTest.java
  ===================================================================
  package org.apache.turbine.pipeline;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Turbine" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Turbine", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  
  import junit.framework.TestCase;
  
  import com.thoughtworks.xstream.XStream;
  import com.thoughtworks.xstream.io.xml.DomDriver;
  
  /**
   * Tests TurbinePipeline.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Daniel Rall</a>
   * @version $Id: PipelineCreationTest.java,v 1.1 2004/10/18 18:37:40 epugh Exp $
   */
  public class PipelineCreationTest extends TestCase
  {
      private Pipeline pipeline;
      /**
       * Constructor
       */
      public PipelineCreationTest(String testName)
      {
          super(testName);
      }
      
      public void setUp(){
          pipeline = new TurbinePipeline();
          pipeline.addValve(new SimpleValve());
          pipeline.addValve(new DetermineActionValve());
      }
  
      
      public void testSavingPipelineWXstream() throws Exception
      {
          XStream xstream = new XStream(new DomDriver()); // does not require XPP3 
library
         
          String xml = xstream.toXML(pipeline);
          //System.out.println(xml);
          //Pipeline pipeline = (Pipeline)xstream.fromXML(xml);
          
      }
      
      public void testReadingPipelineWXstream() throws Exception{
          String xml="<org.apache.turbine.pipeline.TurbinePipeline>  <valves>    
<org.apache.turbine.pipeline.SimpleValve/>    
<org.apache.turbine.pipeline.DetermineActionValve/>  
</valves></org.apache.turbine.pipeline.TurbinePipeline>";
          XStream xstream = new XStream(new DomDriver()); // does not require XPP3 
library
          Object o = xstream.fromXML(xml);
          Pipeline pipeline = (Pipeline)o;
          assertEquals(pipeline.getValves().length,2);
          assertTrue(pipeline.getValves()[0] instanceof SimpleValve);
          assertTrue(pipeline.getValves()[1] instanceof DetermineActionValve);
      }
  
  }
  
  
  
  1.2       +11 -12    jakarta-turbine-2/conf/turbine-classic-pipeline.xml
  
  Index: turbine-classic-pipeline.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-2/conf/turbine-classic-pipeline.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- turbine-classic-pipeline.xml      23 Feb 2004 20:35:06 -0000      1.1
  +++ turbine-classic-pipeline.xml      18 Oct 2004 18:37:40 -0000      1.2
  @@ -1,14 +1,13 @@
  -<pipeline>
  -  <name>TurbineClassicPipeline</name>
  +<org.apache.turbine.pipeline.TurbinePipeline>
     <valves>
  -    <valve className="org.apache.turbine.pipeline.DetermineActionValve"/>
  -    <valve className="org.apache.turbine.pipeline.DetermineTargetValve"/>   
  -    <valve className="org.apache.turbine.pipeline.DefaultSessionTimeoutValve"/>   
  -    <valve className="org.apache.turbine.pipeline.DefaultLoginValve"/>
  -    <valve className="org.apache.turbine.pipeline.DefaultSessionValidationValve"/>
  -    <valve className="org.apache.turbine.pipeline.DefaultACLCreationValve"/>
  -    <valve className="org.apache.turbine.pipeline.ExecutePageValve"/>
  -    <valve className="org.apache.turbine.pipeline.CleanUpValve"/>
  -    <valve className="org.apache.turbine.pipeline.DetermineRedirectRequestedValve"/>
  +    <org.apache.turbine.pipeline.DetermineActionValve/>
  +    <org.apache.turbine.pipeline.DetermineTargetValve/>   
  +    <org.apache.turbine.pipeline.DefaultSessionTimeoutValve/>   
  +    <org.apache.turbine.pipeline.DefaultLoginValve/>
  +    <org.apache.turbine.pipeline.DefaultSessionValidationValve/>
  +    <org.apache.turbine.pipeline.DefaultACLCreationValve/>
  +    <org.apache.turbine.pipeline.ExecutePageValve/>
  +    <org.apache.turbine.pipeline.CleanUpValve/>
  +    <org.apache.turbine.pipeline.DetermineRedirectRequestedValve/>    
     </valves>
  -</pipeline>
  +</org.apache.turbine.pipeline.TurbinePipeline>
  
  
  

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

Reply via email to