On Oct 23, 2007, at 5:25 AM, XXX XXXXXX wrote:

I also have the same problem. I found some documentation, but didn ´t help me: http://portals.apache.org/jetspeed-2/multiproject/jetspeed-security/ index.htmlCan anybody give an example / tutorial / guide, please?


I recommend writing a "component" project that creates a jar file, such as the one described here:

http://wiki.apache.org/portals/Jetspeed2/Maven2BuildSupport

A simple component to be used by other component and application modules:

mvn archetype:create -DarchetypeGroupId=org.apache.portals.jetspeed-2 -DarchetypeArtifactId=component-archetype -DarchetypeVersion=2.1.2 - DgroupId=myportalgroup -DartifactId=myportal-component -Dversion=1.0

This project can be used to create your jar file, which should then be dropped into the WEB-INF/lib directory of Jetspeed Writing a valve is pretty straight forward, but will probably require having the source code if you want to look at other examples of valves and filters
Here is a sample SimpleValve.java class:

package com.xxx.portal.valves;

import org.apache.jetspeed.pipeline.PipelineException;
import org.apache.jetspeed.pipeline.valve.AbstractValve;
import org.apache.jetspeed.pipeline.valve.ValveContext;
import org.apache.jetspeed.request.RequestContext;

/**
* Invokes the Simple service in the request pipeline
*
*/
public class SimpleValve
       extends AbstractValve
{
    private SimpleService ss;

    public SimpleValve(SimpleService ss)
    {
        this.ss = ss;
    }

    public void invoke( RequestContext request, ValveContext context )
        throws PipelineException
    {
        try
        {
            ss.service();
        }
        catch (Exception e)
        {
            throw new PipelineException(e.toString(), e);
        }
        // Pass control to the next Valve in the Pipeline
        context.invokeNext( request );
    }

    public String toString()
    {
        return "SimpleValve";
    }
}

Valves are configured in Spring, so you would have override the pipelines.xml in your custom Jetspeed build, placing your pipelines.xml in WEB-INF/assembly/overrides/ You can leave the WEB-INF/assembly/pipelines.xml there as is, it wont' be used because the overrides/ directory always takes precedence
Add your bean:

  <bean id="simpleValve"
        class="com.xxx.portal.valves.SimpleValve"
        init-method="initialize"
  >
   <constructor-arg>
       <ref bean="SimpleService" />
   </constructor-arg>
  </bean>

Finally, add the Valve to minimally the portal pipeline at the appropriate place:

   <constructor-arg>
       <value>JetspeedPipeline</value>
   </constructor-arg>
   <constructor-arg>
    <list>
...
      <ref bean="simpleValve"/>




Reply via email to