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