1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.tck.testmodels.fruit; |
12 | |
|
13 | |
import org.mule.umo.UMOEventContext; |
14 | |
import org.mule.umo.UMOException; |
15 | |
import org.mule.umo.lifecycle.Callable; |
16 | |
|
17 | |
import org.apache.commons.logging.Log; |
18 | |
import org.apache.commons.logging.LogFactory; |
19 | |
|
20 | 64 | public class Apple implements Fruit, Callable |
21 | |
{ |
22 | |
|
23 | |
|
24 | |
|
25 | |
private static final long serialVersionUID = -7631993371500076921L; |
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | 4 | private static final Log logger = LogFactory.getLog(Apple.class); |
31 | |
|
32 | 64 | private boolean bitten = false; |
33 | 64 | private boolean washed = false; |
34 | |
|
35 | |
private FruitCleaner cleaner; |
36 | |
|
37 | |
public void wash() |
38 | |
{ |
39 | 4 | if (cleaner != null) |
40 | |
{ |
41 | 2 | cleaner.wash(this); |
42 | |
} |
43 | 4 | washed = true; |
44 | 4 | } |
45 | |
|
46 | |
public void polish() |
47 | |
{ |
48 | 0 | cleaner.polish(this); |
49 | 0 | } |
50 | |
|
51 | |
public boolean isWashed() |
52 | |
{ |
53 | 0 | return washed; |
54 | |
} |
55 | |
|
56 | |
public void bite() |
57 | |
{ |
58 | 2 | bitten = true; |
59 | 2 | } |
60 | |
|
61 | |
public boolean isBitten() |
62 | |
{ |
63 | 2 | return bitten; |
64 | |
} |
65 | |
|
66 | |
public Object onCall(UMOEventContext context) throws UMOException |
67 | |
{ |
68 | 2 | logger.debug("Apple received an event in UMOCallable.onEvent! Event says: " |
69 | |
+ context.getMessageAsString()); |
70 | 2 | wash(); |
71 | 2 | return null; |
72 | |
} |
73 | |
|
74 | |
|
75 | |
public FruitCleaner getAppleCleaner() |
76 | |
{ |
77 | 0 | return cleaner; |
78 | |
} |
79 | |
|
80 | |
public void setAppleCleaner(FruitCleaner cleaner) |
81 | |
{ |
82 | 2 | this.cleaner = cleaner; |
83 | 2 | } |
84 | |
|
85 | |
|
86 | |
|
87 | |
|
88 | |
|
89 | |
public Object methodReturningNull() |
90 | |
{ |
91 | 2 | return null; |
92 | |
} |
93 | |
|
94 | |
public boolean equals(Object o) |
95 | |
{ |
96 | 4 | if (this == o) |
97 | |
{ |
98 | 0 | return true; |
99 | |
} |
100 | 4 | if (o == null || getClass() != o.getClass()) |
101 | |
{ |
102 | 0 | return false; |
103 | |
} |
104 | |
|
105 | 4 | final Apple apple = (Apple) o; |
106 | |
|
107 | 4 | if (bitten != apple.bitten) |
108 | |
{ |
109 | 0 | return false; |
110 | |
} |
111 | 4 | if (washed != apple.washed) |
112 | |
{ |
113 | 0 | return false; |
114 | |
} |
115 | |
|
116 | 4 | return true; |
117 | |
} |
118 | |
|
119 | |
public int hashCode() |
120 | |
{ |
121 | |
int result; |
122 | 0 | result = (bitten ? 1 : 0); |
123 | 0 | result = 29 * result + (washed ? 1 : 0); |
124 | 0 | return result; |
125 | |
} |
126 | |
|
127 | |
public String toString() |
128 | |
{ |
129 | 2 | return "Just an apple."; |
130 | |
} |
131 | |
} |