View Javadoc

1   /*
2    * Copyright 2006-2009 the original author or authors. Licensed under the Apache
3    * License, Version 2.0 (the "License"); you may not use this file except in
4    * compliance with the License. You may obtain a copy of the License at
5    * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law
6    * or agreed to in writing, software distributed under the License is
7    * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
8    * KIND, either express or implied. See the License for the specific language
9    * governing permissions and limitations under the License.
10   */
11  
12  package org.springframework.osgi.context;
13  
14  import org.springframework.osgi.context.event.OsgiBundleApplicationContextEventMulticaster;
15  
16  /**
17   * Interface that redirect the application context crucial methods to a third
18   * party executor to allow the initialization to be executed in stages. The
19   * interface splits the <code>refresh</code> method in two parts:
20   * {@link #startRefresh()} and {@link #completeRefresh()}.
21   * 
22   * <p/><strong>Note:</strong> This interface is intended for usage only inside
23   * Spring-DM framework. Relying on this interface is highly discouraged.
24   * 
25   * @see DependencyAwareBeanFactoryPostProcessor
26   * @see DependencyInitializationAwareBeanPostProcessor
27   * @author Costin Leau
28   */
29  public interface DelegatedExecutionOsgiBundleApplicationContext extends ConfigurableOsgiBundleApplicationContext {
30  
31  	/**
32  	 * Non-delegated refresh operation (execute {@link #refresh} in the
33  	 * <em>traditional</em> way).
34  	 * 
35  	 * @see org.springframework.context.ConfigurableApplicationContext#refresh()
36  	 */
37  	void normalRefresh();
38  
39  	/**
40  	 * Non-delegated close operation (execute {@link #close} in the
41  	 * <em>traditional</em> way).
42  	 * 
43  	 * @see org.springframework.context.ConfigurableApplicationContext#close()
44  	 */
45  	void normalClose();
46  
47  	/**
48  	 * First phase of the refresh. Normally, this just prepares the
49  	 * <code>beanFactory</code> but does not instantiates any beans.
50  	 */
51  	void startRefresh();
52  
53  	/**
54  	 * The second, last phase of the refresh. Executes after a certain
55  	 * condition, imposed by the executor, has been met. Finishes the rest of
56  	 * the <code>refresh</code> operation. Normally, this operations performs
57  	 * most of the <code>refresh work</code>, such as instantiating
58  	 * singletons.
59  	 */
60  	void completeRefresh();
61  
62  	/**
63  	 * Assigns the {@link OsgiBundleApplicationContextExecutor} for this
64  	 * delegated context.
65  	 * 
66  	 * @param executor the executor of this application context, to which the
67  	 *        <code>refresh</code> method is delegated to
68  	 */
69  	void setExecutor(OsgiBundleApplicationContextExecutor executor);
70  
71  	/**
72  	 * Allows a delegated {@link OsgiBundleApplicationContextEventMulticaster},
73  	 * external to the application context, to be used for sending OSGi
74  	 * application context events regarding the application context life cycle.
75  	 * This method is mainly intended for monitoring the context lifecycle by
76  	 * third parties (such as the OSGi extender). It's up to the implementation
77  	 * to decide whether this setter method is required or not.
78  	 * 
79  	 * @param multicaster the application multicaster used for sending events
80  	 *        triggered by the delegated execution.
81  	 * @see org.springframework.osgi.context.event.OsgiBundleApplicationContextEvent
82  	 */
83  	void setDelegatedEventMulticaster(OsgiBundleApplicationContextEventMulticaster multicaster);
84  
85  	/**
86  	 * Returns the OSGi event multicaster (if any) associated with this
87  	 * application context.
88  	 * 
89  	 * @return the OSGi event multicaster associated with this context
90  	 */
91  	OsgiBundleApplicationContextEventMulticaster getDelegatedEventMulticaster();
92  }