org.springframework.osgi.context.support
Class AbstractDelegatedExecutionApplicationContext

java.lang.Object
  extended by org.springframework.core.io.DefaultResourceLoader
      extended by org.springframework.context.support.AbstractApplicationContext
          extended by org.springframework.context.support.AbstractRefreshableApplicationContext
              extended by org.springframework.osgi.context.support.AbstractOsgiBundleApplicationContext
                  extended by org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext
All Implemented Interfaces:
BeanFactory, DisposableBean, HierarchicalBeanFactory, ListableBeanFactory, ApplicationContext, ApplicationEventPublisher, ConfigurableApplicationContext, Lifecycle, MessageSource, ResourceLoader, ResourcePatternResolver, ConfigurableOsgiBundleApplicationContext, DelegatedExecutionOsgiBundleApplicationContext
Direct Known Subclasses:
OsgiBundleXmlApplicationContext

public abstract class AbstractDelegatedExecutionApplicationContext
extends AbstractOsgiBundleApplicationContext
implements DelegatedExecutionOsgiBundleApplicationContext

OSGi-specific application context that delegates the execution of its lifecycle methods to a different class. The main reason behind this is to break the startup of the application context in steps that can be executed asynchronously.

The refresh() and AbstractApplicationContext.close() methods delegate their execution to an OsgiBundleApplicationContextExecutor class that chooses how to call the lifecycle methods.

One can still call the 'traditional' lifecycle methods through normalRefresh() and normalClose().

Author:
Costin Leau
See Also:
DelegatedExecutionOsgiBundleApplicationContext

Field Summary
 
Fields inherited from class org.springframework.context.support.AbstractApplicationContext
APPLICATION_EVENT_MULTICASTER_BEAN_NAME, logger, MESSAGE_SOURCE_BEAN_NAME
 
Fields inherited from interface org.springframework.osgi.context.ConfigurableOsgiBundleApplicationContext
APPLICATION_CONTEXT_SERVICE_PROPERTY_NAME, BUNDLE_CONTEXT_BEAN_NAME
 
Fields inherited from interface org.springframework.context.ConfigurableApplicationContext
CONFIG_LOCATION_DELIMITERS, LOAD_TIME_WEAVER_BEAN_NAME
 
Fields inherited from interface org.springframework.beans.factory.BeanFactory
FACTORY_BEAN_PREFIX
 
Fields inherited from interface org.springframework.beans.factory.BeanFactory
FACTORY_BEAN_PREFIX
 
Fields inherited from interface org.springframework.core.io.support.ResourcePatternResolver
CLASSPATH_ALL_URL_PREFIX
 
Fields inherited from interface org.springframework.core.io.ResourceLoader
CLASSPATH_URL_PREFIX
 
Constructor Summary
AbstractDelegatedExecutionApplicationContext()
          Create a new AbstractDelegatedExecutionApplicationContext with no parent.
AbstractDelegatedExecutionApplicationContext(ApplicationContext parent)
          Create a new AbstractDelegatedExecutionApplicationContext with the given parent context.
 
Method Summary
protected  void cancelRefresh(BeansException ex)
           
 void completeRefresh()
          The second, last phase of the refresh.
protected  void doClose()
          Unregister the ApplicationContext OSGi service (in case there is any).
protected  void finishRefresh()
           
 Object getMonitor()
          Synchronization monitor for this ApplicationContext in case multiple threads can work with the application context lifecycle.
 void normalClose()
          Non-delegated close operation (execute ConfigurableApplicationContext.close() in the traditional way).
 void normalRefresh()
          Non-delegated refresh operation (execute ConfigurableApplicationContext.refresh() in the traditional way).
 void refresh()
          Delegate execution of refresh method to a third party.
 void setDelegatedEventMulticaster(ApplicationEventMulticaster multicaster)
          Allows a delegated ApplicationEventMulticaster, external to the application contex, to be used for sending events OSGi application context events regarding the application context lifecycle.
 void setExecutor(OsgiBundleApplicationContextExecutor executor)
          Assigns the OsgiBundleApplicationContextExecutor for this delegated context.
 void startRefresh()
          First phase of the refresh.
 
