Clover coverage report - Code Coverage for tapestry release 4.0-rc-2
Coverage timestamp: Sat Dec 17 2005 09:39:46 PST
file stats: LOC: 87   Methods: 5
NCLOC: 39   Classes: 1
 
 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 org.apache.hivemind.util.Defense;
 22    import org.apache.tapestry.IRequestCycle;
 23    import org.apache.tapestry.Tapestry;
 24    import org.apache.tapestry.services.LinkFactory;
 25    import org.apache.tapestry.services.ResponseRenderer;
 26    import org.apache.tapestry.services.ServiceConstants;
 27   
 28    /**
 29    * Basic server for creating a link to another page in the application.
 30    *
 31    * @author Howard Lewis Ship
 32    * @since 1.0.9
 33    */
 34   
 35    public class PageService implements IEngineService
 36    {
 37    /** @since 4.0 */
 38    private ResponseRenderer _responseRenderer;
 39   
 40    /** @since 4.0 */
 41    private LinkFactory _linkFactory;
 42   
 43  7 public ILink getLink(boolean post, Object parameter)
 44    {
 45  7 Defense.isAssignable(parameter, String.class, "parameter");
 46   
 47  7 Map parameters = new HashMap();
 48   
 49  7 parameters.put(ServiceConstants.PAGE, parameter);
 50   
 51  7 return _linkFactory.constructLink(this, post, parameters, true);
 52   
 53    }
 54   
 55  51 public void service(IRequestCycle cycle) throws IOException
 56    {
 57  51 String pageName = cycle.getParameter(ServiceConstants.PAGE);
 58   
 59    // At one time, the page service required a session, but that is no longer necessary.
 60    // Users can now bookmark pages within a Tapestry application. Pages
 61    // can implement validate() and throw a PageRedirectException if they don't
 62    // want to be accessed this way. For example, most applications have a concept
 63    // of a "login" and have a few pages that don't require the user to be logged in,
 64    // and other pages that do. The protected pages should redirect to a login page.
 65   
 66  51 cycle.activate(pageName);
 67   
 68  41 _responseRenderer.renderResponse(cycle);
 69    }
 70   
 71  34 public String getName()
 72    {
 73  34 return Tapestry.PAGE_SERVICE;
 74    }
 75   
 76    /** @since 4.0 */
 77  29 public void setResponseRenderer(ResponseRenderer responseRenderer)
 78    {
 79  29 _responseRenderer = responseRenderer;
 80    }
 81   
 82    /** @since 4.0 */
 83  29 public void setLinkFactory(LinkFactory linkFactory)
 84    {
 85  29 _linkFactory = linkFactory;
 86    }
 87    }