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