Coverage Report - org.apache.tapestry.services.impl.DisableCachingFilter
 
Classes in this File Line Coverage Branch Coverage Complexity
DisableCachingFilter
0%
0/17
N/A
1.25
 
 1  
 // Copyright 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.services.impl;
 16  
 
 17  
 import edu.emory.mathcs.backport.java.util.concurrent.locks.ReentrantLock;
 18  
 
 19  
 import java.io.IOException;
 20  
 
 21  
 import org.apache.hivemind.ErrorLog;
 22  
 import org.apache.hivemind.HiveMind;
 23  
 import org.apache.tapestry.services.ResetEventHub;
 24  
 import org.apache.tapestry.services.WebRequestServicer;
 25  
 import org.apache.tapestry.services.WebRequestServicerFilter;
 26  
 import org.apache.tapestry.web.WebRequest;
 27  
 import org.apache.tapestry.web.WebResponse;
 28  
 
 29  
 /**
 30  
  * Filter whose job is to invoke
 31  
  * {@link org.apache.tapestry.services.ResetEventHub#fireResetEvent()} after the request has
 32  
  * been processed. This filter is only contributed into the
 33  
  * tapestry.request.WebRequestServicerPipeline configuration if the
 34  
  * org.apache.tapestry.disable-caching system property is true.
 35  
  * 
 36  
  * @author Howard M. Lewis Ship
 37  
  * @since 4.0
 38  
  */
 39  0
 public class DisableCachingFilter implements WebRequestServicerFilter
 40  
 {
 41  0
     private final ReentrantLock _lock = new ReentrantLock();
 42  
     
 43  
     private ErrorLog _errorLog;
 44  
     
 45  
     private ResetEventHub _resetEventHub;
 46  
     
 47  
     public void service(WebRequest request, WebResponse response, WebRequestServicer servicer)
 48  
             throws IOException
 49  
     {
 50  
         try
 51  
         {
 52  0
             _lock.lock();
 53  
             
 54  0
             servicer.service(request, response);
 55  
         }
 56  
         finally
 57  
         {
 58  0
             fireResetEvent();
 59  
             
 60  0
             _lock.unlock();
 61  0
         }
 62  
 
 63  0
     }
 64  
 
 65  
     private void fireResetEvent()
 66  
     {
 67  
         try
 68  
         {
 69  0
             _resetEventHub.fireResetEvent();
 70  
         }
 71  0
         catch (Exception ex)
 72  
         {
 73  0
             _errorLog.error(ImplMessages.errorResetting(ex), HiveMind.getLocation(ex), ex);
 74  0
         }
 75  0
     }
 76  
     
 77  
     public void setResetEventHub(ResetEventHub resetEventCoordinator)
 78  
     {
 79  0
         _resetEventHub = resetEventCoordinator;
 80  0
     }
 81  
 
 82  
     public void setErrorLog(ErrorLog errorLog)
 83  
     {
 84  0
         _errorLog = errorLog;
 85  0
     }
 86  
 }