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 |
4 |
public class DisableCachingFilter implements WebRequestServicerFilter |
40 |
|
{ |
41 |
4 |
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 |
102 |
_lock.lock(); |
53 |
|
|
54 |
102 |
servicer.service(request, response); |
55 |
|
} |
56 |
|
finally |
57 |
|
{ |
58 |
102 |
fireResetEvent(); |
59 |
|
|
60 |
102 |
_lock.unlock(); |
61 |
102 |
} |
62 |
|
|
63 |
102 |
} |
64 |
|
|
65 |
|
private void fireResetEvent() |
66 |
|
{ |
67 |
|
try |
68 |
|
{ |
69 |
102 |
_resetEventHub.fireResetEvent(); |
70 |
|
} |
71 |
1 |
catch (Exception ex) |
72 |
|
{ |
73 |
1 |
_errorLog.error(ImplMessages.errorResetting(ex), HiveMind.getLocation(ex), ex); |
74 |
101 |
} |
75 |
102 |
} |
76 |
|
|
77 |
|
public void setResetEventHub(ResetEventHub resetEventCoordinator) |
78 |
|
{ |
79 |
4 |
_resetEventHub = resetEventCoordinator; |
80 |
4 |
} |
81 |
|
|
82 |
|
public void setErrorLog(ErrorLog errorLog) |
83 |
|
{ |
84 |
1 |
_errorLog = errorLog; |
85 |
1 |
} |
86 |
|
} |