1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
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 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
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 | |
} |