1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule; |
12 | |
|
13 | |
import org.mule.config.ConfigurationException; |
14 | |
import org.mule.config.MuleConfiguration; |
15 | |
import org.mule.config.MuleManifest; |
16 | |
import org.mule.config.MuleProperties; |
17 | |
import org.mule.config.ThreadingProfile; |
18 | |
import org.mule.config.i18n.CoreMessages; |
19 | |
import org.mule.impl.container.MultiContainerContext; |
20 | |
import org.mule.impl.internal.admin.MuleAdminAgent; |
21 | |
import org.mule.impl.internal.notifications.AdminNotification; |
22 | |
import org.mule.impl.internal.notifications.AdminNotificationListener; |
23 | |
import org.mule.impl.internal.notifications.ComponentNotification; |
24 | |
import org.mule.impl.internal.notifications.ComponentNotificationListener; |
25 | |
import org.mule.impl.internal.notifications.ConnectionNotification; |
26 | |
import org.mule.impl.internal.notifications.ConnectionNotificationListener; |
27 | |
import org.mule.impl.internal.notifications.CustomNotification; |
28 | |
import org.mule.impl.internal.notifications.CustomNotificationListener; |
29 | |
import org.mule.impl.internal.notifications.ExceptionNotification; |
30 | |
import org.mule.impl.internal.notifications.ExceptionNotificationListener; |
31 | |
import org.mule.impl.internal.notifications.ManagementNotification; |
32 | |
import org.mule.impl.internal.notifications.ManagementNotificationListener; |
33 | |
import org.mule.impl.internal.notifications.ManagerNotification; |
34 | |
import org.mule.impl.internal.notifications.ManagerNotificationListener; |
35 | |
import org.mule.impl.internal.notifications.MessageNotification; |
36 | |
import org.mule.impl.internal.notifications.MessageNotificationListener; |
37 | |
import org.mule.impl.internal.notifications.ModelNotification; |
38 | |
import org.mule.impl.internal.notifications.ModelNotificationListener; |
39 | |
import org.mule.impl.internal.notifications.NotificationException; |
40 | |
import org.mule.impl.internal.notifications.SecurityNotification; |
41 | |
import org.mule.impl.internal.notifications.SecurityNotificationListener; |
42 | |
import org.mule.impl.internal.notifications.ServerNotificationManager; |
43 | |
import org.mule.impl.internal.notifications.TransactionNotification; |
44 | |
import org.mule.impl.internal.notifications.TransactionNotificationListener; |
45 | |
import org.mule.impl.model.ModelFactory; |
46 | |
import org.mule.impl.model.ModelHelper; |
47 | |
import org.mule.impl.security.MuleSecurityManager; |
48 | |
import org.mule.impl.work.MuleWorkManager; |
49 | |
import org.mule.management.stats.AllStatistics; |
50 | |
import org.mule.umo.UMOException; |
51 | |
import org.mule.umo.UMOInterceptorStack; |
52 | |
import org.mule.umo.endpoint.UMOEndpoint; |
53 | |
import org.mule.umo.lifecycle.FatalException; |
54 | |
import org.mule.umo.lifecycle.InitialisationException; |
55 | |
import org.mule.umo.manager.UMOAgent; |
56 | |
import org.mule.umo.manager.UMOContainerContext; |
57 | |
import org.mule.umo.manager.UMOManager; |
58 | |
import org.mule.umo.manager.UMOServerNotification; |
59 | |
import org.mule.umo.manager.UMOServerNotificationListener; |
60 | |
import org.mule.umo.manager.UMOWorkManager; |
61 | |
import org.mule.umo.model.UMOModel; |
62 | |
import org.mule.umo.provider.UMOConnector; |
63 | |
import org.mule.umo.security.UMOSecurityManager; |
64 | |
import org.mule.umo.transformer.UMOTransformer; |
65 | |
import org.mule.util.CollectionUtils; |
66 | |
import org.mule.util.SpiUtils; |
67 | |
import org.mule.util.StringMessageUtils; |
68 | |
import org.mule.util.StringUtils; |
69 | |
import org.mule.util.UUID; |
70 | |
import org.mule.util.queue.QueueManager; |
71 | |
import org.mule.util.queue.QueuePersistenceStrategy; |
72 | |
import org.mule.util.queue.TransactionalQueueManager; |
73 | |
|
74 | |
import java.net.InetAddress; |
75 | |
import java.net.UnknownHostException; |
76 | |
import java.nio.charset.Charset; |
77 | |
import java.util.ArrayList; |
78 | |
import java.util.Collection; |
79 | |
import java.util.Collections; |
80 | |
import java.util.Date; |
81 | |
import java.util.HashMap; |
82 | |
import java.util.Iterator; |
83 | |
import java.util.LinkedHashMap; |
84 | |
import java.util.List; |
85 | |
import java.util.Map; |
86 | |
|
87 | |
import javax.transaction.TransactionManager; |
88 | |
import javax.xml.parsers.SAXParserFactory; |
89 | |
|
90 | |
import edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicBoolean; |
91 | |
|
92 | |
import org.apache.commons.collections.MapUtils; |
93 | |
import org.apache.commons.collections.list.CursorableLinkedList; |
94 | |
import org.apache.commons.logging.Log; |
95 | |
import org.apache.commons.logging.LogFactory; |
96 | |
|
97 | |
|
98 | |
|
99 | |
|
100 | |
public class MuleManager implements UMOManager |
101 | |
{ |
102 | |
|
103 | |
|
104 | |
|
105 | 2 | private static UMOManager instance = null; |
106 | |
|
107 | |
|
108 | |
|
109 | |
|
110 | 2 | private static MuleConfiguration config = new MuleConfiguration(); |
111 | |
|
112 | |
|
113 | |
|
114 | |
|
115 | 392 | private Map connectors = new HashMap(); |
116 | |
|
117 | |
|
118 | |
|
119 | |
|
120 | |
|
121 | |
|
122 | |
|
123 | 392 | private Map endpointIdentifiers = new HashMap(); |
124 | |
|
125 | |
|
126 | |
|
127 | |
|
128 | 392 | private Map applicationProps = new HashMap(); |
129 | |
|
130 | |
|
131 | |
|
132 | |
|
133 | 392 | private Map agents = new LinkedHashMap(); |
134 | |
|
135 | |
|
136 | |
|
137 | |
|
138 | 392 | private Map endpoints = new HashMap(); |
139 | |
|
140 | |
|
141 | |
|
142 | |
|
143 | 392 | private Map models = new LinkedHashMap(); |
144 | |
|
145 | |
|
146 | |
|
147 | |
|
148 | 392 | private String id = UUID.getUUID(); |
149 | |
|
150 | |
|
151 | |
|
152 | |
|
153 | 392 | private TransactionManager transactionManager = null; |
154 | |
|
155 | |
|
156 | |
|
157 | |
|
158 | 392 | private Map transformers = new HashMap(); |
159 | |
|
160 | |
|
161 | |
|
162 | |
|
163 | 392 | private AtomicBoolean initialised = new AtomicBoolean(false); |
164 | |
|
165 | |
|
166 | |
|
167 | |
|
168 | 392 | private AtomicBoolean initialising = new AtomicBoolean(false); |
169 | |
|
170 | |
|
171 | |
|
172 | |
|
173 | 392 | private AtomicBoolean started = new AtomicBoolean(false); |
174 | |
|
175 | |
|
176 | |
|
177 | |
|
178 | 392 | private AtomicBoolean starting = new AtomicBoolean(false); |
179 | |
|
180 | |
|
181 | |
|
182 | |
|
183 | 392 | private AtomicBoolean stopping = new AtomicBoolean(false); |
184 | |
|
185 | |
|
186 | |
|
187 | |
|
188 | 392 | private AtomicBoolean disposed = new AtomicBoolean(false); |
189 | |
|
190 | |
|
191 | |
|
192 | |
|
193 | 392 | private Map interceptorsMap = new HashMap(); |
194 | |
|
195 | |
|
196 | |
|
197 | |
|
198 | 392 | private long startDate = 0; |
199 | |
|
200 | |
|
201 | |
|
202 | |
|
203 | 392 | private AllStatistics stats = new AllStatistics(); |
204 | |
|
205 | |
|
206 | |
|
207 | |
|
208 | 392 | private ServerNotificationManager notificationManager = null; |
209 | |
|
210 | 392 | private MultiContainerContext containerContext = null; |
211 | |
|
212 | |
private UMOSecurityManager securityManager; |
213 | |
|
214 | |
|
215 | |
|
216 | |
|
217 | |
private QueueManager queueManager; |
218 | |
|
219 | |
private UMOWorkManager workManager; |
220 | |
|
221 | |
|
222 | |
|
223 | |
|
224 | 46 | private static Log logger = LogFactory.getLog(MuleManager.class); |
225 | |
|
226 | |
|
227 | |
|
228 | |
|
229 | |
private MuleManager() |
230 | 392 | { |
231 | 392 | if (config == null) |
232 | |
{ |
233 | 0 | config = new MuleConfiguration(); |
234 | |
} |
235 | 392 | containerContext = new MultiContainerContext(); |
236 | 392 | securityManager = new MuleSecurityManager(); |
237 | |
|
238 | |
|
239 | 392 | notificationManager = new ServerNotificationManager(); |
240 | 392 | notificationManager.registerEventType(ManagerNotification.class, ManagerNotificationListener.class); |
241 | 392 | notificationManager.registerEventType(ModelNotification.class, ModelNotificationListener.class); |
242 | 392 | notificationManager.registerEventType(ComponentNotification.class, |
243 | |
ComponentNotificationListener.class); |
244 | 392 | notificationManager.registerEventType(SecurityNotification.class, SecurityNotificationListener.class); |
245 | 392 | notificationManager.registerEventType(ManagementNotification.class, |
246 | |
ManagementNotificationListener.class); |
247 | 392 | notificationManager.registerEventType(AdminNotification.class, AdminNotificationListener.class); |
248 | 392 | notificationManager.registerEventType(CustomNotification.class, CustomNotificationListener.class); |
249 | 392 | notificationManager.registerEventType(ConnectionNotification.class, |
250 | |
ConnectionNotificationListener.class); |
251 | 392 | notificationManager.registerEventType(ExceptionNotification.class, |
252 | |
ExceptionNotificationListener.class); |
253 | 392 | notificationManager.registerEventType(TransactionNotification.class, |
254 | |
TransactionNotificationListener.class); |
255 | 392 | } |
256 | |
|
257 | |
|
258 | |
|
259 | |
|
260 | |
|
261 | |
|
262 | |
public static synchronized UMOManager getInstance() |
263 | |
{ |
264 | 7863 | if (instance == null) |
265 | |
{ |
266 | 392 | logger.info("Creating new MuleManager instance"); |
267 | |
|
268 | 392 | Class clazz = SpiUtils.findService(UMOManager.class, MuleManager.class.getName(), |
269 | |
MuleManager.class); |
270 | |
try |
271 | |
{ |
272 | |
|
273 | 392 | instance = (UMOManager) clazz.newInstance(); |
274 | 392 | registerSystemModel(config.getSystemModelType()); |
275 | |
} |
276 | 0 | catch (Exception e) |
277 | |
{ |
278 | 0 | throw new MuleRuntimeException(CoreMessages.failedToCreateManagerInstance(clazz.getName()), e); |
279 | 392 | } |
280 | |
} |
281 | |
|
282 | 7863 | return instance; |
283 | |
} |
284 | |
|
285 | |
|
286 | |
|
287 | |
|
288 | |
|
289 | |
|
290 | |
|
291 | |
|
292 | |
|
293 | |
|
294 | |
|
295 | |
public static synchronized boolean isInstanciated() |
296 | |
{ |
297 | 7726 | return (instance != null); |
298 | |
} |
299 | |
|
300 | |
|
301 | |
|
302 | |
|
303 | |
|
304 | |
|
305 | |
public static synchronized void setInstance(UMOManager manager) |
306 | |
{ |
307 | 0 | instance = manager; |
308 | 0 | if (instance == null) |
309 | |
{ |
310 | 0 | config = new MuleConfiguration(); |
311 | |
} |
312 | 0 | } |
313 | |
|
314 | |
|
315 | |
|
316 | |
|
317 | |
|
318 | |
|
319 | |
public AllStatistics getStatistics() |
320 | |
{ |
321 | 126 | return stats; |
322 | |
} |
323 | |
|
324 | |
|
325 | |
|
326 | |
|
327 | |
|
328 | |
|
329 | |
public void setStatistics(AllStatistics stat) |
330 | |
{ |
331 | 0 | this.stats = stat; |
332 | 0 | } |
333 | |
|
334 | |
|
335 | |
|
336 | |
|
337 | |
|
338 | |
public static synchronized MuleConfiguration getConfiguration() |
339 | |
{ |
340 | 10724 | return config; |
341 | |
} |
342 | |
|
343 | |
|
344 | |
|
345 | |
|
346 | |
|
347 | |
|
348 | |
|
349 | |
|
350 | |
|
351 | |
public static synchronized void setConfiguration(MuleConfiguration config) throws UMOException |
352 | |
{ |
353 | 1900 | if (config == null) |
354 | |
{ |
355 | 0 | throw new IllegalArgumentException(CoreMessages.objectIsNull("MuleConfiguration object") |
356 | |
.getMessage()); |
357 | |
} |
358 | |
|
359 | 1900 | MuleManager.config = config; |
360 | |
|
361 | |
|
362 | 1900 | registerSystemModel(config.getSystemModelType()); |
363 | |
|
364 | 1900 | } |
365 | |
|
366 | |
protected static void registerSystemModel(String type) throws UMOException |
367 | |
{ |
368 | 2292 | if (instance != null) |
369 | |
{ |
370 | |
|
371 | 392 | UMOModel model = instance.lookupModel(type); |
372 | 392 | if (model != null && model.getComponentNames().hasNext()) |
373 | |
{ |
374 | 0 | throw new IllegalStateException( |
375 | |
"System model is already registered and contains components. Cannot overwrite"); |
376 | |
} |
377 | 392 | model = ModelFactory.createModel(config.getSystemModelType()); |
378 | 392 | model.setName(ModelHelper.SYSTEM_MODEL); |
379 | 392 | instance.registerModel(model); |
380 | |
} |
381 | 2292 | } |
382 | |
|
383 | |
|
384 | |
|
385 | |
|
386 | |
|
387 | |
|
388 | |
|
389 | |
public synchronized void dispose() |
390 | |
{ |
391 | 392 | if (disposed.get()) |
392 | |
{ |
393 | 0 | return; |
394 | |
} |
395 | |
try |
396 | |
{ |
397 | 392 | if (started.get()) |
398 | |
{ |
399 | 12 | stop(); |
400 | |
} |
401 | |
} |
402 | 0 | catch (UMOException e) |
403 | |
{ |
404 | 0 | logger.error("Failed to stop manager: " + e.getMessage(), e); |
405 | 392 | } |
406 | 392 | disposed.set(true); |
407 | 392 | disposeConnectors(); |
408 | |
|
409 | 392 | for (Iterator i = models.values().iterator(); i.hasNext();) |
410 | |
{ |
411 | 482 | UMOModel model = (UMOModel) i.next(); |
412 | 482 | model.dispose(); |
413 | 482 | } |
414 | |
|
415 | 392 | disposeAgents(); |
416 | |
|
417 | 392 | transformers.clear(); |
418 | 392 | endpoints.clear(); |
419 | 392 | endpointIdentifiers.clear(); |
420 | 392 | containerContext.dispose(); |
421 | 392 | containerContext = null; |
422 | |
|
423 | 392 | fireSystemEvent(new ManagerNotification(this, ManagerNotification.MANAGER_DISPOSED)); |
424 | |
|
425 | 392 | transformers = null; |
426 | 392 | endpoints = null; |
427 | 392 | endpointIdentifiers = null; |
428 | |
|
429 | 392 | initialised.set(false); |
430 | 392 | if (notificationManager != null) |
431 | |
{ |
432 | 392 | notificationManager.dispose(); |
433 | |
} |
434 | 392 | if (workManager != null) |
435 | |
{ |
436 | 44 | workManager.dispose(); |
437 | |
} |
438 | |
|
439 | 392 | if (queueManager != null) |
440 | |
{ |
441 | 46 | queueManager.close(); |
442 | 46 | queueManager = null; |
443 | |
} |
444 | |
|
445 | 392 | if ((startDate > 0) && logger.isInfoEnabled()) |
446 | |
{ |
447 | 0 | logger.info(this.getEndSplash()); |
448 | |
} |
449 | |
|
450 | 392 | config = new MuleConfiguration(); |
451 | 392 | instance = null; |
452 | 392 | } |
453 | |
|
454 | |
|
455 | |
|
456 | |
|
457 | |
private synchronized void disposeConnectors() |
458 | |
{ |
459 | 392 | fireSystemEvent(new ManagerNotification(this, ManagerNotification.MANAGER_DISPOSING_CONNECTORS)); |
460 | 392 | for (Iterator iterator = connectors.values().iterator(); iterator.hasNext();) |
461 | |
{ |
462 | 46 | UMOConnector c = (UMOConnector) iterator.next(); |
463 | 46 | c.dispose(); |
464 | 46 | } |
465 | 392 | fireSystemEvent(new ManagerNotification(this, ManagerNotification.MANAGER_DISPOSED_CONNECTORS)); |
466 | 392 | } |
467 | |
|
468 | |
|
469 | |
|
470 | |
|
471 | |
public Object getProperty(Object key) |
472 | |
{ |
473 | 0 | return applicationProps.get(key); |
474 | |
} |
475 | |
|
476 | |
|
477 | |
|
478 | |
|
479 | |
public Map getProperties() |
480 | |
{ |
481 | 64 | return applicationProps; |
482 | |
} |
483 | |
|
484 | |
|
485 | |
|
486 | |
|
487 | |
public TransactionManager getTransactionManager() |
488 | |
{ |
489 | 0 | return transactionManager; |
490 | |
} |
491 | |
|
492 | |
|
493 | |
|
494 | |
|
495 | |
public UMOConnector lookupConnector(String name) |
496 | |
{ |
497 | 168 | return (UMOConnector) connectors.get(name); |
498 | |
} |
499 | |
|
500 | |
|
501 | |
|
502 | |
|
503 | |
|
504 | |
|
505 | |
|
506 | |
public String lookupEndpointIdentifier(String logicalName, String defaultName) |
507 | |
{ |
508 | 874 | String name = (String) endpointIdentifiers.get(logicalName); |
509 | 874 | if (name == null) |
510 | |
{ |
511 | 874 | return defaultName; |
512 | |
} |
513 | 0 | return name; |
514 | |
} |
515 | |
|
516 | |
|
517 | |
|
518 | |
|
519 | |
public UMOEndpoint lookupEndpoint(String logicalName) |
520 | |
{ |
521 | 134 | UMOEndpoint endpoint = (UMOEndpoint) endpoints.get(logicalName); |
522 | 134 | if (endpoint != null) |
523 | |
{ |
524 | 0 | return (UMOEndpoint) endpoint.clone(); |
525 | |
} |
526 | |
else |
527 | |
{ |
528 | 134 | return null; |
529 | |
} |
530 | |
} |
531 | |
|
532 | |
|
533 | |
|
534 | |
|
535 | |
public UMOEndpoint lookupEndpointByAddress(String address) |
536 | |
{ |
537 | 0 | UMOEndpoint endpoint = null; |
538 | 0 | if (address != null) |
539 | |
{ |
540 | 0 | boolean found = false; |
541 | 0 | Iterator iterator = endpoints.keySet().iterator(); |
542 | 0 | while (!found && iterator.hasNext()) |
543 | |
{ |
544 | 0 | endpoint = (UMOEndpoint) endpoints.get(iterator.next()); |
545 | 0 | found = (address.equals(endpoint.getEndpointURI().toString())); |
546 | |
} |
547 | |
} |
548 | 0 | return endpoint; |
549 | |
} |
550 | |
|
551 | |
|
552 | |
|
553 | |
|
554 | |
public UMOTransformer lookupTransformer(String name) |
555 | |
{ |
556 | 4 | UMOTransformer trans = (UMOTransformer) transformers.get(name); |
557 | 4 | if (trans != null) |
558 | |
{ |
559 | |
try |
560 | |
{ |
561 | 4 | return (UMOTransformer) trans.clone(); |
562 | |
} |
563 | 0 | catch (Exception e) |
564 | |
{ |
565 | 0 | throw new MuleRuntimeException(CoreMessages.failedToClone("Transformer: " + trans.getName()), |
566 | |
e); |
567 | |
} |
568 | |
} |
569 | 0 | return null; |
570 | |
} |
571 | |
|
572 | |
|
573 | |
|
574 | |
|
575 | |
public void registerConnector(UMOConnector connector) throws UMOException |
576 | |
{ |
577 | 46 | connectors.put(connector.getName(), connector); |
578 | 46 | if (initialised.get() || initialising.get()) |
579 | |
{ |
580 | 0 | connector.initialise(); |
581 | |
} |
582 | 46 | if ((started.get() || starting.get()) && !connector.isStarted()) |
583 | |
{ |
584 | 0 | connector.startConnector(); |
585 | |
} |
586 | 46 | } |
587 | |
|
588 | |
|
589 | |
|
590 | |
|
591 | |
public void unregisterConnector(String connectorName) throws UMOException |
592 | |
{ |
593 | 0 | UMOConnector c = (UMOConnector) connectors.remove(connectorName); |
594 | 0 | if (c != null) |
595 | |
{ |
596 | 0 | c.dispose(); |
597 | |
} |
598 | 0 | } |
599 | |
|
600 | |
|
601 | |
|
602 | |
|
603 | |
|
604 | |
|
605 | |
|
606 | |
public void registerEndpointIdentifier(String logicalName, String endpoint) |
607 | |
{ |
608 | 0 | endpointIdentifiers.put(logicalName, endpoint); |
609 | 0 | } |
610 | |
|
611 | |
|
612 | |
|
613 | |
|
614 | |
|
615 | |
|
616 | |
|
617 | |
public void unregisterEndpointIdentifier(String logicalName) |
618 | |
{ |
619 | 0 | endpointIdentifiers.remove(logicalName); |
620 | 0 | } |
621 | |
|
622 | |
|
623 | |
|
624 | |
|
625 | |
public void registerEndpoint(UMOEndpoint endpoint) |
626 | |
{ |
627 | 0 | endpoints.put(endpoint.getName(), endpoint); |
628 | 0 | } |
629 | |
|
630 | |
|
631 | |
|
632 | |
|
633 | |
public void unregisterEndpoint(String endpointName) |
634 | |
{ |
635 | 0 | UMOEndpoint p = (UMOEndpoint) endpoints.get(endpointName); |
636 | 0 | if (p != null) |
637 | |
{ |
638 | 0 | endpoints.remove(p); |
639 | |
} |
640 | 0 | } |
641 | |
|
642 | |
|
643 | |
|
644 | |
|
645 | |
public void registerTransformer(UMOTransformer transformer) throws InitialisationException |
646 | |
{ |
647 | 4 | transformer.initialise(); |
648 | 4 | transformers.put(transformer.getName(), transformer); |
649 | 4 | logger.info("Transformer " + transformer.getName() + " has been initialised successfully"); |
650 | 4 | } |
651 | |
|
652 | |
|
653 | |
|
654 | |
|
655 | |
public void unregisterTransformer(String transformerName) |
656 | |
{ |
657 | 0 | transformers.remove(transformerName); |
658 | 0 | } |
659 | |
|
660 | |
|
661 | |
|
662 | |
|
663 | |
public void setProperty(Object key, Object value) |
664 | |
{ |
665 | 392 | applicationProps.put(key, value); |
666 | 392 | } |
667 | |
|
668 | |
public void addProperties(Map props) |
669 | |
{ |
670 | 0 | applicationProps.putAll(props); |
671 | 0 | } |
672 | |
|
673 | |
|
674 | |
|
675 | |
|
676 | |
public void setTransactionManager(TransactionManager newManager) throws UMOException |
677 | |
{ |
678 | 0 | if (transactionManager != null) |
679 | |
{ |
680 | 0 | throw new ConfigurationException(CoreMessages.transactionManagerAlreadySet()); |
681 | |
} |
682 | 0 | transactionManager = newManager; |
683 | 0 | } |
684 | |
|
685 | |
|
686 | |
|
687 | |
|
688 | |
public synchronized void initialise() throws UMOException |
689 | |
{ |
690 | 44 | validateEncoding(); |
691 | 44 | validateOSEncoding(); |
692 | 44 | validateXML(); |
693 | |
|
694 | 44 | if (!initialised.get()) |
695 | |
{ |
696 | 44 | initialising.set(true); |
697 | 44 | startDate = System.currentTimeMillis(); |
698 | |
|
699 | 44 | if (workManager == null) |
700 | |
{ |
701 | 44 | ThreadingProfile tp = config.getDefaultThreadingProfile(); |
702 | 44 | logger.debug("Creating default work manager using default threading profile: " + tp); |
703 | 44 | workManager = new MuleWorkManager(tp, "UMOManager"); |
704 | 44 | workManager.start(); |
705 | |
} |
706 | |
|
707 | |
|
708 | 44 | notificationManager.start(workManager); |
709 | |
|
710 | |
|
711 | |
|
712 | |
|
713 | 44 | if (config.isEnableMessageEvents()) |
714 | |
{ |
715 | 0 | notificationManager.registerEventType(MessageNotification.class, |
716 | |
MessageNotificationListener.class); |
717 | |
} |
718 | |
|
719 | 44 | fireSystemEvent(new ManagerNotification(this, ManagerNotification.MANAGER_INITIALISNG)); |
720 | 44 | if (id == null) |
721 | |
{ |
722 | 0 | logger.warn("No unique id has been set on this manager"); |
723 | |
} |
724 | |
|
725 | |
try |
726 | |
{ |
727 | 44 | if (securityManager != null) |
728 | |
{ |
729 | 44 | securityManager.initialise(); |
730 | |
} |
731 | 44 | if (queueManager == null) |
732 | |
{ |
733 | |
try |
734 | |
{ |
735 | 44 | TransactionalQueueManager queueMgr = new TransactionalQueueManager(); |
736 | 44 | QueuePersistenceStrategy ps = getConfiguration().getPersistenceStrategy(); |
737 | 44 | queueMgr.setPersistenceStrategy(ps); |
738 | 44 | queueManager = queueMgr; |
739 | |
} |
740 | 0 | catch (Exception e) |
741 | |
{ |
742 | 0 | throw new InitialisationException(CoreMessages.initialisationFailure("QueueManager"), |
743 | |
e); |
744 | 44 | } |
745 | |
} |
746 | |
|
747 | 44 | initialiseConnectors(); |
748 | 44 | initialiseEndpoints(); |
749 | 44 | initialiseAgents(); |
750 | 44 | for (Iterator i = models.values().iterator(); i.hasNext();) |
751 | |
{ |
752 | 110 | UMOModel model = (UMOModel) i.next(); |
753 | 110 | model.initialise(); |
754 | 110 | } |
755 | |
|
756 | |
} |
757 | |
finally |
758 | |
{ |
759 | 44 | initialised.set(true); |
760 | 44 | initialising.set(false); |
761 | 44 | fireSystemEvent(new ManagerNotification(this, ManagerNotification.MANAGER_INITIALISED)); |
762 | 44 | } |
763 | |
} |
764 | 44 | } |
765 | |
|
766 | |
protected void validateEncoding() throws FatalException |
767 | |
{ |
768 | 44 | String encoding = System.getProperty(MuleProperties.MULE_ENCODING_SYSTEM_PROPERTY); |
769 | 44 | if (encoding == null) |
770 | |
{ |
771 | 2 | encoding = config.getEncoding(); |
772 | 2 | System.setProperty(MuleProperties.MULE_ENCODING_SYSTEM_PROPERTY, encoding); |
773 | |
} |
774 | |
else |
775 | |
{ |
776 | 42 | config.setEncoding(encoding); |
777 | |
} |
778 | |
|
779 | 44 | if (!Charset.isSupported(config.getEncoding())) |
780 | |
{ |
781 | 0 | throw new FatalException(CoreMessages.propertyHasInvalidValue("encoding", config.getEncoding()), |
782 | |
this); |
783 | |
} |
784 | 44 | } |
785 | |
|
786 | |
protected void validateOSEncoding() throws FatalException |
787 | |
{ |
788 | 44 | String encoding = System.getProperty(MuleProperties.MULE_OS_ENCODING_SYSTEM_PROPERTY); |
789 | 44 | if (encoding == null) |
790 | |
{ |
791 | 2 | encoding = config.getOSEncoding(); |
792 | 2 | System.setProperty(MuleProperties.MULE_OS_ENCODING_SYSTEM_PROPERTY, encoding); |
793 | |
} |
794 | |
else |
795 | |
{ |
796 | 42 | config.setOSEncoding(encoding); |
797 | |
} |
798 | |
|
799 | 44 | if (!Charset.isSupported(config.getOSEncoding())) |
800 | |
{ |
801 | 0 | throw new FatalException(CoreMessages.propertyHasInvalidValue("osEncoding", |
802 | |
config.getOSEncoding()), this); |
803 | |
} |
804 | 44 | } |
805 | |
|
806 | |
|
807 | |
|
808 | |
|
809 | |
|
810 | |
|
811 | |
|
812 | |
|
813 | |
|
814 | |
|
815 | |
|
816 | |
protected void validateXML() throws FatalException |
817 | |
{ |
818 | 44 | SAXParserFactory f = SAXParserFactory.newInstance(); |
819 | 44 | if (f == null || f.getClass().getName().indexOf("crimson") != -1) |
820 | |
{ |
821 | 0 | throw new FatalException(CoreMessages.valueIsInvalidFor(f.getClass().getName(), |
822 | |
"javax.xml.parsers.SAXParserFactory"), this); |
823 | |
} |
824 | 44 | } |
825 | |
|
826 | |
protected void registerAdminAgent() throws UMOException |
827 | |
{ |
828 | |
|
829 | |
|
830 | 44 | boolean disable = MapUtils.getBooleanValue(System.getProperties(), |
831 | |
MuleProperties.DISABLE_SERVER_CONNECTIONS_SYSTEM_PROPERTY, false); |
832 | |
|
833 | |
|
834 | 44 | if (StringUtils.isBlank(config.getServerUrl())) |
835 | |
{ |
836 | 44 | logger.info("Server endpointUri is null, not registering Mule Admin agent"); |
837 | 44 | disable = true; |
838 | |
} |
839 | |
|
840 | 44 | if (disable) |
841 | |
{ |
842 | 44 | unregisterAgent(MuleAdminAgent.AGENT_NAME); |
843 | |
} |
844 | |
else |
845 | |
{ |
846 | 0 | if (lookupAgent(MuleAdminAgent.AGENT_NAME) == null) |
847 | |
{ |
848 | 0 | registerAgent(new MuleAdminAgent()); |
849 | |
} |
850 | |
} |
851 | 44 | } |
852 | |
|
853 | |
protected void initialiseEndpoints() throws InitialisationException |
854 | |
{ |
855 | |
UMOEndpoint ep; |
856 | 44 | for (Iterator iterator = this.endpoints.values().iterator(); iterator.hasNext();) |
857 | |
{ |
858 | 0 | ep = (UMOEndpoint) iterator.next(); |
859 | 0 | ep.initialise(); |
860 | |
|
861 | |
|
862 | |
|
863 | 0 | ep.setCreateConnector(0); |
864 | |
} |
865 | 44 | } |
866 | |
|
867 | |
|
868 | |
|
869 | |
|
870 | |
|
871 | |
|
872 | |
|
873 | |
public synchronized void start() throws UMOException |
874 | |
{ |
875 | 44 | initialise(); |
876 | |
|
877 | 44 | if (!started.get()) |
878 | |
{ |
879 | 44 | starting.set(true); |
880 | 44 | fireSystemEvent(new ManagerNotification(this, ManagerNotification.MANAGER_STARTING)); |
881 | 44 | registerAdminAgent(); |
882 | 44 | if (queueManager != null) |
883 | |
{ |
884 | 44 | queueManager.start(); |
885 | |
} |
886 | 44 | startConnectors(); |
887 | 44 | startAgents(); |
888 | 44 | fireSystemEvent(new ManagerNotification(this, ManagerNotification.MANAGER_STARTING_MODELS)); |
889 | 44 | for (Iterator i = models.values().iterator(); i.hasNext();) |
890 | |
{ |
891 | 100 | UMOModel model = (UMOModel) i.next(); |
892 | 100 | model.start(); |
893 | 90 | } |
894 | 34 | fireSystemEvent(new ManagerNotification(this, ManagerNotification.MANAGER_STARTED_MODELS)); |
895 | |
|
896 | 34 | started.set(true); |
897 | 34 | starting.set(false); |
898 | 34 | if (logger.isInfoEnabled()) |
899 | |
{ |
900 | 0 | logger.info(this.getStartSplash()); |
901 | |
} |
902 | 34 | fireSystemEvent(new ManagerNotification(this, ManagerNotification.MANAGER_STARTED)); |
903 | |
} |
904 | 34 | } |
905 | |
|
906 | |
|
907 | |
|
908 | |
|
909 | |
|
910 | |
|
911 | |
|
912 | |
|
913 | |
public void start(String serverUrl) throws UMOException |
914 | |
{ |
915 | |
|
916 | 0 | config.setServerUrl(serverUrl); |
917 | 0 | start(); |
918 | 0 | } |
919 | |
|
920 | |
|
921 | |
|
922 | |
|
923 | |
|
924 | |
|
925 | |
private void startConnectors() throws UMOException |
926 | |
{ |
927 | 44 | for (Iterator iterator = connectors.values().iterator(); iterator.hasNext();) |
928 | |
{ |
929 | 22 | UMOConnector c = (UMOConnector) iterator.next(); |
930 | 22 | c.startConnector(); |
931 | 22 | } |
932 | 44 | logger.info("Connectors have been started successfully"); |
933 | 44 | } |
934 | |
|
935 | |
private void initialiseConnectors() throws InitialisationException |
936 | |
{ |
937 | 44 | for (Iterator iterator = connectors.values().iterator(); iterator.hasNext();) |
938 | |
{ |
939 | 22 | UMOConnector c = (UMOConnector) iterator.next(); |
940 | 22 | c.initialise(); |
941 | 22 | } |
942 | 44 | logger.info("Connectors have been initialised successfully"); |
943 | 44 | } |
944 | |
|
945 | |
|
946 | |
|
947 | |
|
948 | |
|
949 | |
|
950 | |
public synchronized void stop() throws UMOException |
951 | |
{ |
952 | 42 | started.set(false); |
953 | 42 | stopping.set(true); |
954 | 42 | fireSystemEvent(new ManagerNotification(this, ManagerNotification.MANAGER_STOPPING)); |
955 | |
|
956 | 42 | stopConnectors(); |
957 | 42 | stopAgents(); |
958 | |
|
959 | 42 | if (queueManager != null) |
960 | |
{ |
961 | 42 | queueManager.stop(); |
962 | |
} |
963 | |
|
964 | 42 | logger.debug("Stopping model..."); |
965 | 42 | fireSystemEvent(new ManagerNotification(this, ManagerNotification.MANAGER_STOPPING_MODELS)); |
966 | 42 | for (Iterator i = models.values().iterator(); i.hasNext();) |
967 | |
{ |
968 | 96 | UMOModel model = (UMOModel) i.next(); |
969 | 96 | model.stop(); |
970 | 96 | } |
971 | 42 | fireSystemEvent(new ManagerNotification(this, ManagerNotification.MANAGER_STOPPED_MODELS)); |
972 | |
|
973 | 42 | stopping.set(false); |
974 | 42 | initialised.set(false); |
975 | 42 | fireSystemEvent(new ManagerNotification(this, ManagerNotification.MANAGER_STOPPED)); |
976 | 42 | } |
977 | |
|
978 | |
|
979 | |
|
980 | |
|
981 | |
|
982 | |
|
983 | |
private void stopConnectors() throws UMOException |
984 | |
{ |
985 | 42 | logger.debug("Stopping connectors..."); |
986 | 42 | for (Iterator iterator = connectors.values().iterator(); iterator.hasNext();) |
987 | |
{ |
988 | 12 | UMOConnector c = (UMOConnector) iterator.next(); |
989 | 12 | c.stopConnector(); |
990 | 12 | } |
991 | 42 | logger.info("Connectors have been stopped successfully"); |
992 | 42 | } |
993 | |
|
994 | |
public UMOModel lookupModel(String name) |
995 | |
{ |
996 | 418 | return (UMOModel) models.get(name); |
997 | |
} |
998 | |
|
999 | |
public void registerModel(UMOModel model) throws UMOException |
1000 | |
{ |
1001 | 482 | models.put(model.getName(), model); |
1002 | 482 | if (initialised.get()) |
1003 | |
{ |
1004 | 0 | model.initialise(); |
1005 | |
} |
1006 | |
|
1007 | 482 | if (started.get()) |
1008 | |
{ |
1009 | 0 | model.start(); |
1010 | |
} |
1011 | 482 | } |
1012 | |
|
1013 | |
public void unregisterModel(String name) |
1014 | |
{ |
1015 | 0 | UMOModel model = lookupModel(name); |
1016 | 0 | if (model != null) |
1017 | |
{ |
1018 | 0 | models.remove(model.getName()); |
1019 | 0 | model.dispose(); |
1020 | |
} |
1021 | 0 | } |
1022 | |
|
1023 | |
public Map getModels() |
1024 | |
{ |
1025 | 2 | return Collections.unmodifiableMap(models); |
1026 | |
} |
1027 | |
|
1028 | |
|
1029 | |
|
1030 | |
|
1031 | |
public void registerInterceptorStack(String name, UMOInterceptorStack stack) |
1032 | |
{ |
1033 | 0 | interceptorsMap.put(name, stack); |
1034 | 0 | } |
1035 | |
|
1036 | |
|
1037 | |
|
1038 | |
|
1039 | |
public UMOInterceptorStack lookupInterceptorStack(String name) |
1040 | |
{ |
1041 | 0 | return (UMOInterceptorStack) interceptorsMap.get(name); |
1042 | |
} |
1043 | |
|
1044 | |
|
1045 | |
|
1046 | |
|
1047 | |
public Map getConnectors() |
1048 | |
{ |
1049 | 76 | return Collections.unmodifiableMap(connectors); |
1050 | |
} |
1051 | |
|
1052 | |
|
1053 | |
|
1054 | |
|
1055 | |
|
1056 | |
|
1057 | |
|
1058 | |
public Map getEndpointIdentifiers() |
1059 | |
{ |
1060 | 0 | return Collections.unmodifiableMap(endpointIdentifiers); |
1061 | |
} |
1062 | |
|
1063 | |
|
1064 | |
|
1065 | |
|
1066 | |
public Map getEndpoints() |
1067 | |
{ |
1068 | 0 | return Collections.unmodifiableMap(endpoints); |
1069 | |
} |
1070 | |
|
1071 | |
|
1072 | |
|
1073 | |
|
1074 | |
public Map getTransformers() |
1075 | |
{ |
1076 | 0 | return Collections.unmodifiableMap(transformers); |
1077 | |
} |
1078 | |
|
1079 | |
|
1080 | |
|
1081 | |
|
1082 | |
public boolean isStarted() |
1083 | |
{ |
1084 | 22 | return started.get(); |
1085 | |
} |
1086 | |
|
1087 | |
|
1088 | |
|
1089 | |
|
1090 | |
public boolean isInitialised() |
1091 | |
{ |
1092 | 0 | return initialised.get(); |
1093 | |
} |
1094 | |
|
1095 | |
|
1096 | |
|
1097 | |
|
1098 | |
|
1099 | |
|
1100 | |
public boolean isInitialising() |
1101 | |
{ |
1102 | 0 | return initialising.get(); |
1103 | |
} |
1104 | |
|
1105 | |
|
1106 | |
|
1107 | |
|
1108 | |
public boolean isStopping() |
1109 | |
{ |
1110 | 0 | return stopping.get(); |
1111 | |
} |
1112 | |
|
1113 | |
|
1114 | |
|
1115 | |
|
1116 | |
public long getStartDate() |
1117 | |
{ |
1118 | 0 | return startDate; |
1119 | |
} |
1120 | |
|
1121 | |
|
1122 | |
|
1123 | |
|
1124 | |
|
1125 | |
|
1126 | |
|
1127 | |
|
1128 | |
private String getStartSplash() |
1129 | |
{ |
1130 | 0 | String notset = CoreMessages.notSet().getMessage(); |
1131 | |
|
1132 | |
|
1133 | 0 | List message = new ArrayList(); |
1134 | 0 | message.add(StringUtils.defaultString(MuleManifest.getProductDescription(), notset)); |
1135 | 0 | message.add(CoreMessages.version().getMessage() + " " |
1136 | |
+ StringUtils.defaultString(MuleManifest.getProductVersion(), notset) + " Build: " |
1137 | |
+ StringUtils.defaultString(MuleManifest.getBuildNumber(), notset)); |
1138 | 0 | message.add(StringUtils.defaultString(MuleManifest.getVendorName(), notset)); |
1139 | 0 | message.add(StringUtils.defaultString(MuleManifest.getProductMoreInfo(), notset)); |
1140 | 0 | message.add(" "); |
1141 | 0 | message.add(CoreMessages.serverStartedAt(this.getStartDate())); |
1142 | 0 | message.add("Server ID: " + id); |
1143 | |
|
1144 | |
|
1145 | 0 | message.add("JDK: " + System.getProperty("java.version") + " (" + System.getProperty("java.vm.info") |
1146 | |
+ ")"); |
1147 | 0 | String patch = System.getProperty("sun.os.patch.level", null); |
1148 | 0 | message.add("OS: " + System.getProperty("os.name") |
1149 | |
+ (patch != null && !"unknown".equalsIgnoreCase(patch) ? " - " + patch : "") + " (" |
1150 | |
+ System.getProperty("os.version") + ", " + System.getProperty("os.arch") + ")"); |
1151 | |
try |
1152 | |
{ |
1153 | 0 | InetAddress host = InetAddress.getLocalHost(); |
1154 | 0 | message.add("Host: " + host.getHostName() + " (" + host.getHostAddress() + ")"); |
1155 | |
} |
1156 | 0 | catch (UnknownHostException e) |
1157 | |
{ |
1158 | |
|
1159 | 0 | } |
1160 | |
|
1161 | |
|
1162 | 0 | message.add(" "); |
1163 | 0 | if (agents.size() == 0) |
1164 | |
{ |
1165 | 0 | message.add(CoreMessages.agentsRunning().getMessage() + " " + CoreMessages.none()); |
1166 | |
} |
1167 | |
else |
1168 | |
{ |
1169 | 0 | message.add(CoreMessages.agentsRunning()); |
1170 | |
UMOAgent umoAgent; |
1171 | 0 | for (Iterator iterator = agents.values().iterator(); iterator.hasNext();) |
1172 | |
{ |
1173 | 0 | umoAgent = (UMOAgent) iterator.next(); |
1174 | 0 | message.add(" " + umoAgent.getDescription()); |
1175 | |
} |
1176 | |
} |
1177 | 0 | return StringMessageUtils.getBoilerPlate(message, '*', 70); |
1178 | |
} |
1179 | |
|
1180 | |
private String getEndSplash() |
1181 | |
{ |
1182 | 0 | List message = new ArrayList(2); |
1183 | 0 | long currentTime = System.currentTimeMillis(); |
1184 | 0 | message.add(CoreMessages.shutdownNormally(new Date())); |
1185 | 0 | long duration = 10; |
1186 | 0 | if (startDate > 0) |
1187 | |
{ |
1188 | 0 | duration = currentTime - startDate; |
1189 | |
} |
1190 | 0 | message.add(CoreMessages.serverWasUpForDuration(duration)); |
1191 | |
|
1192 | 0 | return StringMessageUtils.getBoilerPlate(message, '*', 78); |
1193 | |
} |
1194 | |
|
1195 | |
|
1196 | |
|
1197 | |
|
1198 | |
public void registerAgent(UMOAgent agent) throws UMOException |
1199 | |
{ |
1200 | 0 | agents.put(agent.getName(), agent); |
1201 | 0 | agent.registered(); |
1202 | |
|
1203 | |
|
1204 | |
|
1205 | 0 | if (initialised.get()) |
1206 | |
{ |
1207 | 0 | agent.initialise(); |
1208 | |
} |
1209 | 0 | if ((started.get() || starting.get())) |
1210 | |
{ |
1211 | 0 | agent.start(); |
1212 | |
} |
1213 | 0 | } |
1214 | |
|
1215 | |
public UMOAgent lookupAgent(String name) |
1216 | |
{ |
1217 | 0 | return (UMOAgent) agents.get(name); |
1218 | |
} |
1219 | |
|
1220 | |
|
1221 | |
|
1222 | |
|
1223 | |
public UMOAgent unregisterAgent(String name) throws UMOException |
1224 | |
{ |
1225 | 46 | if (name == null) |
1226 | |
{ |
1227 | 0 | return null; |
1228 | |
} |
1229 | 46 | UMOAgent agent = (UMOAgent) agents.remove(name); |
1230 | 46 | if (agent != null) |
1231 | |
{ |
1232 | 0 | agent.dispose(); |
1233 | 0 | agent.unregistered(); |
1234 | |
} |
1235 | 46 | return agent; |
1236 | |
} |
1237 | |
|
1238 | |
|
1239 | |
|
1240 | |
|
1241 | |
|
1242 | |
|
1243 | |
protected void initialiseAgents() throws InitialisationException |
1244 | |
{ |
1245 | 44 | logger.info("Initialising agents..."); |
1246 | |
|
1247 | |
|
1248 | |
|
1249 | |
|
1250 | |
|
1251 | |
|
1252 | 44 | Collection agentsSnapshot = agents.values(); |
1253 | 44 | CursorableLinkedList agentRegistrationQueue = new CursorableLinkedList(agentsSnapshot); |
1254 | 44 | CursorableLinkedList.Cursor cursor = agentRegistrationQueue.cursor(); |
1255 | |
|
1256 | |
|
1257 | |
|
1258 | |
|
1259 | |
try |
1260 | |
{ |
1261 | 44 | while (cursor.hasNext()) |
1262 | |
{ |
1263 | 0 | UMOAgent umoAgent = (UMOAgent) cursor.next(); |
1264 | |
|
1265 | 0 | int originalSize = agentsSnapshot.size(); |
1266 | 0 | logger.debug("Initialising agent: " + umoAgent.getName()); |
1267 | 0 | umoAgent.initialise(); |
1268 | |
|
1269 | 0 | cursor.remove(); |
1270 | |
|
1271 | |
|
1272 | |
|
1273 | |
|
1274 | 0 | int newSize = agentsSnapshot.size(); |
1275 | 0 | int delta = newSize - originalSize; |
1276 | 0 | if (delta > 0) |
1277 | |
{ |
1278 | |
|
1279 | |
|
1280 | |
|
1281 | 0 | Collection tail = CollectionUtils.retainAll(agentsSnapshot, agentRegistrationQueue); |
1282 | 0 | Collection head = CollectionUtils.subtract(agentsSnapshot, tail); |
1283 | |
|
1284 | |
|
1285 | |
|
1286 | |
|
1287 | |
|
1288 | 0 | agentRegistrationQueue.clear(); |
1289 | |
|
1290 | 0 | agentRegistrationQueue.addAll(head); |
1291 | |
|
1292 | 0 | agentRegistrationQueue.addAll(tail); |
1293 | |
|
1294 | |
|
1295 | |
|
1296 | |
|
1297 | 0 | this.agents.clear(); |
1298 | 0 | for (Iterator it = agentRegistrationQueue.iterator(); it.hasNext();) |
1299 | |
{ |
1300 | 0 | UMOAgent theAgent = (UMOAgent) it.next(); |
1301 | 0 | this.agents.put(theAgent.getName(), theAgent); |
1302 | 0 | } |
1303 | |
} |
1304 | 0 | } |
1305 | |
} |
1306 | |
finally |
1307 | |
{ |
1308 | |
|
1309 | 44 | cursor.close(); |
1310 | 44 | } |
1311 | 44 | logger.info("Agents Successfully Initialised"); |
1312 | 44 | } |
1313 | |
|
1314 | |
|
1315 | |
|
1316 | |
|
1317 | |
protected void startAgents() throws UMOException |
1318 | |
{ |
1319 | |
UMOAgent umoAgent; |
1320 | 44 | logger.info("Starting agents..."); |
1321 | 44 | for (Iterator iterator = agents.values().iterator(); iterator.hasNext();) |
1322 | |
{ |
1323 | 0 | umoAgent = (UMOAgent) iterator.next(); |
1324 | 0 | logger.info("Starting agent: " + umoAgent.getDescription()); |
1325 | 0 | umoAgent.start(); |
1326 | |
|
1327 | |
} |
1328 | 44 | logger.info("Agents Successfully Started"); |
1329 | 44 | } |
1330 | |
|
1331 | |
|
1332 | |
|
1333 | |
|
1334 | |
protected void stopAgents() throws UMOException |
1335 | |
{ |
1336 | 42 | logger.info("Stopping agents..."); |
1337 | 42 | for (Iterator iterator = agents.values().iterator(); iterator.hasNext();) |
1338 | |
{ |
1339 | 0 | UMOAgent umoAgent = (UMOAgent) iterator.next(); |
1340 | 0 | logger.debug("Stopping agent: " + umoAgent.getName()); |
1341 | 0 | umoAgent.stop(); |
1342 | 0 | } |
1343 | 42 | logger.info("Agents Successfully Stopped"); |
1344 | 42 | } |
1345 | |
|
1346 | |
|
1347 | |
|
1348 | |
|
1349 | |
protected void disposeAgents() |
1350 | |
{ |
1351 | |
UMOAgent umoAgent; |
1352 | 392 | logger.info("disposing agents..."); |
1353 | 392 | for (Iterator iterator = agents.values().iterator(); iterator.hasNext();) |
1354 | |
{ |
1355 | 0 | umoAgent = (UMOAgent) iterator.next(); |
1356 | 0 | logger.debug("Disposing agent: " + umoAgent.getName()); |
1357 | 0 | umoAgent.dispose(); |
1358 | |
} |
1359 | 392 | logger.info("Agents Successfully Disposed"); |
1360 | 392 | } |
1361 | |
|
1362 | |
|
1363 | |
|
1364 | |
|
1365 | |
|
1366 | |
|
1367 | |
|
1368 | |
|
1369 | |
|
1370 | |
|
1371 | |
public void setContainerContext(UMOContainerContext container) throws UMOException |
1372 | |
{ |
1373 | 0 | if (container == null) |
1374 | |
{ |
1375 | 0 | if (containerContext != null) |
1376 | |
{ |
1377 | 0 | containerContext.dispose(); |
1378 | |
} |
1379 | 0 | containerContext = new MultiContainerContext(); |
1380 | |
} |
1381 | |
else |
1382 | |
{ |
1383 | 0 | container.initialise(); |
1384 | 0 | containerContext.addContainer(container); |
1385 | |
} |
1386 | 0 | } |
1387 | |
|
1388 | |
|
1389 | |
|
1390 | |
|
1391 | |
|
1392 | |
|
1393 | |
|
1394 | |
public UMOContainerContext getContainerContext() |
1395 | |
{ |
1396 | 70 | return containerContext; |
1397 | |
} |
1398 | |
|
1399 | |
|
1400 | |
|
1401 | |
|
1402 | |
public void registerListener(UMOServerNotificationListener l) throws NotificationException |
1403 | |
{ |
1404 | 18 | registerListener(l, null); |
1405 | 18 | } |
1406 | |
|
1407 | |
public void registerListener(UMOServerNotificationListener l, String resourceIdentifier) |
1408 | |
throws NotificationException |
1409 | |
{ |
1410 | 24 | if (notificationManager == null) |
1411 | |
{ |
1412 | 0 | throw new NotificationException(CoreMessages.serverEventManagerNotEnabled()); |
1413 | |
} |
1414 | 24 | notificationManager.registerListener(l, resourceIdentifier); |
1415 | 24 | } |
1416 | |
|
1417 | |
|
1418 | |
|
1419 | |
|
1420 | |
public void unregisterListener(UMOServerNotificationListener l) |
1421 | |
{ |
1422 | 4 | if (notificationManager != null) |
1423 | |
{ |
1424 | 4 | notificationManager.unregisterListener(l); |
1425 | |
} |
1426 | 4 | } |
1427 | |
|
1428 | |
|
1429 | |
|
1430 | |
|
1431 | |
|
1432 | |
|
1433 | |
|
1434 | |
|
1435 | |
protected void fireSystemEvent(UMOServerNotification e) |
1436 | |
{ |
1437 | 1588 | if (notificationManager != null) |
1438 | |
{ |
1439 | 1588 | notificationManager.fireEvent(e); |
1440 | |
} |
1441 | 0 | else if (logger.isDebugEnabled()) |
1442 | |
{ |
1443 | 0 | logger.debug("Event Manager is not enabled, ignoring event: " + e); |
1444 | |
} |
1445 | 1588 | } |
1446 | |
|
1447 | |
|
1448 | |
|
1449 | |
|
1450 | |
|
1451 | |
|
1452 | |
|
1453 | |
|
1454 | |
|
1455 | |
|
1456 | |
|
1457 | |
|
1458 | |
|
1459 | |
public void fireNotification(UMOServerNotification notification) |
1460 | |
{ |
1461 | |
|
1462 | 1876 | if (notificationManager != null) |
1463 | |
{ |
1464 | 1876 | notificationManager.fireEvent(notification); |
1465 | |
} |
1466 | 0 | else if (logger.isDebugEnabled()) |
1467 | |
{ |
1468 | 0 | logger.debug("Event Manager is not enabled, ignoring notification: " + notification); |
1469 | |
} |
1470 | |
|
1471 | |
|
1472 | |
|
1473 | |
|
1474 | 1876 | } |
1475 | |
|
1476 | |
public void setId(String id) |
1477 | |
{ |
1478 | 0 | this.id = id; |
1479 | 0 | } |
1480 | |
|
1481 | |
public String getId() |
1482 | |
{ |
1483 | 5052 | return id; |
1484 | |
} |
1485 | |
|
1486 | |
|
1487 | |
|
1488 | |
|
1489 | |
|
1490 | |
|
1491 | |
|
1492 | |
|
1493 | |
|
1494 | |
public void setSecurityManager(UMOSecurityManager securityManager) throws InitialisationException |
1495 | |
{ |
1496 | 0 | this.securityManager = securityManager; |
1497 | 0 | if (securityManager != null && isInitialised()) |
1498 | |
{ |
1499 | 0 | this.securityManager.initialise(); |
1500 | |
} |
1501 | 0 | } |
1502 | |
|
1503 | |
|
1504 | |
|
1505 | |
|
1506 | |
|
1507 | |
|
1508 | |
|
1509 | |
|
1510 | |
public UMOSecurityManager getSecurityManager() |
1511 | |
{ |
1512 | 0 | return securityManager; |
1513 | |
} |
1514 | |
|
1515 | |
|
1516 | |
|
1517 | |
|
1518 | |
|
1519 | |
|
1520 | |
|
1521 | |
|
1522 | |
|
1523 | |
|
1524 | |
|
1525 | |
|
1526 | |
|
1527 | |
|
1528 | |
|
1529 | |
public UMOWorkManager getWorkManager() |
1530 | |
{ |
1531 | 0 | return workManager; |
1532 | |
} |
1533 | |
|
1534 | |
|
1535 | |
|
1536 | |
|
1537 | |
|
1538 | |
|
1539 | |
|
1540 | |
|
1541 | |
|
1542 | |
|
1543 | |
|
1544 | |
|
1545 | |
|
1546 | |
|
1547 | |
|
1548 | |
|
1549 | |
|
1550 | |
public void setWorkManager(UMOWorkManager workManager) |
1551 | |
{ |
1552 | 0 | if (this.workManager != null) |
1553 | |
{ |
1554 | 0 | throw new IllegalStateException(CoreMessages.cannotSetObjectOnceItHasBeenSet("workManager") |
1555 | |
.getMessage()); |
1556 | |
} |
1557 | 0 | this.workManager = workManager; |
1558 | 0 | } |
1559 | |
|
1560 | |
public QueueManager getQueueManager() |
1561 | |
{ |
1562 | 107 | return queueManager; |
1563 | |
} |
1564 | |
|
1565 | |
public void setQueueManager(QueueManager queueManager) |
1566 | |
{ |
1567 | 2 | this.queueManager = queueManager; |
1568 | 2 | } |
1569 | |
} |