tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject cvs commit: jakarta-tapestry/framework/src/java/org/apache/tapestry/asset AssetService.java
Date Fri, 03 Dec 2004 16:56:08 GMT
hlship      2004/12/03 08:56:08

  Modified:    framework/src/java/org/apache/tapestry/engine
                        HomeService.java PageService.java
                        RestartService.java ExternalService.java
                        ActionService.java DirectService.java
                        ResetService.java
               framework/src/java/org/apache/tapestry/services/impl
                        InfrastructureImpl.java
               examples/Workbench/src/java/org/apache/tapestry/workbench/chart
                        ChartService.java
               framework/src/descriptor/META-INF tapestry.services.xml
                        hivemodule.xml
               framework/src/java/org/apache/tapestry/services
                        Infrastructure.java
               examples/Workbench/src/context/WEB-INF hivemodule.xml
               framework/src/java/org/apache/tapestry/asset
                        AssetService.java
  Added:       framework/src/java/org/apache/tapestry/engine
                        ServiceUtils.java
               framework/src/java/org/apache/tapestry/services/impl
                        LinkFactoryImpl.java
               framework/src/descriptor/META-INF tapestry.url.xml
               framework/src/java/org/apache/tapestry/services
                        LinkFactory.java
  Removed:     framework/src/java/org/apache/tapestry/engine
                        AbstractService.java
  Log:
  Split URL generation into a new service: tapestry.url.LinkFactory.
  Remove AbstractService; its behaviors are now supplied by LinkFactory and by the static
