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; 18 19 import org.springframework.osgi.context.event.OsgiBundleApplicationContextEventMulticaster; 20 21 /** 22 * Interface that redirect the application context crucial methods to a third 23 * party executor to allow the initialization to be executed in stages. 24 * 25 * The interface splits the <code>refresh</code> method in two parts: 26 * {@link #startRefresh()} and {@link #completeRefresh()}. 27 * 28 * <p/><strong>Note:</strong> This interface is intended for usage only inside 29 * Spring-DM framework. Relying on this interface is highly discouraged. 30 * 31 * @author Costin Leau 32 */ 33 public interface DelegatedExecutionOsgiBundleApplicationContext extends ConfigurableOsgiBundleApplicationContext { 34 35 /** 36 * Non-delegated refresh operation (execute {@link #refresh} in the 37 * <em>traditional</em> way). 38 * 39 * @see org.springframework.context.ConfigurableApplicationContext#refresh() 40 */ 41 void normalRefresh(); 42 43 /** 44 * Non-delegated close operation (execute {@link #close} in the 45 * <em>traditional</em> way). 46 * 47 * @see org.springframework.context.ConfigurableApplicationContext#close() 48 */ 49 void normalClose(); 50 51 /** 52 * First phase of the refresh. Normally, this just prepares the 53 * <code>beanFactory</code> but does not instantiates any beans. 54 */ 55 void startRefresh(); 56 57 /** 58 * The second, last phase of the refresh. Executes after a certain 59 * condition, imposed by the executor, has been met. Finishes the rest of 60 * the <code>refresh</code> operation. Normally, this operations performs 61 * most of the <code>refresh work</code>, such as instantiating 62 * singletons. 63 */ 64 void completeRefresh(); 65 66 /** 67 * Assigns the {@link OsgiBundleApplicationContextExecutor} for this 68 * delegated context. 69 * 70 * @param executor the executor of this application context, to which the 71 * <code>refresh</code> method is delegated to 72 */ 73 void setExecutor(OsgiBundleApplicationContextExecutor executor); 74 75 /** 76 * Synchronization monitor for this 77 * {@link org.springframework.context.ApplicationContext} in case multiple 78 * threads can work with the application context lifecycle. 79 * 80 * @return monitor for this application context. 81 */ 82 Object getMonitor(); 83 84 /** 85 * Allows a delegated {@link OsgiBundleApplicationContextEventMulticaster}, 86 * external to the application context, to be used for sending OSGi 87 * application context events regarding the application context life cycle. 88 * This method is mainly intended for monitoring the context lifecycle by 89 * third parties (such as the OSGi extender). It's up to the implementation 90 * to decide whether this setter method is required or not. 91 * 92 * @param multicaster the application multicaster used for sending events 93 * triggered by the delegated execution. 94 * 95 * @see org.springframework.osgi.context.event.OsgiBundleApplicationContextEvent 96 */ 97 void setDelegatedEventMulticaster(OsgiBundleApplicationContextEventMulticaster multicaster); 98 99 /** 100 * Returns the OSGi event multicaster (if any) associated with this 101 * application context. 102 * 103 * @return the OSGi event multicaster associated with this context 104 */ 105 OsgiBundleApplicationContextEventMulticaster getDelegatedEventMulticaster(); 106 }