1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.impl; |
12 | |
|
13 | |
import org.mule.MuleException; |
14 | |
import org.mule.config.PoolingProfile; |
15 | |
import org.mule.config.QueueProfile; |
16 | |
import org.mule.config.ThreadingProfile; |
17 | |
import org.mule.impl.container.DescriptorContainerKeyPair; |
18 | |
import org.mule.umo.UMODescriptor; |
19 | |
import org.mule.umo.UMOInterceptor; |
20 | |
import org.mule.umo.endpoint.UMOEndpoint; |
21 | |
import org.mule.umo.routing.UMOInboundRouterCollection; |
22 | |
import org.mule.umo.routing.UMONestedRouterCollection; |
23 | |
import org.mule.umo.routing.UMOOutboundRouterCollection; |
24 | |
import org.mule.umo.routing.UMOResponseRouterCollection; |
25 | |
import org.mule.umo.transformer.UMOTransformer; |
26 | |
import org.mule.util.FileUtils; |
27 | |
|
28 | |
import java.beans.ExceptionListener; |
29 | |
import java.io.FileInputStream; |
30 | |
import java.util.List; |
31 | |
import java.util.Map; |
32 | |
import java.util.Properties; |
33 | |
|
34 | |
import org.apache.commons.logging.Log; |
35 | |
import org.apache.commons.logging.LogFactory; |
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | |
|
43 | |
public class MuleDescriptor extends ImmutableMuleDescriptor implements UMODescriptor |
44 | |
{ |
45 | |
public static final String DEFAULT_INSTANCE_REF_NAME = "_instanceRef"; |
46 | |
|
47 | |
|
48 | |
|
49 | 0 | private static Log logger = LogFactory.getLog(MuleDescriptor.class); |
50 | |
|
51 | |
public MuleDescriptor(String name) |
52 | |
{ |
53 | 0 | super(); |
54 | 0 | this.name = name; |
55 | 0 | } |
56 | |
|
57 | |
public MuleDescriptor(MuleDescriptor descriptor) |
58 | |
{ |
59 | 0 | super(descriptor); |
60 | 0 | } |
61 | |
|
62 | |
|
63 | |
|
64 | |
|
65 | |
|
66 | |
|
67 | |
|
68 | |
public MuleDescriptor() |
69 | |
{ |
70 | 0 | super(); |
71 | 0 | } |
72 | |
|
73 | |
public void setThreadingProfile(ThreadingProfile threadingProfile) |
74 | |
{ |
75 | 0 | this.threadingProfile = threadingProfile; |
76 | 0 | } |
77 | |
|
78 | |
|
79 | |
|
80 | |
|
81 | |
|
82 | |
|
83 | |
public void setExceptionListener(ExceptionListener listener) |
84 | |
{ |
85 | 0 | if (listener == null) |
86 | |
{ |
87 | 0 | throw new IllegalArgumentException("Exception Strategy cannot be null"); |
88 | |
} |
89 | 0 | this.exceptionListener = listener; |
90 | 0 | logger.debug("Using exception strategy: " + listener.getClass().getName()); |
91 | 0 | } |
92 | |
|
93 | |
|
94 | |
|
95 | |
|
96 | |
|
97 | |
|
98 | |
public void setName(String newName) |
99 | |
{ |
100 | 0 | if (newName == null) |
101 | |
{ |
102 | 0 | throw new IllegalArgumentException("Name cannot be null"); |
103 | |
} |
104 | 0 | name = newName; |
105 | 0 | } |
106 | |
|
107 | |
|
108 | |
|
109 | |
|
110 | |
|
111 | |
|
112 | |
public void setOutboundTransformer(UMOTransformer transformer) |
113 | |
{ |
114 | 0 | outboundTransformer = transformer; |
115 | 0 | } |
116 | |
|
117 | |
|
118 | |
|
119 | |
|
120 | |
|
121 | |
|
122 | |
public void setResponseTransformer(UMOTransformer transformer) |
123 | |
{ |
124 | 0 | responseTransformer = transformer; |
125 | 0 | } |
126 | |
|
127 | |
|
128 | |
|
129 | |
|
130 | |
|
131 | |
|
132 | |
public void setProperties(Map props) |
133 | |
{ |
134 | 0 | properties = props; |
135 | 0 | String delegate = (String) properties.get(MULE_PROPERTY_DOT_PROPERTIES); |
136 | 0 | if (delegate != null) |
137 | |
{ |
138 | |
try |
139 | |
{ |
140 | 0 | FileInputStream is = new FileInputStream(FileUtils.newFile(delegate)); |
141 | 0 | Properties dProps = new Properties(); |
142 | 0 | dProps.load(is); |
143 | 0 | properties.putAll(dProps); |
144 | |
} |
145 | 0 | catch (Exception e) |
146 | |
{ |
147 | |
|
148 | 0 | logger.warn(MULE_PROPERTY_DOT_PROPERTIES + " was set to " + delegate |
149 | |
+ " but the file could not be read, exception is: " + e.getMessage()); |
150 | 0 | } |
151 | |
} |
152 | 0 | } |
153 | |
|
154 | |
|
155 | |
|
156 | |
|
157 | |
|
158 | |
|
159 | |
public void setVersion(String ver) |
160 | |
{ |
161 | 0 | version = ver; |
162 | 0 | } |
163 | |
|
164 | |
|
165 | |
|
166 | |
|
167 | |
|
168 | |
|
169 | |
public void setInboundEndpoint(UMOEndpoint endpoint) throws MuleException |
170 | |
{ |
171 | 0 | inboundEndpoint = endpoint; |
172 | 0 | if (inboundEndpoint != null) |
173 | |
{ |
174 | 0 | inboundEndpoint.setType(UMOEndpoint.ENDPOINT_TYPE_RECEIVER); |
175 | 0 | if (inboundEndpoint.getTransformer() != null) |
176 | |
{ |
177 | 0 | inboundTransformer = inboundEndpoint.getTransformer(); |
178 | |
} |
179 | |
} |
180 | 0 | } |
181 | |
|
182 | |
|
183 | |
|
184 | |
|
185 | |
|
186 | |
|
187 | |
|
188 | |
public void setOutboundEndpoint(UMOEndpoint endpoint) throws MuleException |
189 | |
{ |
190 | 0 | outboundEndpoint = endpoint; |
191 | 0 | if (outboundEndpoint != null) |
192 | |
{ |
193 | 0 | outboundEndpoint.setType(UMOEndpoint.ENDPOINT_TYPE_SENDER); |
194 | 0 | if (outboundEndpoint.getTransformer() != null) |
195 | |
{ |
196 | 0 | outboundTransformer = outboundEndpoint.getTransformer(); |
197 | |
} |
198 | |
} |
199 | |
|
200 | 0 | } |
201 | |
|
202 | |
|
203 | |
|
204 | |
|
205 | |
|
206 | |
|
207 | |
public void setInboundTransformer(UMOTransformer transformer) |
208 | |
{ |
209 | 0 | inboundTransformer = transformer; |
210 | 0 | } |
211 | |
|
212 | |
|
213 | |
|
214 | |
|
215 | |
|
216 | |
|
217 | |
public void addInterceptor(UMOInterceptor inteceptor) |
218 | |
{ |
219 | 0 | if (inteceptor != null) |
220 | |
{ |
221 | 0 | intecerptorList.add(inteceptor); |
222 | |
} |
223 | 0 | } |
224 | |
|
225 | |
public void setInterceptors(List inteceptorList) |
226 | |
{ |
227 | 0 | this.intecerptorList = inteceptorList; |
228 | 0 | } |
229 | |
|
230 | |
|
231 | |
|
232 | |
|
233 | |
|
234 | |
|
235 | |
public void setPoolingProfile(PoolingProfile poolingProfile) |
236 | |
{ |
237 | 0 | this.poolingProfile = poolingProfile; |
238 | 0 | } |
239 | |
|
240 | |
public void setQueueProfile(QueueProfile queueProfile) |
241 | |
{ |
242 | 0 | this.queueProfile = queueProfile; |
243 | 0 | } |
244 | |
|
245 | |
|
246 | |
|
247 | |
|
248 | |
|
249 | |
|
250 | |
public void setImplementation(Object reference) |
251 | |
{ |
252 | 0 | if (reference == null) |
253 | |
{ |
254 | 0 | throw new IllegalArgumentException("ImplementationReference cannot be null"); |
255 | |
} |
256 | 0 | implementationReference = reference; |
257 | 0 | } |
258 | |
|
259 | |
public void setImplementationInstance(Object instance) |
260 | |
{ |
261 | 0 | if (name == null) |
262 | |
{ |
263 | 0 | throw new IllegalArgumentException("UMODescriptor.name may not be null"); |
264 | |
} |
265 | 0 | properties.put(DEFAULT_INSTANCE_REF_NAME, instance); |
266 | 0 | setImplementation(new DescriptorContainerKeyPair(name, DEFAULT_INSTANCE_REF_NAME)); |
267 | 0 | } |
268 | |
|
269 | |
public void setInboundRouter(UMOInboundRouterCollection router) |
270 | |
{ |
271 | 0 | this.inboundRouter = router; |
272 | 0 | } |
273 | |
|
274 | |
public void setOutboundRouter(UMOOutboundRouterCollection router) |
275 | |
{ |
276 | 0 | outboundRouter = router; |
277 | 0 | } |
278 | |
|
279 | |
public void setNestedRouter(UMONestedRouterCollection router) |
280 | |
{ |
281 | 0 | nestedRouter = router; |
282 | 0 | } |
283 | |
|
284 | |
public void setContainerManaged(boolean value) |
285 | |
{ |
286 | 0 | containerManaged = value; |
287 | 0 | } |
288 | |
|
289 | |
public void addInitialisationCallback(InitialisationCallback callback) |
290 | |
{ |
291 | 0 | initialisationCallbacks.add(callback); |
292 | 0 | } |
293 | |
|
294 | |
|
295 | |
|
296 | |
|
297 | |
|
298 | |
|
299 | |
|
300 | |
|
301 | |
|
302 | |
|
303 | |
|
304 | |
public void setResponseRouter(UMOResponseRouterCollection router) |
305 | |
{ |
306 | 0 | this.responseRouter = router; |
307 | 0 | } |
308 | |
|
309 | |
|
310 | |
|
311 | |
|
312 | |
|
313 | |
|
314 | |
|
315 | |
|
316 | |
|
317 | |
public void setSingleton(boolean singleton) |
318 | |
{ |
319 | 0 | this.singleton = singleton; |
320 | 0 | } |
321 | |
|
322 | |
|
323 | |
|
324 | |
|
325 | |
|
326 | |
|
327 | |
public void setInitialState(String state) |
328 | |
{ |
329 | 0 | this.initialState = state; |
330 | 0 | } |
331 | |
|
332 | |
public void setEncoding(String encoding) |
333 | |
{ |
334 | 0 | this.encoding = encoding; |
335 | 0 | } |
336 | |
|
337 | |
|
338 | |
|
339 | |
|
340 | |
|
341 | |
|
342 | |
|
343 | |
|
344 | |
|
345 | |
|
346 | |
public void setContainer(String containerName) |
347 | |
{ |
348 | 0 | this.container = containerName; |
349 | 0 | } |
350 | |
|
351 | |
|
352 | |
public void setModelName(String modelName) |
353 | |
{ |
354 | 0 | this.modelName = modelName; |
355 | 0 | } |
356 | |
} |