KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tapestry > services > impl > DisableCachingFilter


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 java.io.IOException JavaDoc;
18
19 import org.apache.hivemind.ErrorLog;
20 import org.apache.hivemind.HiveMind;
21 import org.apache.tapestry.services.ResetEventCoordinator;
22 import org.apache.tapestry.services.WebRequestServicer;
23 import org.apache.tapestry.services.WebRequestServicerFilter;
24 import org.apache.tapestry.web.WebRequest;
25 import org.apache.tapestry.web.WebResponse;
26
27 /**
28  * Filter whose job is to invoke
29  * {@link org.apache.tapestry.services.ResetEventCoordinator#fireResetEvent()}after the request has
30  * been processed. This filter is only contributed into the
31  * tapestry.request.WebRequestServicerPipeline configuration if the
32  * org.apache.tapestry.disable-caching system property is true.
33  *
34  * @author Howard M. Lewis Ship
35  * @since 4.0
36  */

37 public class DisableCachingFilter implements WebRequestServicerFilter
38 {
39     private ErrorLog _errorLog;
40
41     private ResetEventCoordinator _resetEventCoordinator;
42
43     public void service(WebRequest request, WebResponse response, WebRequestServicer servicer)
44             throws IOException JavaDoc
45     {
46         try
47         {
48             servicer.service(request, response);
49         }
50         finally
51         {
52             fireResetEvent();
53         }
54
55     }
56
57     private void fireResetEvent()
58     {
59         try
60         {
61             _resetEventCoordinator.fireResetEvent();
62         }
63         catch (Exception JavaDoc ex)
64         {
65             _errorLog.error(ImplMessages.errorResetting(ex), HiveMind.getLocation(ex), ex);
66         }
67     }
68
69     public void setResetEventCoordinator(ResetEventCoordinator resetEventCoordinator)
70     {
71         _resetEventCoordinator = resetEventCoordinator;
72     }
73
74     public void setErrorLog(ErrorLog errorLog)
75     {
76         _errorLog = errorLog;
77     }
78 }
Popular Tags