01: /*
02: * Created on 5 Aug 2006
03: */
04: package uk.org.ponder.rsac;
05:
06: import uk.org.ponder.errorutil.ErrorStateEntry;
07: import uk.org.ponder.errorutil.ThreadErrorState;
08: import uk.org.ponder.messageutil.TargettedMessageList;
09: import uk.org.ponder.util.RunnableInvoker;
10:
11: /**
12: * Link the PonderUtilCore ThreadErrorState marker with the lifecycle of a
13: * request bean (in practice as a BeanFetchBracketer)
14: *
15: * @author Antranig Basman (antranig@caret.cam.ac.uk)
16: *
17: */
18: public class RSACErrorBridge implements RunnableInvoker {
19:
20: private String tmlbeanname;
21: private RSACBeanLocator rsacbeanlocator;
22:
23: public void setRSACBeanLocator(RSACBeanLocator rsacbeanlocator) {
24: this .rsacbeanlocator = rsacbeanlocator;
25: }
26:
27: public void setTMLBeanName(String tmlbeanname) {
28: this .tmlbeanname = tmlbeanname;
29: }
30:
31: public void invokeRunnable(Runnable towrap) {
32: TargettedMessageList tml = (TargettedMessageList) rsacbeanlocator
33: .getBeanLocator().locateBean(tmlbeanname);
34: ThreadErrorState.beginRequest();
35: ErrorStateEntry ese = ThreadErrorState.getErrorState();
36: ese.messages = tml;
37: try {
38: towrap.run();
39: } finally {
40: ThreadErrorState.endRequest();
41: }
42: }
43:
44: }
|