01: /*
02: * Created on 7 Nov 2006
03: */
04: package uk.org.ponder.util;
05:
06: /** A simple RunnableInvoker that converts any incoming exceptions by
07: * replacing their message with a supplied String. By standard RSF semantics,
08: * if this is applied to a bean write operation, the String value will be used
09: * as a key to locate a message from the current message bundle,
10: * when it results in a TargettedMessage entry.
11: * @author Antranig Basman (antranig@caret.cam.ac.uk)
12: *
13: */
14:
15: public class StaticExceptionConvertingRI implements RunnableInvoker {
16: private String message;
17: private Class clazz = IllegalArgumentException.class;
18:
19: public void setMessage(String message) {
20: this .message = message;
21: }
22:
23: public void setExceptionClass(Class clazz) {
24: this .clazz = clazz;
25: }
26:
27: public void invokeRunnable(Runnable torun) {
28: try {
29: torun.run();
30: } catch (Exception e) {
31: throw UniversalRuntimeException.accumulateMsg(e, clazz,
32: message);
33: }
34: }
35: }
|