methods on ServiceUtils.
  
  Revision  Changes    Path
  1.5       +13 -2     jakarta-tapestry/framework/src/java/org/apache/tapestry/engine/HomeService.java
  
  Index: HomeService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/engine/HomeService.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- HomeService.java	3 Dec 2004 15:18:37 -0000	1.4
  +++ HomeService.java	3 Dec 2004 16:56:07 -0000	1.5
  @@ -22,6 +22,7 @@
   import org.apache.tapestry.IRequestCycle;
   import org.apache.tapestry.Tapestry;
   import org.apache.tapestry.request.ResponseOutputStream;
  +import org.apache.tapestry.services.LinkFactory;
   import org.apache.tapestry.services.ResponseRenderer;
   
   /**
  @@ -33,17 +34,21 @@
    * @since 1.0.9
    */
   
  -public class HomeService extends AbstractService
  +public class HomeService implements IEngineService
   {
       /** @since 3.1 */
       private ResponseRenderer _responseRenderer;
   
  +    /** @since 3.1 */
  +
  +    private LinkFactory _linkFactory;
  +
       public ILink getLink(IRequestCycle cycle, Object parameter)
       {
           if (parameter != null)
               throw new IllegalArgumentException(EngineMessages.serviceNoParameter(this));
   
  -        return constructLink(cycle, Tapestry.HOME_SERVICE, null, null, true);
  +        return _linkFactory.constructLink(cycle, Tapestry.HOME_SERVICE, null, null, true);
       }
   
       public void service(IRequestCycle cycle, ResponseOutputStream output) throws ServletException,
  @@ -63,5 +68,11 @@
       public void setResponseRenderer(ResponseRenderer responseRenderer)
       {
           _responseRenderer = responseRenderer;
  +    }
  +
  +    /** @since 3.1 */
  +    public void setLinkFactory(LinkFactory linkFactory)
  +    {
  +        _linkFactory = linkFactory;
       }
   }
  
  
  
  1.5       +13 -3     jakarta-tapestry/framework/src/java/org/apache/tapestry/engine/PageService.java
  
  Index: PageService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/engine/PageService.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- PageService.java	3 Dec 2004 15:18:37 -0000	1.4
  +++ PageService.java	3 Dec 2004 16:56:07 -0000	1.5
  @@ -25,6 +25,7 @@
   import org.apache.tapestry.Tapestry;
   import org.apache.tapestry.request.RequestContext;
   import org.apache.tapestry.request.ResponseOutputStream;
  +import org.apache.tapestry.services.LinkFactory;
   import org.apache.tapestry.services.ResponseRenderer;
   
   /**
  @@ -34,11 +35,14 @@
    * @since 1.0.9
    */
   
  -public class PageService extends AbstractService
  +public class PageService implements IEngineService
   {
       /** @since 3.1 */
       private ResponseRenderer _responseRenderer;
   
  +    /** @since 3.1 */
  +    private LinkFactory _linkFactory;
  +
       public ILink getLink(IRequestCycle cycle, Object parameter)
       {
           Defense.isAssignable(parameter, String.class, "parameter");
  @@ -46,7 +50,7 @@
           String[] context = new String[]
           { (String) parameter };
   
  -        return constructLink(cycle, Tapestry.PAGE_SERVICE, context, null, true);
  +        return _linkFactory.constructLink(cycle, Tapestry.PAGE_SERVICE, context, null,
true);
   
       }
   
  @@ -54,7 +58,7 @@
               IOException
       {
           RequestContext context = cycle.getRequestContext();
  -        String[] serviceContext = getServiceContext(context);
  +        String[] serviceContext = ServiceUtils.getServiceContext(context);
   
           if (Tapestry.size(serviceContext) != 1)
               throw new ApplicationRuntimeException(Tapestry.format(
  @@ -86,5 +90,11 @@
       public void setResponseRenderer(ResponseRenderer responseRenderer)
       {
           _responseRenderer = responseRenderer;
  +    }
  +
  +    /** @since 3.1 */
  +    public void setLinkFactory(LinkFactory linkFactory)
  +    {
  +        _linkFactory = linkFactory;
       }
   }
  
  
  
  1.5       +12 -2     jakarta-tapestry/framework/src/java/org/apache/tapestry/engine/RestartService.java
  
  Index: RestartService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/engine/RestartService.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- RestartService.java	3 Dec 2004 15:18:37 -0000	1.4
  +++ RestartService.java	3 Dec 2004 16:56:07 -0000	1.5
  @@ -26,6 +26,7 @@
   import org.apache.tapestry.Tapestry;
   import org.apache.tapestry.request.ResponseOutputStream;
   import org.apache.tapestry.services.AbsoluteURLBuilder;
  +import org.apache.tapestry.services.LinkFactory;
   
   /**
    * Restarts the Tapestry application. This is normally reserved for dealing with catastrophic
  @@ -36,7 +37,7 @@
    * @since 1.0.9
    */
   
  -public class RestartService extends AbstractService
  +public class RestartService implements IEngineService
   {
       /** @since 3.1 */
       private Log _log;
  @@ -50,12 +51,15 @@
       /** @since 3.1 */
       private AbsoluteURLBuilder _builder;
   
  +    /** @since 3.1 */
  +    private LinkFactory _linkFactory;
  +
       public ILink getLink(IRequestCycle cycle, Object parameter)
       {
           if (parameter != null)
               throw new IllegalArgumentException(EngineMessages.serviceNoParameter(this));
   
  -        return constructLink(cycle, Tapestry.RESTART_SERVICE, null, null, true);
  +        return _linkFactory.constructLink(cycle, Tapestry.RESTART_SERVICE, null, null,
true);
       }
   
       public void service(IRequestCycle cycle, ResponseOutputStream output) throws ServletException,
  @@ -114,5 +118,11 @@
       public void setResponse(HttpServletResponse response)
       {
           _response = response;
  +    }
  +
  +    /** @since 3.1 */
  +    public void setLinkFactory(LinkFactory linkFactory)
  +    {
  +        _linkFactory = linkFactory;
       }
   }
  
  
  
  1.6       +15 -10    jakarta-tapestry/framework/src/java/org/apache/tapestry/engine/ExternalService.java
  
  Index: ExternalService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/engine/ExternalService.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ExternalService.java	3 Dec 2004 15:18:37 -0000	1.5
  +++ ExternalService.java	3 Dec 2004 16:56:07 -0000	1.6
  @@ -20,11 +20,11 @@
   
   import org.apache.hivemind.ApplicationRuntimeException;
   import org.apache.hivemind.Defense;
  -import org.apache.tapestry.IComponent;
   import org.apache.tapestry.IExternalPage;
   import org.apache.tapestry.IRequestCycle;
   import org.apache.tapestry.Tapestry;
   import org.apache.tapestry.request.ResponseOutputStream;
  +import org.apache.tapestry.services.LinkFactory;
   import org.apache.tapestry.services.ResponseRenderer;
   
   /**
  @@ -109,12 +109,15 @@
    * @since 2.2
    */
   
  -public class ExternalService extends AbstractService
  +public class ExternalService implements IEngineService
   {
       /** @since 3.1 */
   
       private ResponseRenderer _responseRenderer;
   
  +    /** @since 3.1 */
  +    private LinkFactory _linkFactory;
  +
       public ILink getLink(IRequestCycle cycle, Object parameter)
       {
           Defense.isAssignable(parameter, ExternalServiceParameter.class, "parameter");
  @@ -126,12 +129,8 @@
           String[] context = new String[]
           { pageName };
   
  -        return constructLink(
  -                cycle,
  -                Tapestry.EXTERNAL_SERVICE,
  -                context,
  -                esp.getServiceParameters(),
  -                true);
  +        return _linkFactory.constructLink(cycle, Tapestry.EXTERNAL_SERVICE, context, esp
  +                .getServiceParameters(), true);
       }
   
       public void service(IRequestCycle cycle, ResponseOutputStream output) throws ServletException,
  @@ -139,7 +138,7 @@
       {
           IExternalPage page = null;
   
  -        String[] context = getServiceContext(cycle.getRequestContext());
  +        String[] context = ServiceUtils.getServiceContext(cycle.getRequestContext());
   
           if (context == null || context.length != 1)
               throw new ApplicationRuntimeException(Tapestry.format(
  @@ -159,7 +158,7 @@
                       pageName), ex);
           }
   
  -        Object[] parameters = getParameters(cycle);
  +        Object[] parameters = _linkFactory.extractServiceParameters(cycle);
   
           cycle.setServiceParameters(parameters);
   
  @@ -181,5 +180,11 @@
       public void setResponseRenderer(ResponseRenderer responseRenderer)
       {
           _responseRenderer = responseRenderer;
  +    }
  +
  +    /** @since 3.1 */
  +    public void setLinkFactory(LinkFactory linkFactory)
  +    {
  +        _linkFactory = linkFactory;
       }
   }
  
  
  
  1.5       +18 -3     jakarta-tapestry/framework/src/java/org/apache/tapestry/engine/ActionService.java
  
  Index: ActionService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/engine/ActionService.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ActionService.java	3 Dec 2004 15:18:37 -0000	1.4
  +++ ActionService.java	3 Dec 2004 16:56:07 -0000	1.5
  @@ -28,6 +28,7 @@
   import org.apache.tapestry.StaleSessionException;
   import org.apache.tapestry.Tapestry;
   import org.apache.tapestry.request.ResponseOutputStream;
  +import org.apache.tapestry.services.LinkFactory;
   import org.apache.tapestry.services.ResponseRenderer;
   
   /**
  @@ -39,11 +40,14 @@
    * @since 1.0.9
    */
   
  -public class ActionService extends AbstractService
  +public class ActionService implements IEngineService
   {
       /** @since 3.1 */
       private ResponseRenderer _responseRenderer;
   
  +    /** @since 3.1 */
  +    private LinkFactory _linkFactory;
  +
       /**
        * Encoded into URL if engine was stateful.
        * 
  @@ -91,7 +95,12 @@
   
           serviceContext[i++] = component.getIdPath();
   
  -        return constructLink(cycle, Tapestry.ACTION_SERVICE, serviceContext, null, true);
  +        return _linkFactory.constructLink(
  +                cycle,
  +                Tapestry.ACTION_SERVICE,
  +                serviceContext,
  +                null,
  +                true);
       }
   
       public void service(IRequestCycle cycle, ResponseOutputStream output) throws ServletException,
  @@ -101,7 +110,7 @@
           String componentPageName;
           int count = 0;
   
  -        String[] serviceContext = getServiceContext(cycle.getRequestContext());
  +        String[] serviceContext = ServiceUtils.getServiceContext(cycle.getRequestContext());
   
           if (serviceContext != null)
               count = serviceContext.length;
  @@ -174,5 +183,11 @@
       public void setResponseRenderer(ResponseRenderer responseRenderer)
       {
           _responseRenderer = responseRenderer;
  +    }
  +
  +    /** @since 3.1 */
  +    public void setLinkFactory(LinkFactory linkFactory)
  +    {
  +        _linkFactory = linkFactory;
       }
   }
  
  
  
  1.5       +19 -4     jakarta-tapestry/framework/src/java/org/apache/tapestry/engine/DirectService.java
  
  Index: DirectService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/engine/DirectService.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DirectService.java	3 Dec 2004 15:18:37 -0000	1.4
  +++ DirectService.java	3 Dec 2004 16:56:08 -0000	1.5
  @@ -29,6 +29,7 @@
   import org.apache.tapestry.Tapestry;
   import org.apache.tapestry.request.RequestContext;
   import org.apache.tapestry.request.ResponseOutputStream;
  +import org.apache.tapestry.services.LinkFactory;
   import org.apache.tapestry.services.ResponseRenderer;
   
   /**
  @@ -39,11 +40,14 @@
    * @since 1.0.9
    */
   
  -public class DirectService extends AbstractService
  +public class DirectService implements IEngineService
   {
       /** @since 3.1 */
       private ResponseRenderer _responseRenderer;
   
  +    /** @since 3.1 */
  +    private LinkFactory _linkFactory;
  +
       /**
        * Encoded into URL if engine was stateful.
        * 
  @@ -97,7 +101,12 @@
           context[i++] = componentPage.getPageName();
           context[i++] = component.getIdPath();
   
  -        return constructLink(cycle, Tapestry.DIRECT_SERVICE, context, serviceParameters,
true);
  +        return _linkFactory.constructLink(
  +                cycle,
  +                Tapestry.DIRECT_SERVICE,
  +                context,
  +                serviceParameters,
  +                true);
       }
   
       public void service(IRequestCycle cycle, ResponseOutputStream output) throws ServletException,
  @@ -108,7 +117,7 @@
           String componentPageName;
           IPage componentPage;
           RequestContext requestContext = cycle.getRequestContext();
  -        String[] serviceContext = getServiceContext(requestContext);
  +        String[] serviceContext = ServiceUtils.getServiceContext(requestContext);
   
           if (serviceContext != null)
               count = serviceContext.length;
  @@ -165,7 +174,7 @@
                           direct.getExtendedId()), direct.getPage());
           }
   
  -        Object[] parameters = getParameters(cycle);
  +        Object[] parameters = _linkFactory.extractServiceParameters(cycle);
   
           cycle.setServiceParameters(parameters);
           direct.trigger(cycle);
  @@ -185,5 +194,11 @@
       public void setResponseRenderer(ResponseRenderer responseRenderer)
       {
           _responseRenderer = responseRenderer;
  +    }
  +
  +    /** @since 3.1 */
  +    public void setLinkFactory(LinkFactory linkFactory)
  +    {
  +        _linkFactory = linkFactory;
       }
   }
  
  
  
  1.5       +14 -5     jakarta-tapestry/framework/src/java/org/apache/tapestry/engine/ResetService.java
  
  Index: ResetService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/engine/ResetService.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ResetService.java	3 Dec 2004 15:18:37 -0000	1.4
  +++ ResetService.java	3 Dec 2004 16:56:08 -0000	1.5
  @@ -19,11 +19,11 @@
   import javax.servlet.ServletException;
   
   import org.apache.hivemind.ApplicationRuntimeException;
  -import org.apache.tapestry.IComponent;
   import org.apache.tapestry.IPage;
   import org.apache.tapestry.IRequestCycle;
   import org.apache.tapestry.Tapestry;
   import org.apache.tapestry.request.ResponseOutputStream;
  +import org.apache.tapestry.services.LinkFactory;
   import org.apache.tapestry.services.ResetEventCoordinator;
   import org.apache.tapestry.services.ResponseRenderer;
   
  @@ -35,10 +35,9 @@
    * 
    * @author Howard Lewis Ship
    * @since 1.0.9
  - * @see org.apache.tapestry.IEngine#isResetServiceEnabled()
    */
   
  -public class ResetService extends AbstractService
  +public class ResetService implements IEngineService
   {
       /** @since 3.1 */
   
  @@ -51,6 +50,10 @@
       /** @since 3.1 */
       private boolean _enabled;
   
  +    /** @since 3.1 */
  +
  +    private LinkFactory _linkFactory;
  +
       public ILink getLink(IRequestCycle cycle, Object parameter)
       {
           if (parameter != null)
  @@ -59,7 +62,7 @@
           String[] context = new String[]
           { cycle.getPage().getPageName() };
   
  -        return constructLink(cycle, Tapestry.RESET_SERVICE, context, null, true);
  +        return _linkFactory.constructLink(cycle, Tapestry.RESET_SERVICE, context, null,
true);
       }
   
       public String getName()
  @@ -70,7 +73,7 @@
       public void service(IRequestCycle cycle, ResponseOutputStream output) throws ServletException,
               IOException
       {
  -        String[] context = getServiceContext(cycle.getRequestContext());
  +        String[] context = ServiceUtils.getServiceContext(cycle.getRequestContext());
   
           if (Tapestry.size(context) != 1)
               throw new ApplicationRuntimeException(Tapestry.format(
  @@ -109,5 +112,11 @@
       public void setEnabled(boolean enabled)
       {
           _enabled = enabled;
  +    }
  +
  +    /** @since 3.1 */
  +    public void setLinkFactory(LinkFactory linkFactory)
  +    {
  +        _linkFactory = linkFactory;
       }
   }
  
  
  
  1.1                  jakarta-tapestry/framework/src/java/org/apache/tapestry/engine/ServiceUtils.java
  
  Index: ServiceUtils.java
  ===================================================================
  // Copyright 2004 The Apache Software Foundation
  //
  // Licensed under the Apache License, Version 2.0 (the "License");
  // you may not use this file except in compliance with the License.
  // You may obtain a copy of the License at
  //
  //     http://www.apache.org/licenses/LICENSE-2.0
  //
  // Unless required by applicable law or agreed to in writing, software
  // distributed under the License is distributed on an "AS IS" BASIS,
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  // See the License for the specific language governing permissions and
  // limitations under the License.
  
  package org.apache.tapestry.engine;
  
  import java.io.IOException;
  
  import org.apache.hivemind.ApplicationRuntimeException;
  import org.apache.tapestry.IRequestCycle;
  import org.apache.tapestry.Tapestry;
  import org.apache.tapestry.request.RequestContext;
  import org.apache.tapestry.services.DataSqueezer;
  import org.apache.tapestry.util.StringSplitter;
  
  /**
   * Utilities often needed by {@link org.apache.tapestry.engine.IEngineService} 
   * implementations.
   * 
   * @author Howard M. Lewis Ship
   * @since 3.1
   */
  public class ServiceUtils
  {
      /**
       * Returns the service context as an array of Strings. Returns null if there are no
service
       * context strings.
       */
  
      public static String[] getServiceContext(RequestContext context)
      {
          String service = context.getParameter(Tapestry.SERVICE_QUERY_PARAMETER_NAME);
  
          int slashx = service.indexOf('/');
  
          if (slashx < 0)
              return null;
  
          String serviceContext = service.substring(slashx + 1);
  
          return new StringSplitter('/').splitToArray(serviceContext);
      }
  
  }
  
  
  1.11      +14 -1     jakarta-tapestry/framework/src/java/org/apache/tapestry/services/impl/InfrastructureImpl.java
  
  Index: InfrastructureImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/services/impl/InfrastructureImpl.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- InfrastructureImpl.java	31 Oct 2004 22:57:46 -0000	1.10
  +++ InfrastructureImpl.java	3 Dec 2004 16:56:08 -0000	1.11
  @@ -22,6 +22,7 @@
   import org.apache.tapestry.services.ComponentMessagesSource;
   import org.apache.tapestry.services.DataSqueezer;
   import org.apache.tapestry.services.Infrastructure;
  +import org.apache.tapestry.services.LinkFactory;
   import org.apache.tapestry.services.ObjectPool;
   import org.apache.tapestry.services.RequestExceptionReporter;
   import org.apache.tapestry.services.ResetEventCoordinator;
  @@ -52,7 +53,7 @@
   
       private ObjectPool _objectPool;
   
  -     private IPageSource _pageSource;
  +    private IPageSource _pageSource;
   
       private ClassResolver _classResolver;
   
  @@ -66,6 +67,8 @@
   
       private ResponseRenderer _responseRenderer;
   
  +    private LinkFactory _linkFactory;
  +
       public IScriptSource getScriptSource()
       {
           return _scriptSource;
  @@ -205,5 +208,15 @@
       public void setResponseRenderer(ResponseRenderer responseRenderer)
       {
           _responseRenderer = responseRenderer;
  +    }
  +
  +    public LinkFactory getLinkFactory()
  +    {
  +        return _linkFactory;
  +    }
  +
  +    public void setLinkFactory(LinkFactory linkFactory)
  +    {
  +        _linkFactory = linkFactory;
       }
   }
  
  
  
  1.1                  jakarta-tapestry/framework/src/java/org/apache/tapestry/services/impl/LinkFactoryImpl.java
  
  Index: LinkFactoryImpl.java
  ===================================================================
  // Copyright 2004 The Apache Software Foundation
  //
  // Licensed under the Apache License, Version 2.0 (the "License");
  // you may not use this file except in compliance with the License.
  // You may obtain a copy of the License at
  //
  //     http://www.apache.org/licenses/LICENSE-2.0
  //
  // Unless required by applicable law or agreed to in writing, software
  // distributed under the License is distributed on an "AS IS" BASIS,
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  // See the License for the specific language governing permissions and
  // limitations under the License.
  
  package org.apache.tapestry.services.impl;
  
  import java.io.IOException;
  
  import org.apache.hivemind.ApplicationRuntimeException;
  import org.apache.hivemind.Defense;
  import org.apache.tapestry.IRequestCycle;
  import org.apache.tapestry.Tapestry;
  import org.apache.tapestry.engine.EngineServiceLink;
  import org.apache.tapestry.engine.ILink;
  import org.apache.tapestry.request.RequestContext;
  import org.apache.tapestry.services.DataSqueezer;
  import org.apache.tapestry.services.LinkFactory;
  
  /**
   * @author Howard M. Lewis Ship
   * @since 3.1
   */
  public class LinkFactoryImpl implements LinkFactory
  {
      private DataSqueezer _dataSqueezer;
  
      private final Object[] EMPTY = new Object[0];
  
      public ILink constructLink(IRequestCycle cycle, String serviceName, String[] context,
              Object[] serviceParameters, boolean stateful)
      {
          Defense.notNull(cycle, "cycle");
          Defense.notNull(serviceName, "serviceName");
  
          String[] squeezed = squeeze(serviceParameters);
  
          return new EngineServiceLink(cycle, serviceName, context, squeezed, stateful);
      }
  
      public Object[] extractServiceParameters(IRequestCycle cycle)
      {
          RequestContext context = cycle.getRequestContext();
  
          String[] squeezed = context.getParameters(Tapestry.PARAMETERS_QUERY_PARAMETER_NAME);
  
          if (Tapestry.size(squeezed) == 0)
              return EMPTY;
  
          try
          {
              return _dataSqueezer.unsqueeze(squeezed);
          }
          catch (IOException ex)
          {
              throw new ApplicationRuntimeException(ex);
          }
      }
  
      private String[] squeeze(Object[] input)
      {
          try
          {
              return _dataSqueezer.squeeze(input);
          }
          catch (IOException ex)
          {
              throw new ApplicationRuntimeException(ex);
          }
      }
  
      public void setDataSqueezer(DataSqueezer dataSqueezer)
      {
          _dataSqueezer = dataSqueezer;
      }
  
  }
  
  
  1.4       +14 -5     jakarta-tapestry/examples/Workbench/src/java/org/apache/tapestry/workbench/chart/ChartService.java
  
  Index: ChartService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/examples/Workbench/src/java/org/apache/tapestry/workbench/chart/ChartService.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ChartService.java	3 Dec 2004 15:18:38 -0000	1.3
  +++ ChartService.java	3 Dec 2004 16:56:08 -0000	1.4
  @@ -20,11 +20,11 @@
   
   import org.apache.hivemind.Defense;
   import org.apache.tapestry.IComponent;
  -import org.apache.tapestry.IPage;
   import org.apache.tapestry.IRequestCycle;
  -import org.apache.tapestry.engine.AbstractService;
  +import org.apache.tapestry.engine.IEngineService;
   import org.apache.tapestry.engine.ILink;
   import org.apache.tapestry.request.ResponseOutputStream;
  +import org.apache.tapestry.services.LinkFactory;
   import org.apache.tapestry.services.RequestExceptionReporter;
   import org.apache.tapestry.util.ComponentAddress;
   import org.jCharts.Chart;
  @@ -39,13 +39,16 @@
    * @since 1.0.10
    */
   
  -public class ChartService extends AbstractService
  +public class ChartService implements IEngineService
   {
       public static final String SERVICE_NAME = "chart";
   
       /** @since 3.1 */
       private RequestExceptionReporter _exceptionReporter;
   
  +    /** @since 3.1 */
  +    private LinkFactory _linkFactory;
  +
       public ILink getLink(IRequestCycle cycle, Object parameter)
       {
           Defense.isAssignable(parameter, IComponent.class, "parameter");
  @@ -55,13 +58,13 @@
           Object[] serviceParameters = new Object[]
           { new ComponentAddress(component) };
   
  -        return constructLink(cycle, SERVICE_NAME, null, serviceParameters, true);
  +        return _linkFactory.constructLink(cycle, SERVICE_NAME, null, serviceParameters,
true);
       }
   
       public void service(IRequestCycle cycle, ResponseOutputStream output) throws ServletException,
               IOException
       {
  -        Object[] serviceParameters = getParameters(cycle);
  +        Object[] serviceParameters = _linkFactory.extractServiceParameters(cycle);
   
           ComponentAddress address = (ComponentAddress) serviceParameters[0];
   
  @@ -110,5 +113,11 @@
       public void setExceptionReporter(RequestExceptionReporter exceptionReporter)
       {
           _exceptionReporter = exceptionReporter;
  +    }
  +
  +    /** @since 3.1 */
  +    public void setLinkFactory(LinkFactory linkFactory)
  +    {
  +        _linkFactory = linkFactory;
       }
   }
  
  
  
  1.4       +6 -0      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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- tapestry.services.xml	3 Dec 2004 16:06:59 -0000	1.3
  +++ tapestry.services.xml	3 Dec 2004 16:56:08 -0000	1.4
  @@ -70,6 +70,7 @@
       <invoke-factory model="primitive">
         <construct class="org.apache.tapestry.engine.ExternalService">
           <set-object property="responseRenderer" value="infrastructure:responseRenderer"/>
  +        <set-object property="linkFactory" value="infrastructure:linkFactory"/>
         </construct>
       </invoke-factory>
     </service-point>  
  @@ -79,6 +80,7 @@
         <construct class="org.apache.tapestry.asset.AssetService">
           <set-object property="exceptionReporter" value="infrastructure:requestExceptionReporter"/>
           <set-service property="assetExternalizer" service-id="AssetExternalizer"/>
  +        <set-object property="linkFactory" value="infrastructure:linkFactory"/>
         </construct>
       </invoke-factory>
     </service-point>  
  @@ -97,6 +99,7 @@
       <invoke-factory model="primitive">
         <construct class="org.apache.tapestry.engine.HomeService">
           <set-object property="responseRenderer" value="infrastructure:responseRenderer"/>
  +        <set-object property="linkFactory" value="infrastructure:linkFactory"/>
         </construct>
       </invoke-factory>
     </service-point>
  @@ -105,6 +108,7 @@
       <invoke-factory model="primitive">
         <construct class="org.apache.tapestry.engine.ActionService">
           <set-object property="responseRenderer" value="infrastructure:responseRenderer"/>
  +        <set-object property="linkFactory" value="infrastructure:linkFactory"/>
         </construct>
       </invoke-factory>
     </service-point>
  @@ -121,6 +125,7 @@
       <invoke-factory model="primitive">
         <construct class="org.apache.tapestry.engine.PageService">
           <set-object property="responseRenderer" value="infrastructure:responseRenderer"/>
  +        <set-object property="linkFactory" value="infrastructure:linkFactory"/>
         </construct>
       </invoke-factory>
     </service-point>
  @@ -131,6 +136,7 @@
           <set-object property="responseRenderer" value="infrastructure:responseRenderer"/>
           <set-service property="resetEventCoordinator" service-id="tapestry.ResetEventCoordinator"/>
           <set property="enabled" value="${org.apache.tapestry.enable-reset-service}"/>
  +        <set-object property="linkFactory" value="infrastructure:linkFactory"/>
         </construct>
       </invoke-factory>
     </service-point>
  
  
  
  1.13      +2 -0      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.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- hivemodule.xml	17 Nov 2004 01:34:57 -0000	1.12
  +++ hivemodule.xml	3 Dec 2004 16:56:08 -0000	1.13
  @@ -32,6 +32,7 @@
     <sub-module descriptor="tapestry.services.xml"/>
     <sub-module descriptor="tapestry.ognl.xml"/>
     <sub-module descriptor="tapestry.coerce.xml"/>
  +  <sub-module descriptor="tapestry.url.xml"/>
     
     <service-point id="ClasspathResourceFactory" interface="org.apache.tapestry.services.ClasspathResourceFactory">
     
  @@ -65,6 +66,7 @@
           <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-service property="linkFactory" service-id="tapestry.url.LinkFactory"/>
         </construct>
       </invoke-factory>
       
  
  
  
  1.1                  jakarta-tapestry/framework/src/descriptor/META-INF/tapestry.url.xml
  
  Index: tapestry.url.xml
  ===================================================================
  <?xml version="1.0"?>
  <!-- 
     Copyright 2004 The Apache Software Foundation
  
     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at
  
       http://www.apache.org/licenses/LICENSE-2.0
  
     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
  -->
  
  <module id="tapestry.url" version="3.1.0">
  
    Control over constructing and recognizing URLs for Tapestry engine services.
    
    <service-point id="LinkFactory" interface="org.apache.tapestry.services.LinkFactory">
      
      A source of ILinks for engine services.
      
      <invoke-factory>
        <construct class="org.apache.tapestry.services.impl.LinkFactoryImpl">
          <set-object property="dataSqueezer" value="infrastructure:dataSqueezer"/>
        </construct>
      </invoke-factory>
      
    </service-point>
  
  </module>
  
  
  1.11      +7 -0      jakarta-tapestry/framework/src/java/org/apache/tapestry/services/Infrastructure.java
  
  Index: Infrastructure.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/services/Infrastructure.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- Infrastructure.java	31 Oct 2004 22:57:42 -0000	1.10
  +++ Infrastructure.java	3 Dec 2004 16:56:08 -0000	1.11
  @@ -117,4 +117,11 @@
        */
   
       public ResponseRenderer getResponseRenderer();
  +
  +    /**
  +     * Constructs {@link org.apache.tapestry.engine.ILink}instances for
  +     * {@link org.apache.tapestry.engine.IEngineService}s.
  +     */
  +
  +    public LinkFactory getLinkFactory();
   }
  
  
  
  1.1                  jakarta-tapestry/framework/src/java/org/apache/tapestry/services/LinkFactory.java
  
  Index: LinkFactory.java
  ===================================================================
  // Copyright 2004 The Apache Software Foundation
  //
  // Licensed under the Apache License, Version 2.0 (the "License");
  // you may not use this file except in compliance with the License.
  // You may obtain a copy of the License at
  //
  //     http://www.apache.org/licenses/LICENSE-2.0
  //
  // Unless required by applicable law or agreed to in writing, software
  // distributed under the License is distributed on an "AS IS" BASIS,
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  // See the License for the specific language governing permissions and
  // limitations under the License.
  
  package org.apache.tapestry.services;
  
  import org.apache.tapestry.IRequestCycle;
  import org.apache.tapestry.engine.ILink;
  
  /**
   * A source of {@link org.apache.tapestry.engine.ILink}instances. This is primarily used
by
   * {@link org.apache.tapestry.engine.IEngineService}s.
   * 
   * @author Howard M. Lewis Ship
   * @since 3.1
   */
  public interface LinkFactory
  {
      /**
       * Constructs an {@link org.apache.tapestry.engine.ILink}&nbsp; from the service
name, context
       * and parameters information provided.
       * <p>
       * Note: this API is subject to significant change shortly!
       * </p>
       * 
       * @param cycle
       *            the current request cycle
       * @param serviceName
       *            the name of the service
       * @param context
       *            an array of context information used by the service when decoding the
request. May
       *            be null. Values should be URL safe (generally speaking, Java identifiers)
       * @param parameters
       *            An array of object values encoded with the service, but ultimately meaningful
to
       *            the application <b>Note: the name serviceParameters is entrenched,
but a better
       *            name would be serviceParameters </b>
       * @param stateful
       *            If true, then the final URL should be encoded (with the session id) if
necessary.
       *            If false, the session encoding should not occur. The latter case is useful
for
       *            services that will absolutely not need any access to user-specific state.
       */
      public ILink constructLink(IRequestCycle cycle, String serviceName, String[] context,
              Object[] serviceParameters, boolean stateful);
  
      /**
       * A secondary function of the service is to convert encoded (aka "squeezed") service
parameters
       * back into an array of Objects. This does makes sense .. the link factory is responsible
for
       * encoding the service parameters, it should be responsible for decoding them.
       * 
       * @param cycle
       *            the current request cycle
       * @return an array of Object[]. May return an empty array, but won't return null.
       */
  
      public Object[] extractServiceParameters(IRequestCycle cycle);
  }
  
  
  1.2       +1 -0      jakarta-tapestry/examples/Workbench/src/context/WEB-INF/hivemodule.xml
  
  Index: hivemodule.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/examples/Workbench/src/context/WEB-INF/hivemodule.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- hivemodule.xml	28 Oct 2004 22:24:46 -0000	1.1
  +++ hivemodule.xml	3 Dec 2004 16:56:08 -0000	1.2
  @@ -33,6 +33,7 @@
       <invoke-factory model="primitive">
         <construct class="org.apache.tapestry.workbench.WorkbenchHomeService">
           <set-object property="responseRenderer" value="infrastructure:responseRenderer"/>
  +        <set-object property="linkFactory" value="infrastructure:linkFactory"/>
         </construct>
       </invoke-factory>
     </service-point>  
  
  
  
  1.6       +16 -5     jakarta-tapestry/framework/src/java/org/apache/tapestry/asset/AssetService.java
  
  Index: AssetService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/asset/AssetService.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- AssetService.java	3 Dec 2004 16:06:59 -0000	1.5
  +++ AssetService.java	3 Dec 2004 16:56:08 -0000	1.6
  @@ -28,10 +28,12 @@
   import org.apache.hivemind.Defense;
   import org.apache.tapestry.IRequestCycle;
   import org.apache.tapestry.Tapestry;
  -import org.apache.tapestry.engine.AbstractService;
  +import org.apache.tapestry.engine.IEngineService;
   import org.apache.tapestry.engine.ILink;
  +import org.apache.tapestry.engine.ServiceUtils;
   import org.apache.tapestry.link.StaticLink;
   import org.apache.tapestry.request.ResponseOutputStream;
  +import org.apache.tapestry.services.LinkFactory;
   import org.apache.tapestry.services.RequestExceptionReporter;
   
   /**
  @@ -49,11 +51,14 @@
    * @author Howard Lewis Ship
    */
   
  -public class AssetService extends AbstractService
  +public class AssetService implements IEngineService
   {
       /** @since 3.1 */
       private AssetExternalizer _assetExternalizer;
   
  +    /** @since 3.1 */
  +    private LinkFactory _linkFactory;
  +
       /**
        * Defaults MIME types, by extension, used when the servlet container doesn't provide
MIME
        * types. ServletExec Debugger, for example, fails to do provide these.
  @@ -98,7 +103,7 @@
   
           // Service is stateless
   
  -        return constructLink(cycle, Tapestry.ASSET_SERVICE, null, new Object[]
  +        return _linkFactory.constructLink(cycle, Tapestry.ASSET_SERVICE, null, new Object[]
           { path }, false);
       }
   
  @@ -130,9 +135,9 @@
       public void service(IRequestCycle cycle, ResponseOutputStream output) throws ServletException,
               IOException
       {
  -        Object[] parameters = getParameters(cycle);
  +        Object[] parameters = _linkFactory.extractServiceParameters(cycle);
   
  -        if (Tapestry.size(parameters) != 1)
  +        if (parameters.length != 1)
               throw new ApplicationRuntimeException(Tapestry.format(
                       "service-single-parameter",
                       Tapestry.ASSET_SERVICE));
  @@ -215,5 +220,11 @@
       public void setAssetExternalizer(AssetExternalizer assetExternalizer)
       {
           _assetExternalizer = assetExternalizer;
  +    }
  +
  +    /** @since 3.1 */
  +    public void setLinkFactory(LinkFactory linkFactory)
  +    {
  +        _linkFactory = linkFactory;
       }
   }
  
  
  

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


Mime
View raw message