You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by we...@apache.org on 2004/08/02 01:17:25 UTC

cvs commit: jakarta-jetspeed-2/portal/src/test/org/apache/jetspeed/pipeline TestPipeline.java

weaver      2004/08/01 16:17:25

  Modified:    portal/src/java/org/apache/jetspeed/engine SpringEngine.java
                        AbstractEngine.java
               portal/src/webapp/WEB-INF/conf jetspeed.properties
               portal/src/java/org/apache/jetspeed/pipeline
                        JetspeedPipeline.java Pipeline.java
               portal/src/test/org/apache/jetspeed/pipeline
                        TestPipeline.java
  Added:       portal/src/webapp/WEB-INF/conf/pipelines README
               portal/src/webapp/WEB-INF/assembly pipelines.xml
  Removed:     portal/src/webapp/WEB-INF/conf/pipelines
                        portlet-pipeline.xml jetspeed-pipeline.xml
                        action-pipeline.xml
  Log:
  Pipeline definitions have been moved into Spring
  
  Revision  Changes    Path
  1.5       +2 -1      jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/engine/SpringEngine.java
  
  Index: SpringEngine.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/engine/SpringEngine.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- SpringEngine.java	1 Aug 2004 15:46:02 -0000	1.4
  +++ SpringEngine.java	1 Aug 2004 23:17:24 -0000	1.5
  @@ -71,6 +71,7 @@
           }
           configs.add("file:///"+absApplicationRoot + configuration.getString("jetspeed.spring.xml", "/WEB-INF/assembly/jetspeed-spring.xml"));
           configs.add("file:///"+absApplicationRoot + configuration.getString("pluto-factories.xml", "/WEB-INF/assembly/pluto-factories.xml"));
  +        configs.add("file:///"+absApplicationRoot + configuration.getString("pipelines.xml", "/WEB-INF/assembly/pipelines.xml"));
           
           ComponentManager cm = new SpringComponentManager((String[])configs.toArray(new String[configs.size()]), null);
           
  
  
  
  1.5       +8 -111    jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/engine/AbstractEngine.java
  
  Index: AbstractEngine.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/engine/AbstractEngine.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- AbstractEngine.java	1 Aug 2004 15:46:02 -0000	1.4
  +++ AbstractEngine.java	1 Aug 2004 23:17:24 -0000	1.5
  @@ -15,10 +15,8 @@
    */
   package org.apache.jetspeed.engine;
   
  -import java.io.File;
   import java.io.FileInputStream;
   import java.io.IOException;
  -import java.util.HashMap;
   import java.util.Properties;
   
   import javax.naming.NamingException;
  @@ -39,8 +37,6 @@
   import org.apache.jetspeed.cps.CommonPortletServices;
   import org.apache.jetspeed.exception.JetspeedException;
   import org.apache.jetspeed.pipeline.Pipeline;
  -import org.apache.jetspeed.pipeline.descriptor.PipelineDescriptor;
  -import org.apache.jetspeed.pipeline.descriptor.XmlReader;
   import org.apache.jetspeed.request.RequestContext;
   import org.apache.log4j.PropertyConfigurator;
   import org.apache.ojb.broker.util.ClassHelper;
  @@ -70,15 +66,13 @@
       protected static final String JNDI_SUPPORT_FLAG_KEY = "portal.use.internal.jndi";
       private PortalContext context;
       private ServletConfig config = null;
  -    private Pipeline defaultPipeline = null;
  -    private Class pipelineClass = null;
  -    private HashMap pipelines = new HashMap();
       private ComponentManager componentManager = null;
           private static final Log log = LogFactory.getLog(PicoEngine.class);
       private static final Log console = LogFactory.getLog(CONSOLE_LOGGER);
       /** stores the most recent RequestContext on a per thread basis */
       private ThreadLocal tlRequestContext = new ThreadLocal();
       protected boolean useInternalJNDI;
  +    protected String defaultPipelineName;
   
       /**
        * Initializes the engine with a commons configuration, starting all early
  @@ -103,7 +97,7 @@
               context.setConfiguration(configuration);
               useInternalJNDI = configuration.getBoolean(JNDI_SUPPORT_FLAG_KEY,
                       true);
  -            
  +            defaultPipelineName = configuration.getString(PIPELINE_DEFAULT, "jetspeed-pipeline");
               configuration.setProperty(JetspeedEngineConstants.APPLICATION_ROOT_KEY, applicationRoot);
               
               
  @@ -154,7 +148,7 @@
               // create the pipelines
               //
               log.info("Creating Jetspeed piplines...");
  -            createPipelines();
  +
               log.info("Jetspeed piplines created sucessfully.");
               // 
               // Make sure JMX is init'd
  @@ -263,11 +257,10 @@
                   targetPipeline = (String)context.getAttribute(PortalReservedParameters.PIPELINE);                
               }
               tlRequestContext.set(context);
  -            Pipeline pipeline = defaultPipeline;
  +            Pipeline pipeline = getPipeline();
               if (targetPipeline != null)
               {
  -                Pipeline specificPipeline = (Pipeline) pipelines
  -                        .get(targetPipeline);
  +                Pipeline specificPipeline = getPipeline(targetPipeline);
                   if (specificPipeline != null)
                   {
                       pipeline = specificPipeline;
  @@ -361,110 +354,14 @@
       
       }
   
  -    /**
  -     * Creates the Jetspeed pipelines for request processing.
  -     * 
  -     * @throws CPSInitializationException
  -     */
  -    private void createPipelines() throws CPSInitializationException
  -    {
  -        String className = this.getContext().getConfiguration().getString(
  -                PIPELINE_CLASS, null);
  -        String defaultPipelineName = this.getContext().getConfiguration()
  -                .getString(PIPELINE_DEFAULT, "jetspeed-pipeline");
  -        if (null == className)
  -        {
  -            throw new CPSInitializationException(
  -                    "Failed to initialize pipeline, missing configuration entry: "
  -                            + PIPELINE_CLASS);
  -        }
  -        try
  -        {
  -            pipelineClass = Class.forName(className);
  -        }
  -        catch (Exception e)
  -        {
  -            throw new CPSInitializationException(
  -                    "Failed to initialize pipeline, couldnt create pipeline class");
  -        }
  -        String pipelinesDir = this.getContext().getConfiguration().getString(
  -                PIPELINE_DIRECTORY, "/WEB-INF/conf/pipelines/");
  -        File directory = new File(getRealPath(pipelinesDir));
  -        if (directory == null || !directory.exists())
  -        {
  -            throw new CPSInitializationException(
  -                    "Failed to initialize pipeline, could not find pipeline directory");
  -        }
  -        File[] pipelineDescriptors = directory.listFiles();
  -        for (int ix = 0; ix < pipelineDescriptors.length; ix++)
  -        {
  -            if (pipelineDescriptors[ix].isDirectory())
  -            {
  -                continue;
  -            }
  -            Pipeline pipeline = createPipeline(pipelineDescriptors[ix]);
  -            String name = pipelineDescriptors[ix].getName();
  -            int index = name.lastIndexOf(".");
  -            if (index > 0)
  -            {
  -                name = name.substring(0, index);
  -            }
  -            if (name.equalsIgnoreCase(defaultPipelineName))
  -            {
  -                defaultPipeline = pipeline;
  -            }
  -            pipelines.put(name, pipeline);
  -        }
  -    }
  -
  -    /**
  -     * Creates a pipeline from a pipeline descriptor file.
  -     * 
  -     * @param file
  -     *                  the descriptor file describing the pipeline.
  -     * @return The new pipeline.
  -     * @throws CPSInitializationException
  -     */
  -    private Pipeline createPipeline( File file ) throws CPSInitializationException
  -    {
  -        Pipeline pipeline;
  -        PipelineDescriptor descriptor;
  -        try
  -        {
  -            System.out.println("Class loader is " + Thread.currentThread().getContextClassLoader().getClass().getName());
  -            pipeline = (Pipeline) pipelineClass.newInstance();
  -            XmlReader reader = new XmlReader(PipelineDescriptor.class);
  -            descriptor = (PipelineDescriptor) reader.parse(new FileInputStream(
  -                    file));
  -        }
  -        catch (Throwable e)
  -        {
  -            System.out.println("Failure *****************************");
  -            e.printStackTrace();
  -            throw new CPSInitializationException(
  -                    "Failed to read pipeline descriptor from deployment", e);
  -        }
  -        try
  -        {
  -            pipeline.setDescriptor(descriptor);
  -            pipeline.initialize();
  -        }
  -        catch (Exception e)
  -        {
  -            throw new CPSInitializationException(
  -                    "Failed to initialize pipeline: ", e);
  -        }
  -        return pipeline;
  -    }
  -
       public Pipeline getPipeline( String pipelineName )
       {
  -        return (Pipeline) this.pipelines.get(pipelineName);
  +        return (Pipeline) componentManager.getComponent(pipelineName);
       }
   
       public Pipeline getPipeline()
       {
  -        return this.defaultPipeline;
  +        return getPipeline(defaultPipelineName);
       }
   
       /**
  
  
  
  1.1                  jakarta-jetspeed-2/portal/src/webapp/WEB-INF/conf/pipelines/README
  
  Index: README
  ===================================================================
  The pipeline definitions have been moved into the Spring configuration file WEB-INF/assembly/pipelines.xml
  
  
  1.1                  jakarta-jetspeed-2/portal/src/webapp/WEB-INF/assembly/pipelines.xml
  
  Index: pipelines.xml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
  <!--
  Copyright 2004 The Apache Software Foundation
  
  Licensed 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.
  -->
  <beans>
    <bean id="localizationValve"
          class="org.apache.jetspeed.localization.impl.LocalizationValveImpl"
          init-method="initialize"
    /> 
    
    <bean id="capabilityValve"
          class="org.apache.jetspeed.capabilities.impl.CapabilityValveImpl"
          init-method="initialize"
    /> 
    
    <bean id="securityValve"
          class="org.apache.jetspeed.security.impl.SecurityValveImpl"
          init-method="initialize"
    /> 
    
    <bean id="profilerValve"
          class="org.apache.jetspeed.profiler.impl.ProfilerValveImpl"
          init-method="initialize"
    /> 
    
    <bean id="containerValve"
          class="org.apache.jetspeed.container.ContainerValve"
          init-method="initialize"
    /> 
    
    <bean id="actionValve"
          class="org.apache.jetspeed.pipeline.valve.impl.ActionValveImpl"
          init-method="initialize"
    /> 
    
    <bean id="portletValve"
          class="org.apache.jetspeed.aggregator.PortletValve"
          init-method="initialize"
    /> 
    
    <bean id="aggregatorValve"
          class="org.apache.jetspeed.aggregator.AggregatorValve"
          init-method="initialize"
    /> 
    
    <bean id="cleanUpValve"
          class="org.apache.jetspeed.pipeline.valve.impl.CleanupValveImpl"
          init-method="initialize"
    /> 
    
    <bean id="jetspeed-pipeline"
          class="org.apache.jetspeed.pipeline.JetspeedPipeline"
          init-method="initialize"
    >
     <constructor-arg>
     	<value>JetspeedPipeline</value>
     </constructor-arg>
     <constructor-arg>
      <list>
      	<ref bean="localizationValve"/>
      	<ref bean="capabilityValve"/>
      	<ref bean="securityValve"/>
      	<ref bean="profilerValve"/>
      	<ref bean="containerValve"/>
      	<ref bean="actionValve"/>
      	<ref bean="aggregatorValve"/>
      	<ref bean="cleanUpValve"/>
      </list>
      </constructor-arg>
    </bean> 
    
    <bean id="action-pipeline"
          class="org.apache.jetspeed.pipeline.JetspeedPipeline"
          init-method="initialize"
    >
     <constructor-arg>
     	<value>ActionPipeline</value>
     </constructor-arg>
     <constructor-arg>
      <list>
      	<ref bean="localizationValve"/>
      	<ref bean="capabilityValve"/>
      	<ref bean="containerValve"/>
      	<ref bean="actionValve"/>
      </list>
      </constructor-arg>
    </bean> 
    
    <bean id="portlet-pipeline"
          class="org.apache.jetspeed.pipeline.JetspeedPipeline"
          init-method="initialize"
    >
     <constructor-arg>
     	<value>PortletPipeline</value>
     </constructor-arg>
     <constructor-arg>
      <list>
      	<ref bean="localizationValve"/>
      	<ref bean="capabilityValve"/>
      	<ref bean="containerValve"/>
      	<ref bean="portletValve"/>
      </list>
      </constructor-arg>
    </bean> 
    
    
  </beans>
  
  
  1.57      +1 -3      jakarta-jetspeed-2/portal/src/webapp/WEB-INF/conf/jetspeed.properties
  
  Index: jetspeed.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/webapp/WEB-INF/conf/jetspeed.properties,v
  retrieving revision 1.56
  retrieving revision 1.57
  diff -u -r1.56 -r1.57
  --- jetspeed.properties	1 Aug 2004 15:53:04 -0000	1.56
  +++ jetspeed.properties	1 Aug 2004 23:17:24 -0000	1.57
  @@ -68,8 +68,6 @@
   # -------------------------------------------------------------------
   #  P I P E L I N E
   # -------------------------------------------------------------------
  -pipeline.class = org.apache.jetspeed.pipeline.JetspeedPipeline
  -pipeline.directory = /WEB-INF/conf/pipelines/
   pipeline.default = jetspeed-pipeline
   
   
  
  
  
  1.4       +6 -52     jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/pipeline/JetspeedPipeline.java
  
  Index: JetspeedPipeline.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/pipeline/JetspeedPipeline.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- JetspeedPipeline.java	18 May 2004 17:58:20 -0000	1.3
  +++ JetspeedPipeline.java	1 Aug 2004 23:17:25 -0000	1.4
  @@ -15,12 +15,11 @@
    */
   package org.apache.jetspeed.pipeline;
   
  -import java.util.ArrayList;
  +import java.util.List;
   
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
   import org.apache.jetspeed.pipeline.descriptor.PipelineDescriptor;
  -import org.apache.jetspeed.pipeline.descriptor.ValveDescriptor;
   import org.apache.jetspeed.pipeline.valve.Valve;
   import org.apache.jetspeed.pipeline.valve.ValveContext;
   import org.apache.jetspeed.request.RequestContext;
  @@ -77,25 +76,11 @@
        * Constructor that provides the descriptor for building
        * the pipeline
        */
  -    public JetspeedPipeline()
  +    public JetspeedPipeline(String name, List valveList)
       throws Exception
       {
  -    }
  -    
  -    /**
  -     * <p>Set the descriptor used to create this pipeline.</p>
  -     */
  -    public void setDescriptor(PipelineDescriptor descriptor)
  -    {
  -        this.descriptor = descriptor;
  -    }
  -    
  -    /**
  -     * <p>Get the descriptor used to create this pipeline.</p>
  -     */
  -    public PipelineDescriptor getDescriptor()
  -    {
  -        return descriptor;
  +        valves = (Valve[]) valveList.toArray(new Valve[valveList.size()]);
  +        setName(name);
       }
       
       /**
  @@ -104,39 +89,8 @@
       public void initialize()
       throws PipelineException
       {
  -        setName(getDescriptor().getName());
  -        ArrayList valveDescriptors = (ArrayList) getDescriptor().getValveDescriptors();
  -        
  -        for (int i=0; i<valveDescriptors.size(); i++)
  -        {
  -            ValveDescriptor vDescriptor = (ValveDescriptor) valveDescriptors.get(i);
  -            String className = vDescriptor.getClassName();
  -            
  -            log.info("Adding Valve: " + className);
  -            
  -            Valve valve;
  -            
  -            try
  -            {
  -                valve = (Valve) Class.forName(className).newInstance();
  -            }
  -            catch (Exception e)
  -            {
  -                throw new PipelineException("Failed to create valve: " + className);
  -            }
  -            
  -            addValve(valve);
  -        }
  -        
  -        // Valve implementations are added to this Pipeline using the
  -        // Mapper.
           
  -        // Initialize the valves
  -        for (int i = 0; i < valves.length; i++)
  -        {
  -            //valves[i].setApplicationView(getApplicationView());
  -            valves[i].initialize();
  -        }
  +       
       }
       
       /**
  
  
  
  1.7       +4 -12     jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/pipeline/Pipeline.java
  
  Index: Pipeline.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/pipeline/Pipeline.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Pipeline.java	31 Jul 2004 20:05:28 -0000	1.6
  +++ Pipeline.java	1 Aug 2004 23:17:25 -0000	1.7
  @@ -15,9 +15,10 @@
    */
   package org.apache.jetspeed.pipeline;
   
  -import org.apache.jetspeed.request.RequestContext;
  -import org.apache.jetspeed.pipeline.descriptor.PipelineDescriptor;
  +import java.io.IOException;
  +
   import org.apache.jetspeed.pipeline.valve.Valve;
  +import org.apache.jetspeed.request.RequestContext;
   
   /**
    *
  @@ -74,13 +75,4 @@
        */
       void removeValve(Valve valve);
   
  -    /**
  -     * <p>Set the descriptor used to create this pipeline.</p>
  -     */
  -    void setDescriptor(PipelineDescriptor pipelineDescriptor);
  -    
  -    /**
  -     * <p>Get the descriptor used to create this pipeline.</p>
  -     */
  -    PipelineDescriptor getDescriptor();
   }
  
  
  
  1.12      +3 -1      jakarta-jetspeed-2/portal/src/test/org/apache/jetspeed/pipeline/TestPipeline.java
  
  Index: TestPipeline.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/test/org/apache/jetspeed/pipeline/TestPipeline.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- TestPipeline.java	18 Jun 2004 20:49:06 -0000	1.11
  +++ TestPipeline.java	1 Aug 2004 23:17:25 -0000	1.12
  @@ -85,5 +85,7 @@
           assertTrue(valves[5].toString().equals("ActionValveImpl"));     
           assertTrue(valves[6].toString().equals("AggregatorValve"));
           assertTrue(valves[7].toString().equals("CleanupValveImpl"));
  +        assertNotNull(engine.getPipeline("action-pipeline"));
  +        assertNotNull(engine.getPipeline("portlet-pipeline"));
       }
   }
  
  
  

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