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: 116   Methods: 7
NCLOC: 56   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
ResetService.java 75% 93.8% 100% 92.6%
coverage 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.tapestry.IRequestCycle;
 24   
 import org.apache.tapestry.Tapestry;
 25   
 import org.apache.tapestry.request.ResponseOutputStream;
 26   
 import org.apache.tapestry.services.LinkFactory;
 27   
 import org.apache.tapestry.services.ResetEventCoordinator;
 28   
 import org.apache.tapestry.services.ResponseRenderer;
 29   
 import org.apache.tapestry.services.ServiceConstants;
 30   
 
 31   
 /**
 32   
  * ServiceLink used to discard all cached data (templates, specifications, et cetera). This is
 33   
  * primarily used during development. It could be a weakness of a Tapestry application, making it
 34   
  * susceptible to denial of service attacks, which is why it is disabled by default. The link
 35   
  * generated by the ResetService redisplays the current page after discarding all data.
 36   
  * 
 37   
  * @author Howard Lewis Ship
 38   
  * @since 1.0.9
 39   
  */
 40   
 
 41   
 public class ResetService implements IEngineService
 42   
 {
 43   
     /** @since 3.1 */
 44   
 
 45   
     private ResponseRenderer _responseRenderer;
 46   
 
 47   
     /** @since 3.1 */
 48   
 
 49   
     private ResetEventCoordinator _resetEventCoordinator;
 50   
 
 51   
     /** @since 3.1 */
 52   
     private boolean _enabled;
 53   
 
 54   
     /** @since 3.1 */
 55   
 
 56   
     private LinkFactory _linkFactory;
 57   
 
 58  4
     public ILink getLink(IRequestCycle cycle, Object parameter)
 59   
     {
 60  4
         if (parameter != null)
 61  1
             throw new IllegalArgumentException(EngineMessages.serviceNoParameter(this));
 62   
 
 63  3
         Map parameters = new HashMap();
 64   
 
 65  3
         parameters.put(ServiceConstants.SERVICE, Tapestry.RESET_SERVICE);
 66  3
         parameters.put(ServiceConstants.PAGE, cycle.getPage().getPageName());
 67   
 
 68  3
         return _linkFactory.constructLink(cycle, parameters, true);
 69   
     }
 70   
 
 71  56
     public String getName()
 72   
     {
 73  56
         return Tapestry.RESET_SERVICE;
 74   
     }
 75   
 
 76  1
     public void service(IRequestCycle cycle, ResponseOutputStream output) throws ServletException,
 77   
             IOException
 78   
     {
 79  1
         String pageName = cycle.getParameter(ServiceConstants.PAGE);
 80   
 
 81  1
         if (_enabled)
 82  0
             _resetEventCoordinator.fireResetEvent();
 83   
 
 84  1
         cycle.activate(pageName);
 85   
 
 86   
         // Render the same page (that contained the reset link).
 87   
 
 88  1
         _responseRenderer.renderResponse(cycle, output);
 89   
     }
 90   
 
 91   
     /** @since 3.1 */
 92  52
     public void setResponseRenderer(ResponseRenderer responseRenderer)
 93   
     {
 94  52
         _responseRenderer = responseRenderer;
 95   
     }
 96   
 
 97   
     /** @since 3.1 */
 98   
 
 99  52
     public void setResetEventCoordinator(ResetEventCoordinator resetEventCoordinator)
 100   
     {
 101  52
         _resetEventCoordinator = resetEventCoordinator;
 102   
     }
 103   
 
 104   
     /** @since 3.1 */
 105   
 
 106  52
     public void setEnabled(boolean enabled)
 107   
     {
 108  52
         _enabled = enabled;
 109   
     }
 110   
 
 111   
     /** @since 3.1 */
 112  53
     public void setLinkFactory(LinkFactory linkFactory)
 113   
     {
 114  53
         _linkFactory = linkFactory;
 115   
     }
 116   
 }