01: package org.objectweb.celtix.bus.busimpl;
02:
03: import java.util.ArrayList;
04: import java.util.List;
05:
06: import org.objectweb.celtix.buslifecycle.BusLifeCycleListener;
07: import org.objectweb.celtix.buslifecycle.BusLifeCycleManager;
08:
09: public class CeltixBusLifeCycleManager implements BusLifeCycleManager {
10:
11: private final List<BusLifeCycleListener> listeners;
12:
13: public CeltixBusLifeCycleManager() {
14: listeners = new ArrayList<BusLifeCycleListener>();
15: }
16:
17: /* (non-Javadoc)
18: * @see org.objectweb.celtix.buslifecycle.BusLifeCycleManager#registerLifeCycleListener(
19: * org.objectweb.celtix.buslifecycle.BusLifeCycleListener)
20: */
21: public void registerLifeCycleListener(BusLifeCycleListener listener) {
22: listeners.add(listener);
23:
24: }
25:
26: /* (non-Javadoc)
27: * @see org.objectweb.celtix.buslifecycle.BusLifeCycleManager#unregisterLifeCycleListener(
28: * org.objectweb.celtix.buslifecycle.BusLifeCycleListener)
29: */
30: public void unregisterLifeCycleListener(
31: BusLifeCycleListener listener) {
32: listeners.remove(listener);
33: }
34:
35: void initComplete() {
36: for (BusLifeCycleListener listener : listeners) {
37: listener.initComplete();
38: }
39: }
40:
41: void preShutdown() {
42: // TODO inverse order of registration?
43: for (BusLifeCycleListener listener : listeners) {
44: listener.preShutdown();
45: }
46: }
47:
48: void postShutdown() {
49: // TODO inverse order of registration?
50: for (BusLifeCycleListener listener : listeners) {
51: listener.postShutdown();
52: }
53: }
54:
55: }
|