1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package net.wotonomy.control;
20
21 /***
22 * EOFaultHandler defines the contract for objects that can
23 * create and populate faults. In wotonomy, this interface is
24 * currently only a marker interface.
25 *
26 * @author michael@mpowers.net
27 * @author $Author: cgruber $
28 * @version $Revision: 893 $
29 */
30 public abstract class EOFaultHandler {
31
32 protected Class _targetClass;
33
34 public EOFaultHandler() {
35 super();
36 }
37
38 public static EOFaultHandler handlerForFault(Object obj) {
39 if (!(obj instanceof EOFaulting))
40 throw new IllegalArgumentException("Object must implement EOFaulting");
41 return ((EOFaulting)obj).faultHandler();
42 }
43
44 public static boolean isFault(Object obj) {
45 if (obj == null)
46 return false;
47 boolean isit = (obj instanceof EOFaulting);
48 if (isit)
49 isit = ((EOFaulting)obj).isFault();
50 return isit;
51 }
52
53 public static void makeObjectIntoFault(Object obj, EOFaultHandler handler) {
54 if (!(obj instanceof EOFaulting))
55 throw new IllegalArgumentException("Object must implement EOFaulting");
56 ((EOFaulting)obj).turnIntoFault(handler);
57 }
58
59 public static void clearFault(Object obj) {
60 if (!(obj instanceof EOFaulting))
61 throw new IllegalArgumentException("Object must implement EOFaulting");
62 ((EOFaulting)obj).clearFault();
63 }
64
65 public Class targetClass() {
66 return _targetClass;
67 }
68
69 public Object createFaultForDeferredFault(Object fault, EOEnterpriseObject source) {
70 return fault;
71 }
72
73 public String descriptionForObject(Object obj) {
74 if (obj == null)
75 return "<null>";
76 return obj.toString();
77 }
78
79 public String eoShallowDescription(Object obj) {
80 return null;
81 }
82
83 public abstract void completeInitializationOfObject(Object obj);
84
85 public abstract void faultWillFire(Object obj);
86
87 }
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102