Clover coverage report - Code Coverage for tapestry release 3.1-alpha-1
Coverage timestamp: Mon Feb 21 2005 09:16:14 EST
file stats: LOC: 92   Methods: 5
NCLOC: 43   Classes: 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
PageService.java - 100% 100% 100%
coverage
 1   
 // Copyright 2004, 2005 The Apache Software Foundation
 2   
 //
 3   
 // Licensed under the Apache License, Version 2.0 (the "License");
 4   
 // you may not use this file except in compliance with the License.
 5   
 // You may obtain a copy of the License at
 6   
 //
 7   
 //     http://www.apache.org/licenses/LICENSE-2.0
 8   
 //
 9   
 // Unless required by applicable law or agreed to in writing, software
 10   
 // distributed under the License is distributed on an "AS IS" BASIS,
 11   
 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12   
 // See the License for the specific language governing permissions and
 13   
 // limitations under the License.
 14   
 
 15   
 package org.apache.tapestry.engine;
 16   
 
 17   
 import java.io.IOException;
 18   
 import java.util.HashMap;
 19   
 import java.util.Map;
 20   
 
 21   
 import javax.servlet.ServletException;
 22   
 
 23   
 import org.apache.hivemind.util.Defense;
 24   
 import org.apache.tapestry.IRequestCycle;
 25   
 import org.apache.tapestry.Tapestry;
 26   
 import org.apache.tapestry.request.ResponseOutputStream;
 27   
 import org.apache.tapestry.services.LinkFactory;
 28   
 import org.apache.tapestry.services.ResponseRenderer;
 29   
 import org.apache.tapestry.services.ServiceConstants;
 30   
 
 31   
 /**
 32   
  * Basic server for creating a link to another page in the application.
 33   
  * 
 34   
  * @author Howard Lewis Ship
 35   
  * @since 1.0.9
 36   
  */
 37   
 
 38   
 public class PageService implements IEngineService
 39   
 {
 40   
     /** @since 3.1 */
 41   
     private ResponseRenderer _responseRenderer;
 42   
 
 43   
     /** @since 3.1 */
 44   
     private LinkFactory _linkFactory;
 45   
 
 46  8
     public ILink getLink(IRequestCycle cycle, Object parameter)
 47   
     {
 48  8
         Defense.isAssignable(parameter, String.class, "parameter");
 49   
 
 50  8
         Map parameters = new HashMap();
 51   
 
 52  8
         parameters.put(ServiceConstants.SERVICE, Tapestry.PAGE_SERVICE);
 53  8
         parameters.put(ServiceConstants.PAGE, parameter);
 54   
 
 55  8
         return _linkFactory.constructLink(cycle, parameters, true);
 56   
 
 57   
     }
 58   
 
 59  76
     public void service(IRequestCycle cycle, ResponseOutputStream output) throws ServletException,
 60   
             IOException
 61   
     {
 62  76
         String pageName = cycle.getParameter(ServiceConstants.PAGE);
 63   
 
 64   
         // At one time, the page service required a session, but that is no longer necessary.
 65   
         // Users can now bookmark pages within a Tapestry application. Pages
 66   
         // can implement validate() and throw a PageRedirectException if they don't
 67   
         // want to be accessed this way. For example, most applications have a concept
 68   
         // of a "login" and have a few pages that don't require the user to be logged in,
 69   
         // and other pages that do. The protected pages should redirect to a login page.
 70   
 
 71  76
         cycle.activate(pageName);
 72   
 
 73  64
         _responseRenderer.renderResponse(cycle, output);
 74   
     }
 75   
 
 76  202
     public String getName()
 77   
     {
 78  202
         return Tapestry.PAGE_SERVICE;
 79   
     }
 80   
 
 81   
     /** @since 3.1 */
 82  53
     public void setResponseRenderer(ResponseRenderer responseRenderer)
 83   
     {
 84  53
         _responseRenderer = responseRenderer;
 85   
     }
 86   
 
 87   
     /** @since 3.1 */
 88  53
     public void setLinkFactory(LinkFactory linkFactory)
 89   
     {
 90  53
         _linkFactory = linkFactory;
 91   
     }
 92   
 }