Methods inherited from class org.springframework.osgi.context.support.AbstractOsgiBundleApplicationContext
destroyBeans, getBundle, getBundleContext, getClassLoader, getConfigLocations, getDefaultConfigLocations, getResource, getResourceByPath, getResourcePatternResolver, getResources, postProcessBeanFactory, setBundleContext, setClassLoader, setConfigLocations, setPublishContextAsService
 
Methods inherited from class org.springframework.context.support.AbstractRefreshableApplicationContext
closeBeanFactory, createBeanFactory, customizeBeanFactory, getBeanFactory, hasBeanFactory, loadBeanDefinitions, refreshBeanFactory, setAllowBeanDefinitionOverriding, setAllowCircularReferences
 
Methods inherited from class org.springframework.context.support.AbstractApplicationContext
addApplicationListener, addBeanFactoryPostProcessor, addListener, close, containsBean, containsBeanDefinition, containsLocalBean, destroy, finishBeanFactoryInitialization, getAliases, getApplicationListeners, getAutowireCapableBeanFactory, getBean, getBean, getBean, getBeanDefinitionCount, getBeanDefinitionNames, getBeanFactoryPostProcessors, getBeanNamesForType, getBeanNamesForType, getBeansOfType, getBeansOfType, getDisplayName, getId, getInternalParentBeanFactory, getInternalParentMessageSource, getMessage, getMessage, getMessage, getParent, getParentBeanFactory, getStartupDate, getType, initApplicationEventMulticaster, initMessageSource, invokeBeanFactoryPostProcessors, isActive, isPrototype, isRunning, isSingleton, isTypeMatch, obtainFreshBeanFactory, onClose, onRefresh, prepareBeanFactory, prepareRefresh, publishEvent, registerBeanPostProcessors, registerListeners, registerShutdownHook, setDisplayName, setId, setParent, start, stop, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.springframework.osgi.context.ConfigurableOsgiBundleApplicationContext
getBundle, getBundleContext, setBundleContext, setConfigLocations, setPublishContextAsService
 
Methods inherited from interface org.springframework.context.ConfigurableApplicationContext
addApplicationListener, addBeanFactoryPostProcessor, close, getBeanFactory, isActive, registerShutdownHook, setParent
 
Methods inherited from interface org.springframework.context.ApplicationContext
getAutowireCapableBeanFactory, getDisplayName, getId, getParent, getStartupDate
 
Methods inherited from interface org.springframework.beans.factory.ListableBeanFactory
containsBeanDefinition, getBeanDefinitionCount, getBeanDefinitionNames, getBeanNamesForType, getBeanNamesForType, getBeansOfType, getBeansOfType
 
Methods inherited from interface org.springframework.beans.factory.BeanFactory
containsBean, getAliases, getBean, getBean, getBean, getType, isPrototype, isSingleton, isTypeMatch
 
Methods inherited from interface org.springframework.beans.factory.HierarchicalBeanFactory
containsLocalBean, getParentBeanFactory
 
Methods inherited from interface org.springframework.beans.factory.BeanFactory
containsBean, getAliases, getBean, getBean, getBean, getType, isPrototype, isSingleton, isTypeMatch
 
Methods inherited from interface org.springframework.context.MessageSource
getMessage, getMessage, getMessage
 
Methods inherited from interface org.springframework.context.ApplicationEventPublisher
publishEvent
 
Methods inherited from interface org.springframework.core.io.support.ResourcePatternResolver
getResources
 
Methods inherited from interface org.springframework.core.io.ResourceLoader
getClassLoader, getResource
 
Methods inherited from interface org.springframework.context.Lifecycle
isRunning, start, stop
 

Constructor Detail

AbstractDelegatedExecutionApplicationContext

public AbstractDelegatedExecutionApplicationContext()
Create a new AbstractDelegatedExecutionApplicationContext with no parent.


AbstractDelegatedExecutionApplicationContext

