1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.springframework.osgi.extender.internal.activator;
18
19 import java.util.Iterator;
20 import java.util.List;
21
22 import org.springframework.osgi.context.event.OsgiBundleApplicationContextEvent;
23 import org.springframework.osgi.context.event.OsgiBundleApplicationContextListener;
24 import org.springframework.util.Assert;
25
26 /**
27 * Listener interface that delegates to a list of listener. This is useful in
28 * OSGi environments when dealing with dynamic collections which can be updated
29 * during iteration.
30 *
31 * @author Costin Leau
32 *
33 */
34 class ListListenerAdapter implements OsgiBundleApplicationContextListener {
35
36 private final List listeners;
37
38
39 /**
40 * Constructs a new <code>ListListenerAdapter</code> instance.
41 *
42 * @param listeners
43 */
44 public ListListenerAdapter(List listeners) {
45 Assert.notNull(listeners);
46 this.listeners = listeners;
47 }
48
49 public void onOsgiApplicationEvent(OsgiBundleApplicationContextEvent event) {
50 for (Iterator iterator = listeners.iterator(); iterator.hasNext();) {
51 OsgiBundleApplicationContextListener osgiListener = (OsgiBundleApplicationContextListener) iterator.next();
52 osgiListener.onOsgiApplicationEvent(event);
53 }
54 }
55 }