cvs commit: jakarta-tapestry/framework/src/java/org/apache/tapestry/listener ListenerMethodInvokerImpl.java ListenerMapSourceImpl.java

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

cvs commit: jakarta-tapestry/framework/src/java/org/apache/tapestry/listener ListenerMethodInvokerImpl.java ListenerMapSourceImpl.java

hlship
hlship      2005/05/10 15:50:57

  Modified:    portlet/src/java/org/apache/tapestry/portlet
                        PortletRequestGlobalsImpl.java
                        PortletHomeService.java PortletRequestGlobals.java
               framework/src/java/org/apache/tapestry/engine
                        EngineMessages.java
               portlet/src/test/org/apache/tapestry/portlet
                        TestPortletHomeService.java
               framework/src/java/org/apache/tapestry/valid
                        RenderString.java ValidationConstraint.java
                        FieldTracking.java ValidationDelegate.java
               portlet/src/descriptor/META-INF
                        tapestry.portlet.services.xml hivemodule.xml
               framework/src/java/org/apache/tapestry/listener
                        ListenerMethodInvokerImpl.java
                        ListenerMapSourceImpl.java
  Added:       portlet/src/java/org/apache/tapestry/portlet
                        PortletPageResolver.java
                        DefaultPortletPageResolver.java
                        MatchingPortletPageResolver.java
                        PageResolverContribution.java
               portlet/src/test/org/apache/tapestry/portlet
                        TestMatchingPortletPageResolver.java
               portlet/src/descriptor/META-INF
                        tapestry.portlet.resolver.xml
  Log:
  Make sure all the bits and pieces of a validation delegate are serializable and java UID.
  Make it easy to subclass the ListenerMapSourceImpl to provide extra functionality related to the synthetic lilsteners.
  Add logic to the Portlet home service to dynamically select the right page based on mime type, portlet mode, window state, etc.
 
  Revision  Changes    Path
  1.5       +14 -2     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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- PortletRequestGlobalsImpl.java 18 Apr 2005 17:08:38 -0000 1.4
  +++ PortletRequestGlobalsImpl.java 10 May 2005 22:50:57 -0000 1.5
  @@ -16,12 +16,13 @@
   
   import javax.portlet.ActionRequest;
   import javax.portlet.ActionResponse;
  +import javax.portlet.PortletRequest;
   import javax.portlet.RenderRequest;
   import javax.portlet.RenderResponse;
   
   /**
  - * Implementation of the <code>tapestry.portlet.PortletRequestGlobals</code> service, which uses
  - * the threaded service lifecycle model.
  + * Implementation of the tapestry.portlet.PortletRequestGlobals service, which uses the threaded
  + * service lifecycle model.
    *
    * @author Howard M. Lewis Ship
    * @since 4.0
  @@ -36,15 +37,21 @@
   
       private RenderRequest _renderRequest;
   
  +    private PortletRequest _portletRequest;
  +
       public void store(ActionRequest request, ActionResponse response)
       {
           _actionRequest = request;
  +        _portletRequest = request;
  +
           _actionResponse = response;
       }
   
       public void store(RenderRequest request, RenderResponse response)
       {
           _renderRequest = request;
  +        _portletRequest = request;
  +
           _renderResponse = response;
       }
   
  @@ -72,4 +79,9 @@
       {
           return _renderRequest != null;
       }
  +
  +    public PortletRequest getPortletRequest()
  +    {
  +        return _portletRequest;
  +    }
   }
  \ No newline at end of file
 
 
 
  1.4       +53 -6     jakarta-tapestry/portlet/src/java/org/apache/tapestry/portlet/PortletHomeService.java
 
  Index: PortletHomeService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/portlet/src/java/org/apache/tapestry/portlet/PortletHomeService.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- PortletHomeService.java 18 Apr 2005 17:08:38 -0000 1.3
  +++ PortletHomeService.java 10 May 2005 22:50:57 -0000 1.4
  @@ -15,9 +15,17 @@
   package org.apache.tapestry.portlet;
   
   import java.io.IOException;
  +import java.util.HashMap;
  +import java.util.Map;
   
   import org.apache.tapestry.IRequestCycle;
  -import org.apache.tapestry.engine.HomeService;
  +import org.apache.tapestry.Tapestry;
  +import org.apache.tapestry.engine.EngineMessages;
  +import org.apache.tapestry.engine.IEngineService;
  +import org.apache.tapestry.engine.ILink;
  +import org.apache.tapestry.services.LinkFactory;
  +import org.apache.tapestry.services.ResponseRenderer;
  +import org.apache.tapestry.services.ServiceConstants;
   
   /**
    * Replacement for the standard home service, used by Portlets. This exists to handle the special
  @@ -27,24 +35,58 @@
    * @author Howard M. Lewis Ship
    * @since 4.0
    */
  -public class PortletHomeService extends HomeService
  +public class PortletHomeService implements IEngineService
   {
       private PortletRenderer _portletRenderer;
   
       private PortletRequestGlobals _requestGlobals;
   
  +    private ResponseRenderer _responseRenderer;
  +
  +    private LinkFactory _linkFactory;
  +
  +    private PortletPageResolver _pageResolver;
  +
  +    public String getName()
  +    {
  +        return Tapestry.HOME_SERVICE;
  +    }
  +
  +    public ILink getLink(IRequestCycle cycle, Object parameter)
  +    {
  +        if (parameter != null)
  +            throw new IllegalArgumentException(EngineMessages.serviceNoParameter(this));
  +
  +        Map parameters = new HashMap();
  +
  +        parameters.put(ServiceConstants.SERVICE, Tapestry.HOME_SERVICE);
  +
  +        return _linkFactory.constructLink(cycle, parameters, true);
  +    }
  +
  +    public void setLinkFactory(LinkFactory linkFactory)
  +    {
  +        _linkFactory = linkFactory;
  +    }
  +
  +    public void setResponseRenderer(ResponseRenderer responseRenderer)
  +    {
  +        _responseRenderer = responseRenderer;
  +    }
  +
       public void service(IRequestCycle cycle) throws IOException
       {
  +        String pageName = _pageResolver.getPageNameForRequest(cycle);
  +
           if (_requestGlobals.isRenderRequest())
           {
  -            String pageName = getPageName();
  -
               _portletRenderer.renderPage(cycle, pageName);
  -
               return;
           }
   
  -        super.service(cycle);
  +        cycle.activate(pageName);
  +
  +        _responseRenderer.renderResponse(cycle);
       }
   
       public void setPortletRenderer(PortletRenderer portletRenderer)
  @@ -56,4 +98,9 @@
       {
           _requestGlobals = requestGlobals;
       }
  +
  +    public void setPageResolver(PortletPageResolver pageResolver)
  +    {
  +        _pageResolver = pageResolver;
  +    }
   }
  \ No newline at end of file
 
 
 
  1.5       +6 -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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- PortletRequestGlobals.java 18 Apr 2005 17:08:38 -0000 1.4
  +++ PortletRequestGlobals.java 10 May 2005 22:50:57 -0000 1.5
  @@ -16,6 +16,7 @@
   
   import javax.portlet.ActionRequest;
   import javax.portlet.ActionResponse;
  +import javax.portlet.PortletRequest;
   import javax.portlet.RenderRequest;
   import javax.portlet.RenderResponse;
   
  @@ -44,4 +45,9 @@
        * otherwise.
        */
       public boolean isRenderRequest();
  +
  +    /**
  +     * Returns whatever is available; the ActionRequest or the PortletRequest.
  +     */
  +    public PortletRequest getPortletRequest();
   }
  \ No newline at end of file
 
 
 
  1.1                  jakarta-tapestry/portlet/src/java/org/apache/tapestry/portlet/PortletPageResolver.java
 
  Index: PortletPageResolver.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 org.apache.tapestry.IRequestCycle;
 
  /**
   * Used by {@link org.apache.tapestry.portlet.PortletHomeService} to determine the correct page name
   * to use to render a request that does not specify a page (that's what the home service does).
   *
   * @author Howard M. Lewis Ship
   */
  public interface PortletPageResolver
  {
      /**
       * Looks at the current request to determine the correct page name.
       *
       * @returns The page name to activate and render (never null).
       */
 
      public String getPageNameForRequest(IRequestCycle cycle);
  }
 
 
 
  1.1                  jakarta-tapestry/portlet/src/java/org/apache/tapestry/portlet/DefaultPortletPageResolver.java
 
  Index: DefaultPortletPageResolver.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 org.apache.tapestry.IRequestCycle;
 
  /**
   * The final entry on the tapestry.portlet.resolver.PageResolvers chain; this one returns a fixed,
   * default page name (typically, "View").
   *
   * @author Howard M. Lewis Ship
   * @since 4.0
   */
  public class DefaultPortletPageResolver implements PortletPageResolver
  {
      private String _pageName;
 
      public void setPageName(String pageName)
      {
          _pageName = pageName;
      }
 
      public String getPageNameForRequest(IRequestCycle cycle)
      {
          return _pageName;
      }
 
  }
 
 
 
  1.1                  jakarta-tapestry/portlet/src/java/org/apache/tapestry/portlet/MatchingPortletPageResolver.java
 
  Index: MatchingPortletPageResolver.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.ArrayList;
  import java.util.Collections;
  import java.util.Iterator;
  import java.util.List;
 
  import javax.portlet.PortletRequest;
 
  import org.apache.tapestry.IRequestCycle;
  import org.apache.tapestry.PageNotFoundException;
 
  /**
   * Uses the tapestry.portlet.resolver.PageResolverRules configuration point to find a match.
   *
   * @author Howard M. Lewis Ship
   * @since 4.0
   */
  public class MatchingPortletPageResolver implements PortletPageResolver
  {
      private List _contributions;
 
      private List _sortedContributions;
 
      private PortletRequest _request;
 
      public void initializeService()
      {
          _sortedContributions = new ArrayList(_contributions);
          Collections.sort(_sortedContributions);
      }
 
      public String getPageNameForRequest(IRequestCycle cycle)
      {
          Iterator i = _sortedContributions.iterator();
          while (i.hasNext())
          {
              PageResolverContribution c = (PageResolverContribution) i.next();
 
              if (c.match(_request))
              {
                  String pageName = c.getPageName();
 
                  try
                  {
                      cycle.getPage(pageName);
 
                      return pageName;
                  }
                  catch (PageNotFoundException ex)
                  {
                      // Ignore.
                  }
              }
          }
 
          // No match, or no matches where the page actually exists.
 
          return null;
      }
 
      public void setContributions(List contributions)
      {
          _contributions = contributions;
      }
 
      public void setRequest(PortletRequest request)
      {
          _request = request;
      }
 
  }
 
 
 
  1.1                  jakarta-tapestry/portlet/src/java/org/apache/tapestry/portlet/PageResolverContribution.java
 
  Index: PageResolverContribution.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.PortletRequest;
 
  import org.apache.hivemind.impl.BaseLocatable;
  import org.apache.hivemind.util.Defense;
  import org.apache.hivemind.util.ToStringBuilder;
 
  /**
   * Contribution used for resolving requests to named pages.
   *
   * @author Howard M. Lewis Ship
   * @since 4.0
   */
  public class PageResolverContribution extends BaseLocatable implements Comparable
  {
      private String _portletMode;
 
      private String _windowState;
 
      private String _mimeType;
 
      private String _pageName;
 
      public void setMimeType(String mimeType)
      {
          _mimeType = mimeType;
      }
 
      public void setPageName(String pageName)
      {
          _pageName = pageName;
      }
 
      public String getPageName()
      {
          return _pageName;
      }
 
      public void setPortletMode(String portletMode)
      {
          _portletMode = portletMode;
      }
 
      public void setWindowState(String windowState)
      {
          _windowState = windowState;
      }
 
      int sortScore()
      {
          int result = 0;
 
          if (_mimeType != null)
              result += 4;
 
          if (_portletMode != null)
              result += 2;
 
          if (_windowState != null)
              result += 1;
 
          return result;
      }
 
      public String toString()
      {
          ToStringBuilder builder = new ToStringBuilder(this);
 
          builder.append("mimeType", _mimeType);
          builder.append("portletMode", _portletMode);
          builder.append("windowState", _windowState);
          builder.append("pageName", _pageName);
 
          return builder.toString();
      }
 
      public int compareTo(Object o)
      {
          int thisScore = sortScore();
          int otherScore = ((PageResolverContribution) o).sortScore();
 
          // End result: sorted descending by specificity
 
          return otherScore - thisScore;
      }
 
      public boolean match(PortletRequest request)
      {
          Defense.notNull(request, "request");
 
          if (_mimeType != null && !_mimeType.equals(request.getResponseContentType()))
              return false;
 
          if (_portletMode != null && !_portletMode.equals(request.getPortletMode().toString()))
              return false;
 
          if (_windowState != null && !_windowState.equals(request.getWindowState().toString()))
              return false;
 
          return true;
      }
  }
 
 
 
  1.6       +3 -3      jakarta-tapestry/framework/src/java/org/apache/tapestry/engine/EngineMessages.java
 
  Index: EngineMessages.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/engine/EngineMessages.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- EngineMessages.java 9 May 2005 20:43:02 -0000 1.5
  +++ EngineMessages.java 10 May 2005 22:50:57 -0000 1.6
  @@ -24,12 +24,12 @@
    * @author Howard M. Lewis Ship
    * @since 4.0
    */
  -class EngineMessages
  +public class EngineMessages
   {
       private static final MessageFormatter _formatter = new MessageFormatter(EngineMessages.class,
               "EngineStrings");
   
  -    static String serviceNoParameter(IEngineService service)
  +    public static String serviceNoParameter(IEngineService service)
       {
           return _formatter.format("service-no-parameter", service.getName());
       }
  @@ -67,7 +67,7 @@
   
               buffer.append(pageNames.get(i));
           }
  -        
  +
           return _formatter.format("validate-cycle", buffer);
       }
   }
  \ No newline at end of file
 
 
 
  1.4       +59 -2     jakarta-tapestry/portlet/src/test/org/apache/tapestry/portlet/TestPortletHomeService.java
 
  Index: TestPortletHomeService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/portlet/src/test/org/apache/tapestry/portlet/TestPortletHomeService.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TestPortletHomeService.java 18 Apr 2005 17:08:37 -0000 1.3
  +++ TestPortletHomeService.java 10 May 2005 22:50:57 -0000 1.4
  @@ -14,9 +14,16 @@
   
   package org.apache.tapestry.portlet;
   
  +import java.util.HashMap;
  +import java.util.Map;
  +
   import org.apache.hivemind.test.HiveMindTestCase;
   import org.apache.tapestry.IRequestCycle;
  +import org.apache.tapestry.Tapestry;
  +import org.apache.tapestry.engine.ILink;
  +import org.apache.tapestry.services.LinkFactory;
   import org.apache.tapestry.services.ResponseRenderer;
  +import org.apache.tapestry.services.ServiceConstants;
   import org.easymock.MockControl;
   
   /**
  @@ -53,18 +60,30 @@
           return (PortletRenderer) newMock(PortletRenderer.class);
       }
   
  +    private PortletPageResolver newResolver(IRequestCycle cycle, String pageName)
  +    {
  +        MockControl control = newControl(PortletPageResolver.class);
  +        PortletPageResolver resolver = (PortletPageResolver) control.getMock();
  +
  +        resolver.getPageNameForRequest(cycle);
  +        control.setReturnValue(pageName);
  +
  +        return resolver;
  +    }
  +
       public void testIsRenderRequest() throws Exception
       {
           IRequestCycle cycle = newCycle();
           PortletRequestGlobals globals = newRequestGlobals(true);
           PortletRenderer renderer = newPortletRenderer();
  +        PortletPageResolver resolver = newResolver(cycle, "ZePage");
   
           renderer.renderPage(cycle, "ZePage");
   
           replayControls();
   
           PortletHomeService phs = new PortletHomeService();
  -        phs.setPageName("ZePage");
  +        phs.setPageResolver(resolver);
           phs.setPortletRenderer(renderer);
           phs.setRequestGlobals(globals);
   
  @@ -78,6 +97,7 @@
           IRequestCycle cycle = newCycle();
           PortletRequestGlobals globals = newRequestGlobals(false);
           ResponseRenderer renderer = newResponseRenderer();
  +        PortletPageResolver resolver = newResolver(cycle, "ZePage");
   
           cycle.activate("ZePage");
           renderer.renderResponse(cycle);
  @@ -87,10 +107,47 @@
           PortletHomeService phs = new PortletHomeService();
           phs.setResponseRenderer(renderer);
           phs.setRequestGlobals(globals);
  -        phs.setPageName("ZePage");
  +        phs.setPageResolver(resolver);
   
           phs.service(cycle);
   
           verifyControls();
       }
  +
  +    public void testGetLink()
  +    {
  +        Map parameters = new HashMap();
  +        parameters.put(ServiceConstants.SERVICE, Tapestry.HOME_SERVICE);
  +
  +        MockControl factoryc = newControl(LinkFactory.class);
  +        LinkFactory factory = (LinkFactory) factoryc.getMock();
  +
  +        ILink link = (ILink) newMock(ILink.class);
  +        IRequestCycle cycle = newCycle();
  +
  +        factory.constructLink(cycle, parameters, true);
  +        factoryc.setReturnValue(link);
  +
  +        replayControls();
  +
  +        PortletHomeService phs = new PortletHomeService();
  +        phs.setLinkFactory(factory);
  +
  +        assertSame(link, phs.getLink(cycle, null));
  +
  +        verifyControls();
  +    }
  +
  +    public void testGetLinkWithParameter()
  +    {
  +        try
  +        {
  +            new PortletHomeService().getLink(null, "PARAMETER");
  +            unreachable();
  +        }
  +        catch (IllegalArgumentException ex)
  +        {
  +            assertEquals("The home service does not require a parameter object.", ex.getMessage());
  +        }
  +    }
   }
  \ No newline at end of file
 
 
 
  1.1                  jakarta-tapestry/portlet/src/test/org/apache/tapestry/portlet/TestMatchingPortletPageResolver.java
 
  Index: TestMatchingPortletPageResolver.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.ArrayList;
  import java.util.Collections;
  import java.util.List;
 
  import javax.portlet.PortletMode;
  import javax.portlet.PortletRequest;
  import javax.portlet.WindowState;
 
  import org.apache.hivemind.test.HiveMindTestCase;
  import org.apache.tapestry.IPage;
  import org.apache.tapestry.IRequestCycle;
  import org.apache.tapestry.PageNotFoundException;
  import org.easymock.MockControl;
 
  /**
   * Tests for {@link org.apache.tapestry.portlet.MatchingPortletPageResolver}.
   *
   * @author Howard M. Lewis Ship
   * @since 4.0
   */
  public class TestMatchingPortletPageResolver extends HiveMindTestCase
  {
      private IRequestCycle newCycle()
      {
          return (IRequestCycle) newMock(IRequestCycle.class);
      }
 
      private IPage newPage()
      {
          return (IPage) newMock(IPage.class);
      }
 
      private IRequestCycle newCycle(String pageName)
      {
          IPage page = newPage();
 
          MockControl control = newControl(IRequestCycle.class);
          IRequestCycle cycle = (IRequestCycle) control.getMock();
 
          cycle.getPage(pageName);
          control.setReturnValue(page);
 
          return cycle;
      }
 
      private PageResolverContribution newContribution(String mimeType, String portletMode,
              String windowState, String pageName)
      {
          PageResolverContribution result = new PageResolverContribution();
          result.setMimeType(mimeType);
          result.setPortletMode(portletMode);
          result.setWindowState(windowState);
          result.setPageName(pageName);
 
          return result;
      }
 
      public void testNoMatchOnContentType()
      {
          IRequestCycle cycle = newCycle();
 
          MockControl requestc = newControl(PortletRequest.class);
          PortletRequest request = (PortletRequest) requestc.getMock();
 
          trainContentType(requestc, request, "text/xml");
 
          List l = Collections.singletonList(newContribution("text/html", null, "wierd", "Wierd"));
 
          replayControls();
 
          MatchingPortletPageResolver resolver = new MatchingPortletPageResolver();
          resolver.setContributions(l);
          resolver.initializeService();
          resolver.setRequest(request);
 
          assertNull(resolver.getPageNameForRequest(cycle));
 
          verifyControls();
      }
 
      public void testNoMatchOnPortletMode()
      {
          IRequestCycle cycle = newCycle();
 
          MockControl requestc = newControl(PortletRequest.class);
          PortletRequest request = (PortletRequest) requestc.getMock();
 
          trainPortletMode(requestc, request, "edit");
 
          List l = Collections.singletonList(newContribution(null, "view", null, "Wierd"));
 
          replayControls();
 
          MatchingPortletPageResolver resolver = new MatchingPortletPageResolver();
          resolver.setContributions(l);
          resolver.initializeService();
          resolver.setRequest(request);
 
          assertNull(resolver.getPageNameForRequest(cycle));
 
          verifyControls();
      }
 
      public void testNoMatchOnWindowState()
      {
          IRequestCycle cycle = newCycle();
 
          MockControl requestc = newControl(PortletRequest.class);
          PortletRequest request = (PortletRequest) requestc.getMock();
 
          trainWindowState(requestc, request, "huge");
 
          List l = Collections.singletonList(newContribution(null, null, "tiny", "Wierd"));
 
          replayControls();
 
          MatchingPortletPageResolver resolver = new MatchingPortletPageResolver();
          resolver.setContributions(l);
          resolver.initializeService();
          resolver.setRequest(request);
 
          assertNull(resolver.getPageNameForRequest(cycle));
 
          verifyControls();
      }
 
      public void testSortingCounts()
      {
          IRequestCycle cycle = newCycle("EditHuge");
 
          MockControl requestc = newControl(PortletRequest.class);
          PortletRequest request = (PortletRequest) requestc.getMock();
 
          List l = new ArrayList();
          l.add(newContribution(null, "edit", null, "EditNormal"));
          l.add(newContribution(null, "edit", "huge", "EditHuge"));
 
          trainPortletMode(requestc, request, "edit");
          trainWindowState(requestc, request, "huge");
 
          replayControls();
 
          MatchingPortletPageResolver resolver = new MatchingPortletPageResolver();
          resolver.setContributions(l);
          resolver.initializeService();
          resolver.setRequest(request);
 
          assertEquals("EditHuge", resolver.getPageNameForRequest(cycle));
 
          verifyControls();
      }
 
      public void testPageMissing()
      {
          IPage page = newPage();
 
          MockControl cyclec = newControl(IRequestCycle.class);
          IRequestCycle cycle = (IRequestCycle) cyclec.getMock();
 
          MockControl requestc = newControl(PortletRequest.class);
          PortletRequest request = (PortletRequest) requestc.getMock();
 
          List l = new ArrayList();
          l.add(newContribution(null, "edit", null, "EditNormal"));
          l.add(newContribution(null, "edit", "huge", "EditHuge"));
 
          trainPortletMode(requestc, request, "edit");
          trainWindowState(requestc, request, "huge");
 
          cycle.getPage("EditHuge");
          cyclec.setThrowable(new PageNotFoundException("missing!"));
 
          trainPortletMode(requestc, request, "edit");
 
          cycle.getPage("EditNormal");
          cyclec.setReturnValue(page);
 
          replayControls();
 
          MatchingPortletPageResolver resolver = new MatchingPortletPageResolver();
          resolver.setContributions(l);
          resolver.initializeService();
          resolver.setRequest(request);
 
          assertEquals("EditNormal", resolver.getPageNameForRequest(cycle));
 
          verifyControls();
      }
 
      private void trainContentType(MockControl control, PortletRequest request, String contentType)
      {
          request.getResponseContentType();
          control.setReturnValue(contentType);
      }
 
      private void trainPortletMode(MockControl control, PortletRequest request, String modeName)
      {
          PortletMode mode = new PortletMode(modeName);
 
          request.getPortletMode();
          control.setReturnValue(mode);
      }
 
      private void trainWindowState(MockControl control, PortletRequest request, String stateName)
      {
          WindowState state = new WindowState(stateName);
 
          request.getWindowState();
          control.setReturnValue(state);
      }
  }
 
 
  1.6       +5 -1      jakarta-tapestry/framework/src/java/org/apache/tapestry/valid/RenderString.java
 
  Index: RenderString.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/valid/RenderString.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- RenderString.java 3 May 2005 11:34:28 -0000 1.5
  +++ RenderString.java 10 May 2005 22:50:57 -0000 1.6
  @@ -14,6 +14,8 @@
   
   package org.apache.tapestry.valid;
   
  +import java.io.Serializable;
  +
   import org.apache.tapestry.IMarkupWriter;
   import org.apache.tapestry.IRender;
   import org.apache.tapestry.IRequestCycle;
  @@ -25,8 +27,10 @@
    * @author Howard Lewis Ship
    */
   
  -public class RenderString implements IRender
  +public class RenderString implements IRender, Serializable
   {
  +    private static final long serialVersionUID = 6215074338439140780L;
  +
       private String _string;
   
       private boolean _raw = false;
 
 
 
  1.4       +52 -67    jakarta-tapestry/framework/src/java/org/apache/tapestry/valid/ValidationConstraint.java
 
  Index: ValidationConstraint.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/valid/ValidationConstraint.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ValidationConstraint.java 6 Jan 2005 02:17:23 -0000 1.3
  +++ ValidationConstraint.java 10 May 2005 22:50:57 -0000 1.4
  @@ -17,113 +17,98 @@
   import org.apache.commons.lang.enum.Enum;
   
   /**
  - *  Defines an enumeration of different types of validation constraints
  - *  that may be violated.
  - *
  - *  @author Howard Lewis Ship
  + * Defines an enumeration of different types of validation constraints that may be violated.
    *
  - **/
  + * @author Howard Lewis Ship
  + */
   
   public class ValidationConstraint extends Enum
   {
  +    private static final long serialVersionUID = 371593028205311930L;
  +
       /**
  -     *  Indicates that no value (or a value consisting only of white space) was
  -     *  provided for a field that requires a non-null value.
  -     *
  -     **/
  +     * Indicates that no value (or a value consisting only of white space) was provided for a field
  +     * that requires a non-null value.
  +     */
   
       public static final ValidationConstraint REQUIRED = new ValidationConstraint("REQUIRED");
   
       /**
  -     *  Indicates that a non-null value was provided, but that (after removing
  -     *  leading and trailing whitespace), the value was not long enough.
  -     *
  -     **/
  -
  -    public static final ValidationConstraint MINIMUM_WIDTH =
  -        new ValidationConstraint("MINUMUM_WIDTH");
  +     * Indicates that a non-null value was provided, but that (after removing leading and trailing
  +     * whitespace), the value was not long enough.
  +     */
  +
  +    public static final ValidationConstraint MINIMUM_WIDTH = new ValidationConstraint(
  +            "MINUMUM_WIDTH");
   
       /**
  -     *  Indicates a general error in converting a String into a Date.
  -     *
  -     **/
  +     * Indicates a general error in converting a String into a Date.
  +     */
   
       public static final ValidationConstraint DATE_FORMAT = new ValidationConstraint("DATE_FORMAT");
   
       /**
  -     *  Indicates a general error in the format of a string that is
  -     *  to be interpreted as a email.
  -     *
  -     **/
  +     * Indicates a general error in the format of a string that is to be interpreted as a email.
  +     */
   
  -    public static final ValidationConstraint EMAIL_FORMAT =
  -        new ValidationConstraint("EMAIL_FORMAT");
  +    public static final ValidationConstraint EMAIL_FORMAT = new ValidationConstraint("EMAIL_FORMAT");
   
       /**
  -     *  Indicates a general error in the format of a string that is
  -     *  to be interpreted as a number.
  -     *
  -     **/
  +     * Indicates a general error in the format of a string that is to be interpreted as a number.
  +     */
   
  -    public static final ValidationConstraint NUMBER_FORMAT =
  -        new ValidationConstraint("NUMBER_FORMAT");
  +    public static final ValidationConstraint NUMBER_FORMAT = new ValidationConstraint(
  +            "NUMBER_FORMAT");
   
       /**
  -     *  Indicates that the value was too small (for a Date, too early).
  -     *
  -     **/
  +     * Indicates that the value was too small (for a Date, too early).
  +     */
   
       public static final ValidationConstraint TOO_SMALL = new ValidationConstraint("TOO_SMALL");
   
       /**
  -     *  Indicates that the value was too large (for a Date, too late).
  -     *
  -     **/
  +     * Indicates that the value was too large (for a Date, too late).
  +     */
   
       public static final ValidationConstraint TOO_LARGE = new ValidationConstraint("TOO_LARGE");
   
       /**
  -     *  Indicates an error in a string that does not fulfill a pattern.
  -     *
  -     *  @since 3.0
  +     * Indicates an error in a string that does not fulfill a pattern.
        *
  -     **/
  +     * @since 3.0
  +     */
   
  -    public static final ValidationConstraint PATTERN_MISMATCH =
  -        new ValidationConstraint("PATTERN_MISMATCH");
  +    public static final ValidationConstraint PATTERN_MISMATCH = new ValidationConstraint(
  +            "PATTERN_MISMATCH");
   
       /**
  -     *  Indicates a consistency error, usually between too different fields.
  +     * Indicates a consistency error, usually between too different fields.
        *
  -     *  @since 3.0
  -     *
  -     **/
  +     * @since 3.0
  +     */
   
       public static final ValidationConstraint CONSISTENCY = new ValidationConstraint("CONSISTENCY");
   
  - /**
  - *  Indicates that a URL is not of the correct format
  - *
  - * @since 3.0
  - */
  -
  - public static final ValidationConstraint URL_FORMAT = new ValidationConstraint("URL_FORMAT");
  -
  - /**
  - *  Indicates that the URL does not use one of the specified protocols
  - *
  - * @since 3.0
  - */
  -
  - public static final ValidationConstraint DISALLOWED_PROTOCOL = new ValidationConstraint("DISALLOWED_PROTOCOL");
  +    /**
  +     * Indicates that a URL is not of the correct format
  +     *
  +     * @since 3.0
  +     */
  +
  +    public static final ValidationConstraint URL_FORMAT = new ValidationConstraint("URL_FORMAT");
   
  +    /**
  +     * Indicates that the URL does not use one of the specified protocols
  +     *
  +     * @since 3.0
  +     */
   
  +    public static final ValidationConstraint DISALLOWED_PROTOCOL = new ValidationConstraint(
  +            "DISALLOWED_PROTOCOL");
   
  - /**
  - *  Protected constructor, which allows new constraints to be created
  - *  as subclasses.
  - *
  - **/
  +    /**
  +     * Protected constructor, which allows new constraints to be created as subclasses.
  +     */
   
       protected ValidationConstraint(String name)
       {
 
 
 
  1.5       +5 -1      jakarta-tapestry/framework/src/java/org/apache/tapestry/valid/FieldTracking.java
 
  Index: FieldTracking.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/valid/FieldTracking.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- FieldTracking.java 30 Apr 2005 15:06:47 -0000 1.4
  +++ FieldTracking.java 10 May 2005 22:50:57 -0000 1.5
  @@ -14,6 +14,8 @@
   
   package org.apache.tapestry.valid;
   
  +import java.io.Serializable;
  +
   import org.apache.hivemind.util.Defense;
   import org.apache.tapestry.IRender;
   import org.apache.tapestry.form.IFormComponent;
  @@ -25,8 +27,10 @@
    * @since 1.0.8
    */
   
  -public class FieldTracking implements IFieldTracking
  +public class FieldTracking implements IFieldTracking, Serializable
   {
  +    private static final long serialVersionUID = -5397563163968532716L;
  +
       private transient IFormComponent _component;
   
       private String _input;
 
 
 
  1.6       +2 -5      jakarta-tapestry/framework/src/java/org/apache/tapestry/valid/ValidationDelegate.java
 
  Index: ValidationDelegate.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/valid/ValidationDelegate.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ValidationDelegate.java 3 May 2005 17:41:27 -0000 1.5
  +++ ValidationDelegate.java 10 May 2005 22:50:57 -0000 1.6
  @@ -21,14 +21,9 @@
   import java.util.List;
   import java.util.Map;
   
  -import org.apache.hivemind.ApplicationRuntimeException;
  -import org.apache.hivemind.Location;
  -import org.apache.hivemind.util.Defense;
  -import org.apache.tapestry.IComponent;
   import org.apache.tapestry.IMarkupWriter;
   import org.apache.tapestry.IRender;
   import org.apache.tapestry.IRequestCycle;
  -import org.apache.tapestry.NestedMarkupWriter;
   import org.apache.tapestry.Tapestry;
   import org.apache.tapestry.form.IFormComponent;
   
  @@ -42,6 +37,8 @@
   
   public class ValidationDelegate implements IValidationDelegate
   {
  +    private static final long serialVersionUID = 6215074338439140780L;
  +
       private transient IFormComponent _currentComponent;
   
       /**
 
 
 
  1.11      +1 -1      jakarta-tapestry/portlet/src/descriptor/META-INF/tapestry.portlet.services.xml
 
  Index: tapestry.portlet.services.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/portlet/src/descriptor/META-INF/tapestry.portlet.services.xml,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- tapestry.portlet.services.xml 4 May 2005 23:03:42 -0000 1.10
  +++ tapestry.portlet.services.xml 10 May 2005 22:50:57 -0000 1.11
  @@ -106,7 +106,7 @@
           <set-object property="linkFactory" value="infrastructure:linkFactory"/>
           <set-service property="requestGlobals" service-id="tapestry.portlet.PortletRequestGlobals"/>
           <set-service property="portletRenderer" service-id="PortletRenderer"/>
  -        <set-object property="pageName" value="app-property:org.apache.tapestry.portlet.home-page"/>
  +        <set-service property="pageResolver" service-id="tapestry.portlet.resolver.PortletPageResolver"/>
         </construct>
       </invoke-factory>
     </service-point>
 
 
 
  1.15      +12 -0     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.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- hivemodule.xml 9 May 2005 23:28:15 -0000 1.14
  +++ hivemodule.xml 10 May 2005 22:50:57 -0000 1.15
  @@ -23,6 +23,7 @@
     <dependency module-id="hivemind.lib" version="1.1.0"/>
     
     <sub-module descriptor="tapestry.portlet.services.xml"/>
  +  <sub-module descriptor="tapestry.portlet.resolver.xml"/>
     
     <configuration-point id="PortletApplicationInitializers" schema-id="hivemind.lib.ChainContribution">
       
  @@ -160,6 +161,17 @@
       
     </service-point>
     
  +  <service-point id="PortletRequest" interface="javax.portlet.PortletRequest">
  +    
  +    The PortletRequest for the current request. This may be either an ActionRequest
  +    or a RenderRequest.
  +    
  +    <invoke-factory service-id="hivemind.lib.ServicePropertyFactory" model="primitive">
  +      <construct service-id="PortletRequestGlobals" property="portletRequest"/>
  +    </invoke-factory>
  +    
  +  </service-point>  
  +  
     <service-point id="RenderResponse" interface="javax.portlet.RenderResponse">
       
       The RenderResponse for the current request.
 
 
 
  1.1                  jakarta-tapestry/portlet/src/descriptor/META-INF/tapestry.portlet.resolver.xml
 
  Index: tapestry.portlet.resolver.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.resolver" version="4.0.0" package="org.apache.tapestry.portlet">
 
    Controls the resolution, based on portlet mode and window state, to a page.
    This is all used by the Portlet's home engine service.
 
    <service-point id="PortletPageResolver">
     
      A chain of command for determing the correct page.
     
      <invoke-factory service-id="hivemind.lib.ChainFactory" model="primitive">
        <construct configuration-id="PageResolvers"/>
      </invoke-factory>
     
    </service-point>
 
    <configuration-point id="PageResolvers" schema-id="hivemind.lib.ChainContribution">
     
      Defines the series of command steps to try and resolve the page name for
      the request.
     
    </configuration-point>
   
    <contribution configuration-id="PageResolvers">
      <command id="matcher" object="service:MatchingPortletPageResolver"/>
      <command id="default" after="*" object="service:DefaultPortletPageResolver"/>
    </contribution>
   
    <service-point id="MatchingPortletPageResolver" interface="PortletPageResolver">
     
      Uses the PageResolverRules configuration point to find a match
      against the current request's mime type, portlet mode and/or
      window state. Best match that corresponds to an actual page wins.
     
      <invoke-factory model="primitive">
        <construct class="MatchingPortletPageResolver">
          <set-object property="request" value="service:tapestry.portlet.PortletRequest"/>
          <set-object property="contributions" value="configuration:PageResolverRules"/>
        </construct>
      </invoke-factory>
     
    </service-point>
   
    <service-point id="DefaultPortletPageResolver" interface="PortletPageResolver">
     
      <invoke-factory model="primitive">
        <construct class="DefaultPortletPageResolver">
          <set-object property="pageName" value="app-property:org.apache.tapestry.portlet.home-page"/>
        </construct>
      </invoke-factory>
    </service-point>
   
    <configuration-point id="PageResolverRules">
     
      Identifies rules for matching an incoming request to a
      named page.
      <schema>
        <element name="match">
          <attribute name="portlet-mode">
           
            The name of a portlet mode to match against.
           
          </attribute>
         
          <attribute name="window-state">
           
            The name of a window state to match against.
           
          </attribute>
         
          <attribute name="mime-type">
           
            The mime type to match against.
           
          </attribute>
         
          <attribute name="page" required="true">
           
            The name of the page to use. If such a page exists (it may not), it will
            be activated to render the response.
           
          </attribute>
         
          <conversion class="PageResolverContribution">
            <map property="pageName" attribute="page"/>
          </conversion>
         
        </element>
      </schema>
     
    </configuration-point>
   
    <contribution configuration-id="PageResolverRules">
      <match portlet-mode="edit" page="Edit"/>
      <match portlet-mode="help" page="Help"/>
    </contribution>
   
  </module>
 
 
  1.3       +12 -1     jakarta-tapestry/framework/src/java/org/apache/tapestry/listener/ListenerMethodInvokerImpl.java
 
  Index: ListenerMethodInvokerImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/listener/ListenerMethodInvokerImpl.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ListenerMethodInvokerImpl.java 18 Apr 2005 17:06:36 -0000 1.2
  +++ ListenerMethodInvokerImpl.java 10 May 2005 22:50:57 -0000 1.3
  @@ -148,7 +148,7 @@
   
           try
           {
  -            listenerMethod.invoke(target, parameters);
  +            invokeTargetMethod(target, listenerMethod, parameters);
           }
           catch (InvocationTargetException ex)
           {
  @@ -171,4 +171,15 @@
   
           }
       }
  +
  +    /**
  +     * Provided as a hook so that subclasses can perform any additional work before or after
  +     * invoking the listener method.
  +     */
  +
  +    protected void invokeTargetMethod(Object target, Method listenerMethod, Object[] parameters)
  +            throws IllegalAccessException, InvocationTargetException
  +    {
  +        listenerMethod.invoke(target, parameters);
  +    }
   }
  \ No newline at end of file
 
 
 
  1.3       +12 -1     jakarta-tapestry/framework/src/java/org/apache/tapestry/listener/ListenerMapSourceImpl.java
 
  Index: ListenerMapSourceImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/listener/ListenerMapSourceImpl.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ListenerMapSourceImpl.java 18 Apr 2005 17:06:36 -0000 1.2
  +++ ListenerMapSourceImpl.java 10 May 2005 22:50:57 -0000 1.3
  @@ -132,7 +132,7 @@
   
               Method[] methods = convertMethodListToArray(methodList);
   
  -            ListenerMethodInvoker invoker = new ListenerMethodInvokerImpl(name, methods);
  +            ListenerMethodInvoker invoker = createListenerMethodInvoker(name, methods);
   
               result.put(name, invoker);
           }
  @@ -140,6 +140,17 @@
           return result;
       }
   
  +    /**
  +     * This implementation returns a new
  +     * {@link org.apache.tapestry.listener.ListenerMethodInvokerImpl}. Subclasses can override to
  +     * provide their own implementation.
  +     */
  +
  +    protected ListenerMethodInvokerImpl createListenerMethodInvoker(String name, Method[] methods)
  +    {
  +        return new ListenerMethodInvokerImpl(name, methods);
  +    }
  +
       private Method[] convertMethodListToArray(List methodList)
       {
           int size = methodList.size();
 
 
 

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]