public AbstractDelegatedExecutionApplicationContext(ApplicationContext parent)
Create a new AbstractDelegatedExecutionApplicationContext with the given parent context.

Parameters:
parent - the parent context
Method Detail

refresh

public void refresh()
             throws BeansException,
                    IllegalStateException
Delegate execution of refresh method to a third party. This allows breaking the refresh process into several small pieces providing continuation-like behavior or completion of the refresh method on several threads, in a asynch manner. By default, the refresh method in executed in one go (normal behavior).

Specified by:
refresh in interface ConfigurableApplicationContext
Overrides:
refresh in class AbstractApplicationContext
Throws:
BeansException
IllegalStateException

normalRefresh

public void normalRefresh()
Description copied from interface: DelegatedExecutionOsgiBundleApplicationContext
Non-delegated refresh operation (execute ConfigurableApplicationContext.refresh() in the traditional way).

Specified by:
normalRefresh in interface DelegatedExecutionOsgiBundleApplicationContext
See Also:
ConfigurableApplicationContext.refresh()

normalClose

public void normalClose()
Description copied from interface: DelegatedExecutionOsgiBundleApplicationContext
Non-delegated close operation (execute ConfigurableApplicationContext.close() in the traditional way).

Specified by:
normalClose in interface DelegatedExecutionOsgiBundleApplicationContext
See Also:
ConfigurableApplicationContext.close()

doClose

protected void doClose()
Description copied from class: AbstractOsgiBundleApplicationContext
Unregister the ApplicationContext OSGi service (in case there is any).

Overrides:
doClose in class AbstractOsgiBundleApplicationContext

startRefresh

public void startRefresh()
Description copied from interface: DelegatedExecutionOsgiBundleApplicationContext
First phase of the refresh. Normally, this just prepares the beanFactory but does not instantiates any beans.

Specified by:
startRefresh in interface DelegatedExecutionOsgiBundleApplicationContext

completeRefresh

public void completeRefresh()
Description copied from interface: DelegatedExecutionOsgiBundleApplicationContext
The second, last phase of the refresh. Executes after a certain condition, imposed by the executor, has been met. Finishes the rest of the refresh operation. Normally, this operations performs most of the refresh work, such as instantiating singletons.

Specified by:
completeRefresh in interface DelegatedExecutionOsgiBundleApplicationContext

finishRefresh

protected void finishRefresh()
Overrides:
finishRefresh in class AbstractApplicationContext

cancelRefresh

protected void cancelRefresh(BeansException ex)
Overrides:
cancelRefresh in class AbstractApplicationContext

getMonitor

public Object getMonitor()
Description copied from interface: DelegatedExecutionOsgiBundleApplicationContext
Synchronization monitor for this ApplicationContext in case multiple threads can work with the application context lifecycle.

Specified by:
getMonitor in interface DelegatedExecutionOsgiBundleApplicationContext
Returns:
monitor for this application context.

setExecutor

public void setExecutor(OsgiBundleApplicationContextExecutor executor)
Description copied from interface: DelegatedExecutionOsgiBundleApplicationContext
Assigns the OsgiBundleApplicationContextExecutor for this delegated context.

Specified by:
setExecutor in interface DelegatedExecutionOsgiBundleApplicationContext
Parameters:
executor - the executor of this application context, to which the refresh method is delegated to

setDelegatedEventMulticaster

public void setDelegatedEventMulticaster(ApplicationEventMulticaster multicaster)
Description copied from interface: DelegatedExecutionOsgiBundleApplicationContext
Allows a delegated ApplicationEventMulticaster, external to the application contex, to be used for sending events OSGi application context events regarding the application context lifecycle. This method is mainly intended for monitoring the context lifecycle by third parties (such as the OSGi extender). It's up to the implementation to decide whether this setter method is required or not.

Specified by:
setDelegatedEventMulticaster in interface DelegatedExecutionOsgiBundleApplicationContext
Parameters:
multicaster - the application multicaster used for sending events triggered by the delegated execution.
See Also:
OsgiBundleApplicationContextEvent


Copyright © 2006-2008 Spring Framework. All Rights Reserved.