You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2005/03/17 22:53:34 UTC

cvs commit: jakarta-tapestry/framework/src/java/org/apache/tapestry/services ApplicationGlobals.java

hlship      2005/03/17 13:53:34

  Modified:    portlet/src/java/org/apache/tapestry/portlet
                        ApplicationPortlet.java RenderWebResponse.java
                        PortletRequestGlobalsImpl.java
                        PortletRequestGlobals.java
               portlet/src/descriptor/META-INF hivemodule.xml
               portlet/src/test/org/apache/tapestry/portlet
                        TestApplicationPortlet.java
               framework/src/descriptor/META-INF hivemodule.xml
                        tapestry.services.xml
               framework/src/java/org/apache/tapestry/services/impl
                        LinkFactoryImpl.java ApplicationGlobalsImpl.java
               framework/src/java/org/apache/tapestry/engine
                        SetupServletEngineServices.java
               framework/src/java/org/apache/tapestry/services
                        ApplicationGlobals.java
  Added:       portlet/src/java/org/apache/tapestry/portlet
                        PortletConstants.java
                        ActionRequestServicerToWebRequestServicerBridge.java
                        PortletResponseRenderer.java
                        RenderRequestServicerFilter.java PortletLink.java
                        RenderRequestServicerToWebRequestServicerBridge.java
                        PortletLinkFactoryImpl.java
                        SetupPortletEngineServices.java RenderService.java
                        RenderRequestServicer.java
               portlet/src/descriptor/META-INF
                        tapestry.portlet.services.xml
               portlet/src/test/org/apache/tapestry/portlet
                        TestPortletResponseRenderer.java
                        TestPortletLink.java
                        TestPortletServicerBridges.java
  Removed:     portlet/src/java/org/apache/tapestry/portlet
                        ActionPortletToWebRequestServicerPipelineBridge.java
               portlet/src/test/org/apache/tapestry/portlet
                        TestActionPortletToWebRequestServicerPipelineBridge.java
  Log:
  Continue extending out the Portlet pipelines.
  
  Revision  Changes    Path
  1.2       +23 -0     jakarta-tapestry/portlet/src/java/org/apache/tapestry/portlet/ApplicationPortlet.java
  
  Index: ApplicationPortlet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/portlet/src/java/org/apache/tapestry/portlet/ApplicationPortlet.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ApplicationPortlet.java	16 Mar 2005 19:19:25 -0000	1.1
  +++ ApplicationPortlet.java	17 Mar 2005 21:53:33 -0000	1.2
  @@ -50,6 +50,8 @@
   
       ActionRequestServicer _actionRequestServicer;
   
  +    RenderRequestServicer _renderRequestServicer;
  +
       public void destroy()
       {
           try
  @@ -60,6 +62,7 @@
           {
               _registry = null;
               _actionRequestServicer = null;
  +            _renderRequestServicer = null;
           }
       }
   
  @@ -77,6 +80,10 @@
           _actionRequestServicer = (ActionRequestServicer) _registry.getService(
                   "tapestry.portlet.ActionRequestServicer",
                   ActionRequestServicer.class);
  +
  +        _renderRequestServicer = (RenderRequestServicer) _registry.getService(
  +                "tapestry.portlet.RenderRequestServicer",
  +                RenderRequestServicer.class);
       }
   
       /**
  @@ -132,6 +139,10 @@
           {
               _actionRequestServicer.service(request, response);
           }
  +        catch (RuntimeException ex)
  +        {
  +            throw new PortletException(ex);
  +        }
           finally
           {
               _registry.cleanupThread();
  @@ -141,5 +152,17 @@
       public void render(RenderRequest request, RenderResponse response) throws PortletException,
               IOException
       {
  +        try
  +        {
  +            _renderRequestServicer.service(request, response);
  +        }
  +        catch (RuntimeException ex)
  +        {
  +            throw new PortletException(ex);
  +        }
  +        finally
  +        {
  +            _registry.cleanupThread();
  +        }
       }
   }
  \ No newline at end of file
  
  
  
  1.2       +4 -0      jakarta-tapestry/portlet/src/java/org/apache/tapestry/portlet/RenderWebResponse.java
  
  Index: RenderWebResponse.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/portlet/src/java/org/apache/tapestry/portlet/RenderWebResponse.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- RenderWebResponse.java	10 Mar 2005 23:24:33 -0000	1.1
  +++ RenderWebResponse.java	17 Mar 2005 21:53:33 -0000	1.2
  @@ -20,7 +20,11 @@
   import javax.portlet.RenderResponse;
   
   /**
  + * Wrapper around {@link javax.portlet.RenderResponse} to adapt it as
  + * {@link org.apache.tapestry.portlet.PortletWebResponse}.
  + * 
    * @author Howard M. Lewis Ship
  + * @since 3.1
    */
   public class RenderWebResponse extends PortletWebResponse
   {
  
  
  
  1.2       +21 -0     jakarta-tapestry/portlet/src/java/org/apache/tapestry/portlet/PortletRequestGlobalsImpl.java
  
  Index: PortletRequestGlobalsImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/portlet/src/java/org/apache/tapestry/portlet/PortletRequestGlobalsImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PortletRequestGlobalsImpl.java	16 Mar 2005 19:19:25 -0000	1.1
  +++ PortletRequestGlobalsImpl.java	17 Mar 2005 21:53:33 -0000	1.2
  @@ -16,6 +16,8 @@
   
   import javax.portlet.ActionRequest;
   import javax.portlet.ActionResponse;
  +import javax.portlet.RenderRequest;
  +import javax.portlet.RenderResponse;
   
   /**
    * Implementation of the <code>tapestry.portlet.PortletRequestGlobals</code> service, which uses
  @@ -30,12 +32,22 @@
   
       private ActionResponse _actionResponse;
   
  +    private RenderResponse _renderResponse;
  +
  +    private RenderRequest _renderRequest;
  +
       public void store(ActionRequest request, ActionResponse response)
       {
           _actionRequest = request;
           _actionResponse = response;
       }
   
  +    public void store(RenderRequest request, RenderResponse response)
  +    {
  +        _renderRequest = request;
  +        _renderResponse = response;
  +    }
  +
       public ActionRequest getActionRequest()
       {
           return _actionRequest;
  @@ -46,4 +58,13 @@
           return _actionResponse;
       }
   
  +    public RenderRequest getRenderRequest()
  +    {
  +        return _renderRequest;
  +    }
  +
  +    public RenderResponse getRenderResponse()
  +    {
  +        return _renderResponse;
  +    }
   }
  \ No newline at end of file
  
  
  
  1.2       +8 -0      jakarta-tapestry/portlet/src/java/org/apache/tapestry/portlet/PortletRequestGlobals.java
  
  Index: PortletRequestGlobals.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/portlet/src/java/org/apache/tapestry/portlet/PortletRequestGlobals.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PortletRequestGlobals.java	16 Mar 2005 19:19:25 -0000	1.1
  +++ PortletRequestGlobals.java	17 Mar 2005 21:53:33 -0000	1.2
  @@ -16,6 +16,8 @@
   
   import javax.portlet.ActionRequest;
   import javax.portlet.ActionResponse;
  +import javax.portlet.RenderRequest;
  +import javax.portlet.RenderResponse;
   
   /**
    * Stores the current Portlet request and response, for access by other services.
  @@ -27,7 +29,13 @@
   {
       public void store(ActionRequest request, ActionResponse response);
   
  +    public void store(RenderRequest request, RenderResponse response);
  +
       public ActionRequest getActionRequest();
   
       public ActionResponse getActionResponse();
  +
  +    public RenderRequest getRenderRequest();
  +
  +    public RenderResponse getRenderResponse();
   }
  \ No newline at end of file
  
  
  
  1.1                  jakarta-tapestry/portlet/src/java/org/apache/tapestry/portlet/PortletConstants.java
  
  Index: PortletConstants.java
  ===================================================================
  // Copyright 2005 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.
  
  package org.apache.tapestry.portlet;
  
  /**
   * @author Howard M. Lewis Ship
   * @since 3.1
   */
  public class PortletConstants
  {
      /**
       * Name of the render service, whose job is to render a page. The page to render is identified
       * in the {@link org.apache.tapestry.services.ServiceConstants#PAGE}parameter.
       */
      public static final String RENDER_SERVICE = "render";
  
      private PortletConstants()
      {
          // Prevent instantiation
      }
  }
  
  
  1.1                  jakarta-tapestry/portlet/src/java/org/apache/tapestry/portlet/ActionRequestServicerToWebRequestServicerBridge.java
  
  Index: ActionRequestServicerToWebRequestServicerBridge.java
  ===================================================================
  // Copyright 2005 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.
  
  package org.apache.tapestry.portlet;
  
  import java.io.IOException;
  
  import javax.portlet.ActionRequest;
  import javax.portlet.ActionResponse;
  import javax.portlet.PortletException;
  
  import org.apache.tapestry.services.WebRequestServicer;
  
  /**
   * Bridges from the <code>tapestry.portlet.ActionRequestServicerPipeline</code> to the standard
   * <code>tapestry.request.WebRequestServicerPipeline</code>.
   * 
   * @author Howard M. Lewis Ship
   * @since 3.1
   */
  public class ActionRequestServicerToWebRequestServicerBridge implements ActionRequestServicer
  {
      private PortletRequestGlobals _portletRequestGlobals;
  
      private WebRequestServicer _webRequestServicer;
  
      public void service(ActionRequest request, ActionResponse response) throws IOException,
              PortletException
      {
          _portletRequestGlobals.store(request, response);
  
          PortletWebRequest webRequest = new PortletWebRequest(request);
          PortletWebResponse webResponse = new PortletWebResponse(response);
  
          try
          {
              _webRequestServicer.service(webRequest, webResponse);
          }
          catch (RuntimeException ex)
          {
              throw new PortletException(ex);
          }
      }
  
      public void setPortletRequestGlobals(PortletRequestGlobals portletRequestGlobals)
      {
          _portletRequestGlobals = portletRequestGlobals;
      }
  
      public void setWebRequestServicer(WebRequestServicer webRequestServicer)
      {
          _webRequestServicer = webRequestServicer;
      }
  }
  
  
  1.1                  jakarta-tapestry/portlet/src/java/org/apache/tapestry/portlet/PortletResponseRenderer.java
  
  Index: PortletResponseRenderer.java
  ===================================================================
  // Copyright 2005 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.
  
  package org.apache.tapestry.portlet;
  
  import java.io.IOException;
  
  import javax.portlet.ActionResponse;
  import javax.servlet.ServletException;
  
  import org.apache.tapestry.IRequestCycle;
  import org.apache.tapestry.request.ResponseOutputStream;
  import org.apache.tapestry.services.ResponseRenderer;
  import org.apache.tapestry.services.ServiceConstants;
  
  /**
   * Sets render parameters on the current {@link javax.portlet.ActionResponse}&nbsp;that will invoke
   * the {@link org.apache.tapestry.portlet.RenderService}to render the (currently) active page.
   * 
   * @author Howard M. Lewis Ship
   * @since 3.1
   */
  public class PortletResponseRenderer implements ResponseRenderer
  {
      private ActionResponse _response;
  
      public void renderResponse(IRequestCycle cycle, ResponseOutputStream output)
              throws ServletException, IOException
      {
          String pageName = cycle.getPage().getPageName();
  
          _response.setRenderParameter(ServiceConstants.SERVICE, PortletConstants.RENDER_SERVICE);
          _response.setRenderParameter(ServiceConstants.PAGE, pageName);
      }
  
      public void setResponse(ActionResponse response)
      {
          _response = response;
      }
  }
  
  
  1.1                  jakarta-tapestry/portlet/src/java/org/apache/tapestry/portlet/RenderRequestServicerFilter.java
  
  Index: RenderRequestServicerFilter.java
  ===================================================================
  // Copyright 2005 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.
  
  package org.apache.tapestry.portlet;
  
  import java.io.IOException;
  
  import javax.portlet.PortletException;
  import javax.portlet.RenderRequest;
  import javax.portlet.RenderResponse;
  
  /**
   * Filter interface used for the commands in the
   * <code>tapestry.portlet.RenderRequestServicerPipeline</code> configuration.
   * 
   * @author Howard M. Lewis Ship
   * @since 3.1
   * @see org.apache.tapestry.portlet.RenderRequestServicer
   */
  public interface RenderRequestServicerFilter
  {
      public void service(RenderRequest request, RenderResponse response,
              RenderRequestServicer servicer) throws IOException, PortletException;
  }
  
  
  1.1                  jakarta-tapestry/portlet/src/java/org/apache/tapestry/portlet/PortletLink.java
  
  Index: PortletLink.java
  ===================================================================
  // Copyright 2005 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.
  
  package org.apache.tapestry.portlet;
  
  import javax.portlet.PortletURL;
  
  import org.apache.hivemind.util.Defense;
  import org.apache.tapestry.IRequestCycle;
  import org.apache.tapestry.engine.ILink;
  import org.apache.tapestry.util.QueryParameterMap;
  
  /**
   * Wrapper around {@link javax.portlet.PortletURL}.
   * 
   * @author Howard M. Lewis Ship
   * @since 3.1
   */
  public class PortletLink implements ILink
  {
      private final IRequestCycle _cycle;
  
      private final PortletURL _portletURL;
  
      private final boolean _stateful;
  
      private final QueryParameterMap _parameters;
  
      public PortletLink(IRequestCycle cycle, PortletURL portletURL, QueryParameterMap parameters,
              boolean stateful)
      {
          Defense.notNull(cycle, "cycle");
          Defense.notNull(portletURL, "portletURL");
          Defense.notNull(parameters, "parameters");
  
          _cycle = cycle;
          _portletURL = portletURL;
          _parameters = parameters;
          _stateful = stateful;
      }
  
      public String getURL()
      {
          return getURL(null, true);
      }
  
      public String getURL(String anchor, boolean includeParameters)
      {
          if (includeParameters)
              loadParameters();
  
          String url = _portletURL.toString();
  
          if (_stateful)
              url = _cycle.encodeURL(url);
  
          if (anchor != null)
              url = url + "#" + anchor;
  
          return url;
      }
  
      private void loadParameters()
      {
          String[] names = _parameters.getParameterNames();
  
          for (int i = 0; i < names.length; i++)
          {
              String name = names[i];
              String[] values = _parameters.getParameterValues(name);
  
              _portletURL.setParameter(name, values);
          }
      }
  
      public String getAbsoluteURL()
      {
          throw new UnsupportedOperationException(PortletMessages.unsupportedMethod("getAbsoluteURL"));
      }
  
      public String getAbsoluteURL(String scheme, String server, int port, String anchor,
              boolean includeParameters)
      {
          throw new UnsupportedOperationException(PortletMessages.unsupportedMethod("getAbsoluteURL"));
      }
  
      public String[] getParameterNames()
      {
          return _parameters.getParameterNames();
      }
  
      public String[] getParameterValues(String name)
      {
          return _parameters.getParameterValues(name);
      }
  
  }
  
  
  1.1                  jakarta-tapestry/portlet/src/java/org/apache/tapestry/portlet/RenderRequestServicerToWebRequestServicerBridge.java
  
  Index: RenderRequestServicerToWebRequestServicerBridge.java
  ===================================================================
  // Copyright 2005 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.
  
  package org.apache.tapestry.portlet;
  
  import java.io.IOException;
  
  import javax.portlet.PortletException;
  import javax.portlet.RenderRequest;
  import javax.portlet.RenderResponse;
  
  import org.apache.tapestry.services.WebRequestServicer;
  
  /**
   * Bridges from the <code>tapestry.portlet.RenderRequestServicerPipeline</code> to the standard
   * <code>tapestry.request.WebRequestServicerPipeline</code>.
   * 
   * @author Howard M. Lewis Ship
   * @since 3.1
   */
  public class RenderRequestServicerToWebRequestServicerBridge implements RenderRequestServicer
  {
  
      private PortletRequestGlobals _portletRequestGlobals;
  
      private WebRequestServicer _webRequestServicer;
  
      public void service(RenderRequest request, RenderResponse response) throws IOException,
              PortletException
      {
          _portletRequestGlobals.store(request, response);
  
          PortletWebRequest webRequest = new PortletWebRequest(request);
          PortletWebResponse webResponse = new PortletWebResponse(response);
  
          try
          {
              _webRequestServicer.service(webRequest, webResponse);
          }
          catch (RuntimeException ex)
          {
              throw new PortletException(ex);
          }
      }
  
      public void setPortletRequestGlobals(PortletRequestGlobals portletRequestGlobals)
      {
          _portletRequestGlobals = portletRequestGlobals;
      }
  
      public void setWebRequestServicer(WebRequestServicer webRequestServicer)
      {
          _webRequestServicer = webRequestServicer;
      }
  
  }
  
  
  1.1                  jakarta-tapestry/portlet/src/java/org/apache/tapestry/portlet/PortletLinkFactoryImpl.java
  
  Index: PortletLinkFactoryImpl.java
  ===================================================================
  // Copyright 2005 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.
  
  package org.apache.tapestry.portlet;
  
  import java.util.Map;
  
  import javax.portlet.PortletURL;
  import javax.portlet.RenderResponse;
  
  import org.apache.hivemind.util.Defense;
  import org.apache.tapestry.IRequestCycle;
  import org.apache.tapestry.engine.ILink;
  import org.apache.tapestry.services.impl.LinkFactoryImpl;
  import org.apache.tapestry.util.QueryParameterMap;
  
  /**
   * Extended version of {@link org.apache.tapestry.services.impl.LinkFactoryImpl}&nbsp;that can
   * create generate Portlet URLs.
   * 
   * @author Howard M. Lewis Ship
   * @since 3.1
   */
  public class PortletLinkFactoryImpl extends LinkFactoryImpl
  {
      private RenderResponse _renderResponse;
  
      public void setRenderResponse(RenderResponse renderResponse)
      {
          _renderResponse = renderResponse;
      }
  
      public ILink constructLink(IRequestCycle cycle, Map parameters, boolean stateful)
      {
          Defense.notNull(cycle, "cycle");
          Defense.notNull(parameters, "parameters");
  
          squeezeServiceParameters(parameters);
  
          PortletURL url = _renderResponse.createActionURL();
  
          return new PortletLink(cycle, url, new QueryParameterMap(parameters), stateful);
      }
  }
  
  
  1.1                  jakarta-tapestry/portlet/src/java/org/apache/tapestry/portlet/SetupPortletEngineServices.java
  
  Index: SetupPortletEngineServices.java
  ===================================================================
  // Copyright 2005 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.
  
  package org.apache.tapestry.portlet;
  
  import java.util.List;
  
  import javax.portlet.PortletConfig;
  
  import org.apache.tapestry.services.ApplicationGlobals;
  import org.apache.tapestry.services.ResponseRenderer;
  
  /**
   * Alternative to {@link org.apache.tapestry.engine.SetupServletEngineServices}, but for Portlets
   * and the <code>tapestry.portlet.services.FactoryServices</code> configuration point.
   * 
   * @author Howard M. Lewis Ship
   * @since 3.1
   */
  public class SetupPortletEngineServices implements PortletApplicationInitializer
  {
      private ApplicationGlobals _globals;
  
      private List _factoryServices;
  
      private ResponseRenderer _responseRenderer;
  
      public void initialize(PortletConfig portletConfig)
      {
          _globals.storeFactoryServices(_factoryServices);
          _globals.storeResponseRenderer(_responseRenderer);
      }
  
      public void setFactoryServices(List factoryServices)
      {
          _factoryServices = factoryServices;
      }
  
      public void setGlobals(ApplicationGlobals globals)
      {
          _globals = globals;
      }
  
      public void setResponseRenderer(ResponseRenderer responseRenderer)
      {
          _responseRenderer = responseRenderer;
      }
  }
  
  
  1.1                  jakarta-tapestry/portlet/src/java/org/apache/tapestry/portlet/RenderService.java
  
  Index: RenderService.java
  ===================================================================
  // Copyright 2005 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.
  
  package org.apache.tapestry.portlet;
  
  import java.io.IOException;
  
  import javax.servlet.ServletException;
  
  import org.apache.tapestry.IMarkupWriter;
  import org.apache.tapestry.IPage;
  import org.apache.tapestry.IRequestCycle;
  import org.apache.tapestry.engine.IEngineService;
  import org.apache.tapestry.engine.ILink;
  import org.apache.tapestry.request.ResponseOutputStream;
  import org.apache.tapestry.services.ServiceConstants;
  
  /**
   * Responsible for rendering out a page; a Portlet render URL is built during action processing that
   * stores the active page; this is the page that will be rendered.
   * 
   * @author Howard M. Lewis Ship
   * @since 3.1
   * @see org.apache.tapestry.services.impl.ResponseRendererImpl
   */
  public class RenderService implements IEngineService
  {
  
      public ILink getLink(IRequestCycle cycle, Object parameter)
      {
          throw new UnsupportedOperationException(PortletMessages.unsupportedMethod("getLink"));
      }
  
      public void service(IRequestCycle cycle, ResponseOutputStream output) throws ServletException,
              IOException
      {
          String pageName = cycle.getParameter(ServiceConstants.PAGE);
  
          IPage page = cycle.getPage(pageName);
  
          IMarkupWriter writer = page.getResponseWriter(output);
  
          // TODO: Ensure that content type matches?
          // output.setContentType(writer.getContentType());
  
          boolean discard = true;
  
          try
          {
              cycle.renderPage(writer);
  
              discard = false;
          }
          finally
          {
              // Closing the writer closes its PrintWriter and a whole stack of
              // java.io objects,
              // which tend to stream a lot of output that eventually hits the
              // ResponseOutputStream. If we are discarding output anyway (due to
              // an exception
              // getting thrown during the render), we can save ourselves some
              // trouble
              // by ignoring it.
  
              if (discard)
                  output.setDiscard(true);
  
              writer.close();
  
              if (discard)
                  output.setDiscard(false);
          }
  
          // TODO: Trap errors and do some error reporting here?
      }
  
      public String getName()
      {
          return PortletConstants.RENDER_SERVICE;
      }
  
  }
  
  
  1.1                  jakarta-tapestry/portlet/src/java/org/apache/tapestry/portlet/RenderRequestServicer.java
  
  Index: RenderRequestServicer.java
  ===================================================================
  // Copyright 2005 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.
  
  package org.apache.tapestry.portlet;
  
  import java.io.IOException;
  
  import javax.portlet.PortletException;
  import javax.portlet.RenderRequest;
  import javax.portlet.RenderResponse;
  
  /**
   * Used to define the commands in the <code>tapestry.portlet.RenderRequestServicerPipeline</code>
   * configuration.
   * 
   * @author Howard M. Lewis Ship
   * @since 3.1
   */
  public interface RenderRequestServicer
  {
      public void service(RenderRequest request, RenderResponse response) throws IOException,
              PortletException;
  }
  
  
  1.3       +66 -3     jakarta-tapestry/portlet/src/descriptor/META-INF/hivemodule.xml
  
  Index: hivemodule.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/portlet/src/descriptor/META-INF/hivemodule.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- hivemodule.xml	16 Mar 2005 19:19:25 -0000	1.2
  +++ hivemodule.xml	17 Mar 2005 21:53:33 -0000	1.3
  @@ -19,6 +19,10 @@
     
     Add on for Tapestry that adds native Portlet support.
     
  +  <dependency module-id="tapestry" version="3.1.0"/>
  +  
  +  <sub-module descriptor="tapestry.portlet.services.xml"/>
  +  
     <configuration-point id="PortletApplicationInitializers" schema-id="hivemind.lib.ChainContribution">
       
       Defines the steps for initializing a Tapestry portlet application.
  @@ -83,20 +87,60 @@
       </invoke-factory>  
     </service-point>
     
  -  <service-point id="ActionPortletToWebRequestServicerPipelineBridge" interface="ActionRequestServicer">
  +  <service-point id="ActionRequestServicerToWebRequestServicerBridge" interface="ActionRequestServicer">
       
       Bridge from the ActionRequestServicerPipeline to
       the tapestry.request.WebRequestServicer pipeline.
       
       <invoke-factory model="primitive">
  -      <construct class="ActionPortletToWebRequestServicerPipelineBridge">
  +      <construct class="ActionRequestServicerToWebRequestServicerBridge">
  +        <set-service property="portletRequestGlobals" service-id="PortletRequestGlobals"/>
  +        <set-service property="webRequestServicer" service-id="tapestry.request.WebRequestServicerPipeline"/>
  +      </construct>
  +    </invoke-factory>
  +    
  +  </service-point>
  +  
  +  <contribution configuration-id="ActionRequestServicerPipeline">
  +    <terminator object="service:ActionRequestServicerToWebRequestServicerBridge"/>
  +  </contribution>
  +  
  +  <configuration-point id="RenderRequestServicerPipeline" schema-id="hivemind.lib.Pipeline">
  +    
  +    A pipeline for processing an incoming Portlet action request.
  +    
  +  </configuration-point>   
  +      
  +  <service-point id="RenderRequestServicer" interface="RenderRequestServicer">  
  +    
  +    Service for handling Portlet action requests, built around
  +    the RenderRequestServicerPipeline configuration.
  +    
  +    <invoke-factory service-id="hivemind.lib.PipelineFactory" model="primitive">
  +      <create-pipeline filter-interface="RenderRequestServicerFilter"
  +        configuration-id="RenderRequestServicerPipeline"/>
  +    </invoke-factory>  
  +  </service-point>
  +  
  +  <service-point id="RenderRequestServicerToWebRequestServicerBridge" interface="RenderRequestServicer">
  +    
  +    Bridge from the RenderRequestServicerPipeline to
  +    the tapestry.request.WebRequestServicer pipeline.
  +    
  +    <invoke-factory model="primitive">
  +      <construct class="RenderRequestServicerToWebRequestServicerBridge">
           <set-service property="portletRequestGlobals" service-id="PortletRequestGlobals"/>
  -        <set-service property="webRequestServicer" service-id="tapestry.request.WebRequestServicer"/>
  +        <set-service property="webRequestServicer" service-id="tapestry.request.WebRequestServicerPipeline"/>
         </construct>
       </invoke-factory>
       
     </service-point>
     
  +  <contribution configuration-id="RenderRequestServicerPipeline">
  +    <terminator object="service:RenderRequestServicerToWebRequestServicerBridge"/>
  +  </contribution>
  +
  +
     <service-point id="PortletRequestGlobals" interface="PortletRequestGlobals">
       
       Stores the current request and response objects.
  @@ -105,4 +149,23 @@
       
     </service-point>
     
  +  <service-point id="ActionResponse" interface="javax.portlet.ActionResponse">
  +    
  +    The ActionResponse for the current request.
  +    
  +    <invoke-factory service-id="hivemind.lib.ServicePropertyFactory" model="primitive">
  +      <construct service-id="PortletRequestGlobals" property="actionResponse"/>
  +    </invoke-factory>
  +    
  +  </service-point>
  +  
  +  <service-point id="RenderResponse" interface="javax.portlet.RenderResponse">
  +    
  +    The RenderResponse for the current request.
  +    
  +    <invoke-factory service-id="hivemind.lib.ServicePropertyFactory" model="primitive">
  +      <construct service-id="PortletRequestGlobals" property="renderResponse"/>
  +    </invoke-factory>
  +  </service-point>
  +  
   </module>
  \ No newline at end of file
  
  
  
  1.1                  jakarta-tapestry/portlet/src/descriptor/META-INF/tapestry.portlet.services.xml
  
  Index: tapestry.portlet.services.xml
  ===================================================================
  <?xml version="1.0"?>
  <!-- 
     Copyright 2005 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.
  -->
  
  <module id="tapestry.portlet.services" version="3.1.0" package="org.apache.tapestry.portlet">
  
    Defines engine services used by Tapestry portlet support.
    
    <configuration-point id="FactoryServices" schema-id="tapestry.services.EngineServices">
      
      Configuration point for the factory default services. Each contributed service
      must have a unique name.
      
    </configuration-point>
      
    <contribution configuration-id="FactoryServices">
      <service object="service:tapestry.services.Home"/>
      <service object="service:tapestry.services.Action"/>
      <service object="service:tapestry.services.Direct"/>
      <service object="service:tapestry.services.Page"/>
      <service object="service:tapestry.services.Reset"/>
      <service object="service:tapestry.services.Restart"/>
      <service object="service:tapestry.services.Asset"/>
  	  <service object="service:tapestry.services.External"/>
      <service object="service:Render"/>
    </contribution>    
    
   <service-point id="Render" interface="org.apache.tapestry.engine.IEngineService">
    
    The single service that should be referenced by a Portlet render request.
    
    <create-instance class="RenderService" model="primitive"/>
    
   </service-point>
   
   <service-point id="ResponseRenderer" interface="org.apache.tapestry.services.ResponseRenderer">
    
    Portal specific implementation of ResponseRender that builds a 
    Portlet Render URL that references the render engine service.
    
    <invoke-factory model="primitive">
      <construct class="PortletResponseRenderer">
        <set-service property="response" service-id="tapestry.portlet.ActionResponse"/>
      </construct>
    </invoke-factory>
   </service-point>
    
   <service-point id="SetupPortletEngineServices" interface="PortletApplicationInitializer">
    
    Contributed into the tapestry.init.ApplicationInitializers configuration point
    to install the servlet-specific framework services into the
    tapestry.globals.ApplicationGlobals service.
    
    <invoke-factory model="primitive">
      <construct class="SetupPortletEngineServices">
        <set-service property="globals" service-id="tapestry.globals.ApplicationGlobals"/>
        <set-configuration property="factoryServices" configuration-id="FactoryServices"/>
        <set-service property="responseRenderer" service-id="ResponseRenderer"/>
      </construct>
    </invoke-factory>
   </service-point>
   
   <contribution configuration-id="tapestry.portlet.PortletApplicationInitializers">
    <command id="SetupPortletEngineServices" object="service:SetupPortletEngineServices"/>
   </contribution>
    
  </module>
  
  
  1.2       +65 -5     jakarta-tapestry/portlet/src/test/org/apache/tapestry/portlet/TestApplicationPortlet.java
  
  Index: TestApplicationPortlet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/portlet/src/test/org/apache/tapestry/portlet/TestApplicationPortlet.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestApplicationPortlet.java	16 Mar 2005 19:19:24 -0000	1.1
  +++ TestApplicationPortlet.java	17 Mar 2005 21:53:33 -0000	1.2
  @@ -18,6 +18,8 @@
   import javax.portlet.ActionResponse;
   import javax.portlet.PortletConfig;
   import javax.portlet.PortletContext;
  +import javax.portlet.RenderRequest;
  +import javax.portlet.RenderResponse;
   
   import org.apache.hivemind.Registry;
   import org.apache.hivemind.test.HiveMindTestCase;
  @@ -56,8 +58,13 @@
           return (ActionRequestServicer) newMock(ActionRequestServicer.class);
       }
   
  +    private RenderRequestServicer newRenderRequestServicer()
  +    {
  +        return (RenderRequestServicer) newMock(RenderRequestServicer.class);
  +    }
  +
       private Registry newRegistry(PortletApplicationInitializer initializer,
  -            ActionRequestServicer actionRequestServicer)
  +            ActionRequestServicer actionRequestServicer, RenderRequestServicer renderRequestServicer)
       {
           MockControl control = newControl(Registry.class);
           Registry registry = (Registry) control.getMock();
  @@ -70,6 +77,9 @@
           registry.getService("tapestry.portlet.ActionRequestServicer", ActionRequestServicer.class);
           control.setReturnValue(actionRequestServicer);
   
  +        registry.getService("tapestry.portlet.RenderRequestServicer", RenderRequestServicer.class);
  +        control.setReturnValue(renderRequestServicer);
  +
           return registry;
       }
   
  @@ -88,6 +98,16 @@
           return (ActionResponse) newMock(ActionResponse.class);
       }
   
  +    private RenderRequest newRenderRequest()
  +    {
  +        return (RenderRequest) newMock(RenderRequest.class);
  +    }
  +
  +    private RenderResponse newRenderResponse()
  +    {
  +        return (RenderResponse) newMock(RenderResponse.class);
  +    }
  +
       public void testParseOptionalDescriptors() throws Exception
       {
           MockControl configc = MockControl.createControl(PortletConfig.class);
  @@ -112,10 +132,10 @@
   
           context.getResource("/WEB-INF/hivemodule.xml");
           contextc.setReturnValue(getClass().getResource("hivemodule.xml"), 2);
  -        
  +
           context.getResource("/WEB-INF/myportlet/myportlet.application");
           contextc.setReturnValue(null);
  -        
  +
           context.getResource("/WEB-INF/myportlet.application");
           contextc.setReturnValue(null);
   
  @@ -127,6 +147,7 @@
   
           assertNotNull(ap._registry);
           assertNotNull(ap._actionRequestServicer);
  +        assertNotNull(ap._renderRequestServicer);
   
           assertEquals("parsed", ap._registry.expandSymbols("${module-portlet}", null));
           assertEquals("parsed", ap._registry.expandSymbols("${module-plain}", null));
  @@ -136,7 +157,9 @@
       {
           PortletApplicationInitializer initializer = newInitializer();
           ActionRequestServicer actionRequestServicer = newActionRequestServicer();
  -        Registry registry = newRegistry(initializer, actionRequestServicer);
  +        RenderRequestServicer renderRequestServicer = newRenderRequestServicer();
  +
  +        Registry registry = newRegistry(initializer, actionRequestServicer, renderRequestServicer);
           PortletConfig config = newConfig();
   
           initializer.initialize(config);
  @@ -162,7 +185,10 @@
       {
           PortletApplicationInitializer initializer = newInitializer();
           ActionRequestServicer actionRequestServicer = newActionRequestServicer();
  -        Registry registry = newRegistry(initializer, actionRequestServicer);
  +        RenderRequestServicer renderRequestServicer = newRenderRequestServicer();
  +
  +        Registry registry = newRegistry(initializer, actionRequestServicer, renderRequestServicer);
  +
           PortletConfig config = newConfig();
   
           initializer.initialize(config);
  @@ -188,4 +214,38 @@
   
           verifyControls();
       }
  +
  +    public void testProcessRender() throws Exception
  +    {
  +        PortletApplicationInitializer initializer = newInitializer();
  +        ActionRequestServicer actionRequestServicer = newActionRequestServicer();
  +        RenderRequestServicer renderRequestServicer = newRenderRequestServicer();
  +
  +        Registry registry = newRegistry(initializer, actionRequestServicer, renderRequestServicer);
  +
  +        PortletConfig config = newConfig();
  +
  +        initializer.initialize(config);
  +
  +        replayControls();
  +
  +        ApplicationPortletFixture portlet = new ApplicationPortletFixture(registry);
  +
  +        portlet.init(config);
  +
  +        verifyControls();
  +
  +        RenderRequest request = newRenderRequest();
  +        RenderResponse response = newRenderResponse();
  +
  +        renderRequestServicer.service(request, response);
  +
  +        registry.cleanupThread();
  +
  +        replayControls();
  +
  +        portlet.render(request, response);
  +
  +        verifyControls();
  +    }
   }
  \ No newline at end of file
  
  
  
  1.1                  jakarta-tapestry/portlet/src/test/org/apache/tapestry/portlet/TestPortletResponseRenderer.java
  
  Index: TestPortletResponseRenderer.java
  ===================================================================
  // Copyright 2005 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.
  
  package org.apache.tapestry.portlet;
  
  import javax.portlet.ActionResponse;
  
  import org.apache.hivemind.test.HiveMindTestCase;
  import org.apache.tapestry.IPage;
  import org.apache.tapestry.IRequestCycle;
  import org.apache.tapestry.services.ServiceConstants;
  import org.easymock.MockControl;
  
  /**
   * Tests for {@link org.apache.tapestry.portlet.PortletResponseRenderer}.
   * 
   * @author Howard M. Lewis Ship
   * @since 3.1
   */
  public class TestPortletResponseRenderer extends HiveMindTestCase
  {
      private ActionResponse newResponse()
      {
          return (ActionResponse) newMock(ActionResponse.class);
      }
  
      private IPage newPage(String name)
      {
          MockControl control = newControl(IPage.class);
          IPage page = (IPage) control.getMock();
  
          page.getPageName();
          control.setReturnValue(name);
  
          return page;
      }
  
      private IRequestCycle newCycle(IPage page)
      {
          MockControl control = newControl(IRequestCycle.class);
          IRequestCycle cycle = (IRequestCycle) control.getMock();
  
          cycle.getPage();
          control.setReturnValue(page);
  
          return cycle;
      }
  
      public void testSuccess() throws Exception
      {
          IPage page = newPage("Frodo");
          IRequestCycle cycle = newCycle(page);
          ActionResponse response = newResponse();
  
          response.setRenderParameter(ServiceConstants.SERVICE, PortletConstants.RENDER_SERVICE);
          response.setRenderParameter(ServiceConstants.PAGE, "Frodo");
  
          replayControls();
  
          PortletResponseRenderer renderer = new PortletResponseRenderer();
          renderer.setResponse(response);
  
          renderer.renderResponse(cycle, null);
  
          verifyControls();
      }
  }
  
  
  1.1                  jakarta-tapestry/portlet/src/test/org/apache/tapestry/portlet/TestPortletLink.java
  
  Index: TestPortletLink.java
  ===================================================================
  // Copyright 2005 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.
  
  package org.apache.tapestry.portlet;
  
  import javax.portlet.PortletURL;
  
  import org.apache.hivemind.test.HiveMindTestCase;
  import org.apache.tapestry.IRequestCycle;
  import org.apache.tapestry.engine.ILink;
  import org.apache.tapestry.util.QueryParameterMap;
  import org.easymock.MockControl;
  
  /**
   * Tests for {@link org.apache.tapestry.portlet.PortletLink}.
   * 
   * @author Howard M. Lewis Ship
   * @since 3.1
   */
  public class TestPortletLink extends HiveMindTestCase
  {
      private IRequestCycle newCycle()
      {
          return (IRequestCycle) newMock(IRequestCycle.class);
      }
  
      private PortletURL newPortletURL()
      {
          return (PortletURL) newMock(PortletURL.class);
      }
  
      private QueryParameterMap newParameters()
      {
          return (QueryParameterMap) newMock(QueryParameterMap.class);
      }
  
      public void testGetAbsoluteURL()
      {
          IRequestCycle cycle = newCycle();
          PortletURL url = newPortletURL();
          QueryParameterMap parameters = newParameters();
  
          replayControls();
  
          ILink link = new PortletLink(cycle, url, parameters, false);
  
          try
          {
              link.getAbsoluteURL();
              unreachable();
          }
          catch (UnsupportedOperationException ex)
          {
              // Accept.
          }
  
          try
          {
              link.getAbsoluteURL(null, null, -1, null, false);
              unreachable();
          }
          catch (UnsupportedOperationException ex)
          {
              // Accept.
          }
  
          verifyControls();
      }
  
      public void testGetParameterNames()
      {
          IRequestCycle cycle = newCycle();
          PortletURL url = newPortletURL();
  
          MockControl control = newControl(QueryParameterMap.class);
          QueryParameterMap parameters = (QueryParameterMap) control.getMock();
  
          String[] names =
          { "Fred", "Barney" };
  
          parameters.getParameterNames();
          control.setReturnValue(names);
  
          replayControls();
  
          ILink link = new PortletLink(cycle, url, parameters, false);
  
          assertSame(names, link.getParameterNames());
  
          verifyControls();
      }
  
      public void testGetParameterValues()
      {
          IRequestCycle cycle = newCycle();
          PortletURL url = newPortletURL();
  
          MockControl control = newControl(QueryParameterMap.class);
          QueryParameterMap parameters = (QueryParameterMap) control.getMock();
  
          String[] values =
          { "Fred", "Barney" };
  
          parameters.getParameterValues("bedrock");
          control.setReturnValue(values);
  
          replayControls();
  
          ILink link = new PortletLink(cycle, url, parameters, false);
  
          assertSame(values, link.getParameterValues("bedrock"));
  
          verifyControls();
      }
  
      public void testGetURL()
      {
          IRequestCycle cycle = newCycle();
          PortletURL url = newPortletURL();
  
          MockControl control = newControl(QueryParameterMap.class);
          QueryParameterMap parameters = (QueryParameterMap) control.getMock();
  
          parameters.getParameterNames();
          control.setReturnValue(new String[0]);
  
          replayControls();
  
          ILink link = new PortletLink(cycle, url, parameters, false);
  
          assertEquals(url.toString(), link.getURL());
  
          verifyControls();
      }
  
      public void testGetURLIncludeParameters()
      {
          IRequestCycle cycle = newCycle();
          PortletURL url = newPortletURL();
  
          MockControl control = newControl(QueryParameterMap.class);
          QueryParameterMap parameters = (QueryParameterMap) control.getMock();
  
          String[] values =
          { "Fred", "Barney" };
  
          parameters.getParameterNames();
          control.setReturnValue(new String[]
          { "bedrock" });
          parameters.getParameterValues("bedrock");
          control.setReturnValue(values);
  
          url.setParameter("bedrock", values);
  
          replayControls();
  
          ILink link = new PortletLink(cycle, url, parameters, false);
  
          assertEquals(url.toString(), link.getURL());
  
          verifyControls();
      }
  
      public void testGetURLStatefulWithAnchor()
      {
          PortletURL url = newPortletURL();
  
          MockControl cyclec = newControl(IRequestCycle.class);
          IRequestCycle cycle = (IRequestCycle) cyclec.getMock();
  
          cycle.encodeURL(url.toString());
          cyclec.setReturnValue("/encoded-url");
  
          QueryParameterMap parameters = newParameters();
  
          replayControls();
  
          ILink link = new PortletLink(cycle, url, parameters, true);
  
          assertEquals("/encoded-url#anchor", link.getURL("anchor", false));
  
          verifyControls();
      }
  }
  
  
  1.1                  jakarta-tapestry/portlet/src/test/org/apache/tapestry/portlet/TestPortletServicerBridges.java
  
  Index: TestPortletServicerBridges.java
  ===================================================================
  // Copyright 2005 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.
  
  package org.apache.tapestry.portlet;
  
  import java.io.IOException;
  
  import javax.portlet.ActionRequest;
  import javax.portlet.ActionResponse;
  import javax.portlet.PortletException;
  import javax.portlet.RenderRequest;
  import javax.portlet.RenderResponse;
  
  import org.apache.hivemind.test.AggregateArgumentsMatcher;
  import org.apache.hivemind.test.ArgumentMatcher;
  import org.apache.hivemind.test.HiveMindTestCase;
  import org.apache.hivemind.test.TypeMatcher;
  import org.apache.tapestry.services.WebRequestServicer;
  import org.apache.tapestry.web.WebRequest;
  import org.apache.tapestry.web.WebResponse;
  import org.easymock.MockControl;
  
  /**
   * Tests for {@link ActionRequestServicerToWebRequestServicerBridge}&nbsp;and
   * {@link org.apache.tapestry.portlet.RenderRequestServicerToWebRequestServicerBridge}.
   * 
   * @author Howard M. Lewis Ship
   * @since 3.1
   */
  public class TestPortletServicerBridges extends HiveMindTestCase
  {
      private class WebRequestServicerFixture implements WebRequestServicer
      {
          WebRequest _request;
  
          WebResponse _response;
  
          public void service(WebRequest request, WebResponse response) throws IOException
          {
              _request = request;
              _response = response;
          }
  
      }
  
      public void testActionBridgeSuccess() throws Exception
      {
          ActionRequest request = (ActionRequest) newMock(ActionRequest.class);
  
          MockControl responsec = newControl(ActionResponse.class);
          ActionResponse response = (ActionResponse) responsec.getMock();
  
          PortletRequestGlobals prg = (PortletRequestGlobals) newMock(PortletRequestGlobals.class);
          WebRequestServicerFixture wrs = new WebRequestServicerFixture();
  
          prg.store(request, response);
  
          request.removeAttribute("FOO");
          response.encodeURL("FOO");
          responsec.setReturnValue(null);
  
          replayControls();
  
          ActionRequestServicerToWebRequestServicerBridge bridge = new ActionRequestServicerToWebRequestServicerBridge();
          bridge.setPortletRequestGlobals(prg);
          bridge.setWebRequestServicer(wrs);
  
          bridge.service(request, response);
  
          // Test that the WebXXX wrappers createde by the bridge and passed to the WebRequestServicer
          // encapsulate the ActionRequest and ActionResponse
  
          wrs._request.setAttribute("FOO", null);
          wrs._response.encodeURL("FOO");
  
          verifyControls();
      }
  
      public void testRenderBridgeSuccess() throws Exception
      {
          RenderRequest request = (RenderRequest) newMock(RenderRequest.class);
  
          MockControl responsec = newControl(RenderResponse.class);
          RenderResponse response = (RenderResponse) responsec.getMock();
  
          PortletRequestGlobals prg = (PortletRequestGlobals) newMock(PortletRequestGlobals.class);
          WebRequestServicerFixture wrs = new WebRequestServicerFixture();
  
          prg.store(request, response);
  
          request.removeAttribute("FOO");
          response.encodeURL("FOO");
          responsec.setReturnValue(null);
  
          replayControls();
  
          RenderRequestServicerToWebRequestServicerBridge bridge = new RenderRequestServicerToWebRequestServicerBridge();
          bridge.setPortletRequestGlobals(prg);
          bridge.setWebRequestServicer(wrs);
  
          bridge.service(request, response);
  
          // Test that the WebXXX wrappers createde by the bridge and passed to the WebRequestServicer
          // encapsulate the RenderRequest and RenderResponse
  
          wrs._request.setAttribute("FOO", null);
          wrs._response.encodeURL("FOO");
  
          verifyControls();
      }
  
      public void testActionBridgeFailure() throws Exception
      {
          ActionRequest request = (ActionRequest) newMock(ActionRequest.class);
          ActionResponse response = (ActionResponse) newMock(ActionResponse.class);
          PortletRequestGlobals prg = (PortletRequestGlobals) newMock(PortletRequestGlobals.class);
  
          MockControl control = newControl(WebRequestServicer.class);
          WebRequestServicer servicer = (WebRequestServicer) control.getMock();
  
          Throwable t = new RuntimeException("Failure.");
  
          prg.store(request, response);
          servicer.service(new PortletWebRequest(request), new PortletWebResponse(response));
          control.setMatcher(new AggregateArgumentsMatcher(new ArgumentMatcher[]
          { new TypeMatcher(), new TypeMatcher() }));
          control.setThrowable(t);
  
          replayControls();
  
          ActionRequestServicerToWebRequestServicerBridge bridge = new ActionRequestServicerToWebRequestServicerBridge();
          bridge.setPortletRequestGlobals(prg);
          bridge.setWebRequestServicer(servicer);
  
          try
          {
  
              bridge.service(request, response);
              unreachable();
          }
          catch (PortletException ex)
          {
              // PortletException doesn't seem to copy the
              // message?
              // assertEquals("Failure.", ex.getMessage());
              // Note: implemented by PortletException, not tied
              // to JDK 1.4
              assertSame(t, ex.getCause());
          }
  
          verifyControls();
      }
  
      public void testRenderBridgeFailure() throws Exception
      {
          RenderRequest request = (RenderRequest) newMock(RenderRequest.class);
          RenderResponse response = (RenderResponse) newMock(RenderResponse.class);
          PortletRequestGlobals prg = (PortletRequestGlobals) newMock(PortletRequestGlobals.class);
  
          MockControl control = newControl(WebRequestServicer.class);
          WebRequestServicer servicer = (WebRequestServicer) control.getMock();
  
          Throwable t = new RuntimeException("Failure.");
  
          prg.store(request, response);
          servicer.service(new PortletWebRequest(request), new PortletWebResponse(response));
          control.setMatcher(new AggregateArgumentsMatcher(new ArgumentMatcher[]
          { new TypeMatcher(), new TypeMatcher() }));
          control.setThrowable(t);
  
          replayControls();
  
          RenderRequestServicerToWebRequestServicerBridge bridge = new RenderRequestServicerToWebRequestServicerBridge();
          bridge.setPortletRequestGlobals(prg);
          bridge.setWebRequestServicer(servicer);
  
          try
          {
  
              bridge.service(request, response);
              unreachable();
          }
          catch (PortletException ex)
          {
              // PortletException doesn't seem to copy the
              // message?
              // assertEquals("Failure.", ex.getMessage());
              // Note: implemented by PortletException, not tied
              // to JDK 1.4
              assertSame(t, ex.getCause());
          }
  
          verifyControls();
      }
  }
  
  
  1.32      +1 -1      jakarta-tapestry/framework/src/descriptor/META-INF/hivemodule.xml
  
  Index: hivemodule.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/descriptor/META-INF/hivemodule.xml,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- hivemodule.xml	14 Mar 2005 22:29:47 -0000	1.31
  +++ hivemodule.xml	17 Mar 2005 21:53:34 -0000	1.32
  @@ -75,7 +75,7 @@
           <set-service property="scriptSource" service-id="tapestry.script.ScriptSource"/>
           <set-service property="serviceMap" service-id="tapestry.services.ServiceMap"/>
           <set-service property="requestExceptionReporter" service-id="RequestExceptionReporter"/>
  -        <set-service property="responseRenderer" service-id="tapestry.request.ResponseRenderer"/>
  +        <set-object property="responseRenderer" value="service-property:tapestry.globals.ApplicationGlobals:responseRenderer"/>
           <set-service property="linkFactory" service-id="tapestry.url.LinkFactory"/>
           <set-service property="requestCycleFactory" service-id="tapestry.request.RequestCycleFactory"/>
           <set-service property="applicationStateManager" service-id="tapestry.state.ApplicationStateManager"/>
  
  
  
  1.19      +4 -5      jakarta-tapestry/framework/src/descriptor/META-INF/tapestry.services.xml
  
  Index: tapestry.services.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/descriptor/META-INF/tapestry.services.xml,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- tapestry.services.xml	16 Mar 2005 19:19:25 -0000	1.18
  +++ tapestry.services.xml	17 Mar 2005 21:53:34 -0000	1.19
  @@ -162,8 +162,7 @@
         <construct class="org.apache.tapestry.services.impl.ServiceMapImpl">
           <set-object property="factoryServices" 
             value="service-property:tapestry.globals.ApplicationGlobals:factoryServices"/>
  -        <set-object property="applicationServices" 
  -          value="service-property:tapestry.globals.ApplicationGlobals:applicationServices"/>
  +        <set-configuration property="applicationServices"  configuration-id="ApplicationServices"/>
         </construct>
       </invoke-factory>
       
  @@ -188,14 +187,14 @@
    <service-point id="SetupServletEngineServices" interface="org.apache.tapestry.services.ApplicationInitializer">
     
     Contributed into the tapestry.init.ApplicationInitializers configuration point
  -  to install the servlet-specific application and framework services into the
  -  tapestry.globals.ApplicationGlobals services.
  +  to install the servlet-specific framework services into the
  +  tapestry.globals.ApplicationGlobals service.
     
     <invoke-factory model="primitive">
       <construct class="SetupServletEngineServices">
         <set-service property="globals" service-id="tapestry.globals.ApplicationGlobals"/>
  +      <set-service property="responseRenderer" service-id="tapestry.request.ResponseRenderer"/>
         <set-configuration property="factoryServices" configuration-id="FactoryServices"/>
  -      <set-configuration property="applicationServices" configuration-id="ApplicationServices"/>
       </construct>
     </invoke-factory>
    </service-point>
  
  
  
  1.8       +3 -3      jakarta-tapestry/framework/src/java/org/apache/tapestry/services/impl/LinkFactoryImpl.java
  
  Index: LinkFactoryImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/services/impl/LinkFactoryImpl.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- LinkFactoryImpl.java	8 Mar 2005 15:36:35 -0000	1.7
  +++ LinkFactoryImpl.java	17 Mar 2005 21:53:34 -0000	1.8
  @@ -62,7 +62,7 @@
       private final Object[] EMPTY = new Object[0];
   
       private URLCodec _codec = new URLCodec();
  -    
  +
       private WebRequest _request;
   
       public void initializeService()
  @@ -133,7 +133,7 @@
           return result;
       }
   
  -    private void squeezeServiceParameters(Map parameters)
  +    protected void squeezeServiceParameters(Map parameters)
       {
           Object[] serviceParameters = (Object[]) parameters.get(ServiceConstants.PARAMETER);
   
  @@ -198,7 +198,7 @@
       {
           _contextPath = contextPath;
       }
  -    
  +
       public void setRequest(WebRequest request)
       {
           _request = request;
  
  
  
  1.8       +14 -9     jakarta-tapestry/framework/src/java/org/apache/tapestry/services/impl/ApplicationGlobalsImpl.java
  
  Index: ApplicationGlobalsImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/services/impl/ApplicationGlobalsImpl.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ApplicationGlobalsImpl.java	16 Mar 2005 19:19:25 -0000	1.7
  +++ ApplicationGlobalsImpl.java	17 Mar 2005 21:53:34 -0000	1.8
  @@ -17,6 +17,7 @@
   import java.util.List;
   
   import org.apache.tapestry.services.ApplicationGlobals;
  +import org.apache.tapestry.services.ResponseRenderer;
   import org.apache.tapestry.spec.IApplicationSpecification;
   import org.apache.tapestry.web.WebActivator;
   import org.apache.tapestry.web.WebContext;
  @@ -37,7 +38,7 @@
   
       private List _factoryServices;
   
  -    private List _applicationServices;
  +    private ResponseRenderer _responseRenderer;
   
       public void storeActivator(WebActivator activator)
       {
  @@ -74,19 +75,23 @@
           _webContext = context;
       }
   
  -    public void storeServices(List factoryServices, List applicationServices)
  +    public void storeFactoryServices(List factoryServices)
       {
  -      _factoryServices = factoryServices;
  -      _applicationServices = applicationServices;
  -    }
  -    
  -    public List getApplicationServices()
  -    {
  -        return _applicationServices;
  +        _factoryServices = factoryServices;
       }
   
       public List getFactoryServices()
       {
           return _factoryServices;
       }
  +
  +    public ResponseRenderer getResponseRenderer()
  +    {
  +        return _responseRenderer;
  +    }
  +
  +    public void storeResponseRenderer(ResponseRenderer responseRenderer)
  +    {
  +        _responseRenderer = responseRenderer;
  +    }
   }
  \ No newline at end of file
  
  
  
  1.2       +15 -8     jakarta-tapestry/framework/src/java/org/apache/tapestry/engine/SetupServletEngineServices.java
  
  Index: SetupServletEngineServices.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/engine/SetupServletEngineServices.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SetupServletEngineServices.java	16 Mar 2005 19:19:25 -0000	1.1
  +++ SetupServletEngineServices.java	17 Mar 2005 21:53:34 -0000	1.2
  @@ -20,9 +20,15 @@
   
   import org.apache.tapestry.services.ApplicationGlobals;
   import org.apache.tapestry.services.ApplicationInitializer;
  +import org.apache.tapestry.services.ResponseRenderer;
   
   /**
  + * Invokes {@link org.apache.tapestry.services.ApplicationGlobals#storeFactoryServices(List)}
  + * &nbsp;to set up the based set of <em>servlet</em> engine services. Portlets use a seperate
  + * configuration of to define a slightly different set of engine services.
  + * 
    * @author Howard M. Lewis Ship
  + * @since 3.1
    */
   public class SetupServletEngineServices implements ApplicationInitializer
   {
  @@ -30,26 +36,27 @@
   
       private List _factoryServices;
   
  -    private List _applicationServices;
  +    private ResponseRenderer _responseRenderer;
   
       public void initialize(HttpServlet servlet)
       {
  -        _globals.storeServices(_factoryServices, _applicationServices);
  +        _globals.storeFactoryServices(_factoryServices);
  +        _globals.storeResponseRenderer(_responseRenderer);
       }
   
  -    public void setApplicationServices(List applicationServices)
  +    public void setGlobals(ApplicationGlobals globals)
       {
  -        _applicationServices = applicationServices;
  +        _globals = globals;
       }
   
       public void setFactoryServices(List factoryServices)
       {
           _factoryServices = factoryServices;
       }
  -
  -    public void setGlobals(ApplicationGlobals globals)
  +    
  +    public void setResponseRenderer(ResponseRenderer responseRenderer)
       {
  -        _globals = globals;
  +        _responseRenderer = responseRenderer;
       }
  -
  +    
   }
  \ No newline at end of file
  
  
  
  1.8       +9 -10     jakarta-tapestry/framework/src/java/org/apache/tapestry/services/ApplicationGlobals.java
  
  Index: ApplicationGlobals.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/services/ApplicationGlobals.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ApplicationGlobals.java	16 Mar 2005 19:19:25 -0000	1.7
  +++ ApplicationGlobals.java	17 Mar 2005 21:53:34 -0000	1.8
  @@ -21,9 +21,9 @@
   import org.apache.tapestry.web.WebContext;
   
   /**
  - * A "global" holder for the servlet, servlet context and application specification.
  - * <p>
  - * Note: the servlet API portions of this will likely move to a seperate service.
  + * A "global" holder for various services and configurations. In many cases, these values end up as
  + * properties of the {@link org.apache.tapestry.services.Infrastructure}. The servlet and portlet
  + * implementations differentiate themselves by storing different values into these properties.
    * 
    * @author Howard Lewis Ship
    * @since 3.1
  @@ -59,16 +59,14 @@
       public String getActivatorName();
   
       /**
  -     * Stores the two sets of engine service definitions. Application services override factory
  +     * Stores the default set of engine service definitions. Application services override factory
        * services with the same {@link org.apache.tapestry.engine.IEngineService#getName()name}.
        * 
        * @param factoryServices
        *            List of {@link org.apache.tapestry.engine.IEngineService}.
  -     * @param applicationServices
  -     *            List of {@link org.apache.tapestry.engine.IEngineService}.
        */
   
  -    public void storeServices(List factoryServices, List applicationServices);
  +    public void storeFactoryServices(List factoryServices);
   
       /**
        * Returns the factory default services as a List of
  @@ -78,9 +76,10 @@
       public List getFactoryServices();
   
       /**
  -     * Returns the application services (and overrides) as a List of
  -     * {@link org.apache.tapestry.engine.IEngineService}.
  +     * Stores the {@link org.apache.tapestry.services.ResponseRenderer}.
        */
   
  -    public List getApplicationServices();
  +    public void storeResponseRenderer(ResponseRenderer renderer);
  +
  +    public ResponseRenderer getResponseRenderer();
   }
  \ No newline at end of file
  
  
  

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