View Javadoc

1   /*
2    * Copyright 2006-2008 the original author or authors.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.springframework.osgi.context.event;
18  
19  /**
20   * Interface to be implemented by objects that can manage a number of
21   * {@link OsgiBundleApplicationContextListener}s, and publish events to them.
22   * 
23   * <p/> The contract of this interface is very similar to that of
24   * {@link org.springframework.context.event.ApplicationEventMulticaster} except
25   * the type of listeners this multicaster can handle. Different from the
26   * aforementioned class, this interface is used for broadcasting life cycle
27   * events of application contexts started inside an OSGi environment, to outside
28   * entities. This normally implies that the entities as well as the multicaster
29   * are not managed by the application context triggering the event (so that a
30   * destruction event can be properly propagated).
31   * 
32   * @see org.springframework.context.event.ApplicationEventMulticaster
33   * 
34   * @author Costin Leau
35   */
36  public interface OsgiBundleApplicationContextEventMulticaster {
37  
38  	/**
39  	 * Add an OSGi listener to be notified of all events.
40  	 * 
41  	 * @param osgiListener the listener to add
42  	 */
43  	void addApplicationListener(OsgiBundleApplicationContextListener osgiListener);
44  
45  	/**
46  	 * Remove an OSGi listener from the notification list.
47  	 * 
48  	 * @param osgiListener the listener to remove
49  	 */
50  	void removeApplicationListener(OsgiBundleApplicationContextListener osgiListener);
51  
52  	/**
53  	 * Remove all listeners registered with this multicaster. It will perform no
54  	 * action on event notification until more listeners are registered.
55  	 */
56  	void removeAllListeners();
57  
58  	/**
59  	 * Multicast the given application event to appropriate listeners.
60  	 * 
61  	 * @param osgiListener the event to multicast
62  	 */
63  	void multicastEvent(OsgiBundleApplicationContextEvent osgiListener);
64  }