org.springframework.osgi.context.support
Class OsgiBundleXmlApplicationContext
java.lang.Object
org.springframework.core.io.DefaultResourceLoader
org.springframework.context.support.AbstractApplicationContext
org.springframework.context.support.AbstractRefreshableApplicationContext
org.springframework.osgi.context.support.AbstractOsgiBundleApplicationContext
org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext
org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext
- All Implemented Interfaces:
- BeanFactory, DisposableBean, HierarchicalBeanFactory, ListableBeanFactory, ApplicationContext, ApplicationEventPublisher, ConfigurableApplicationContext, Lifecycle, MessageSource, ResourceLoader, ResourcePatternResolver, ConfigurableOsgiBundleApplicationContext, DelegatedExecutionOsgiBundleApplicationContext
public class OsgiBundleXmlApplicationContext
- extends AbstractDelegatedExecutionApplicationContext
Standalone XML application context, backed by an OSGi bundle.
The config location defaults can be overridden via
getDefaultConfigLocations()
, Config locations can either denote
concrete files like "/myfiles/context.xml" or Ant-style patterns like
"/myfiles/*-context.xml" (see the
AntPathMatcher
javadoc for pattern details).
Note: In case of multiple config locations, later bean definitions will
override ones defined in earlier loaded files. This can be leveraged to
deliberately override certain bean definitions via an extra XML file.
This is the main ApplicationContext class for OSGi environments.
- Author:
- Adrian Colyer, Costin Leau, Andy Piper, Hal Hildebrand
Methods inherited from class org.springframework.osgi.context.support.AbstractOsgiBundleApplicationContext |
destroyBeans, getBundle, getBundleContext, getClassLoader, getConfigLocations, getResource, getResourceByPath, getResourcePatternResolver, getResources, postProcessBeanFactory, setBundleContext, setClassLoader, setConfigLocations, setPublishContextAsService |
Methods inherited from class org.springframework.context.support.AbstractApplicationContext |
addApplicationListener, addBeanFactoryPostProcessor, addListener, cancelRefresh, close, containsBean, containsBeanDefinition, containsLocalBean, destroy, finishBeanFactoryInitialization, getAliases, getApplicationListeners, getAutowireCapableBeanFactory, getBean, getBean, getBean, getBeanDefinitionCount, getBeanDefinitionNames, getBeanFactoryPostProcessors, getBeanNamesForType, getBeanNamesForType, getBeansOfType, getBeansOfType, getDisplayName, getInternalParentBeanFactory, getInternalParentMessageSource, getMessage, getMessage, getMessage, getParent, getParentBeanFactory, getStartupDate, getType, initApplicationEventMulticaster, initLifecycleDependentBeans, initMessageSource, invokeBeanFactoryPostProcessors, isActive, isPrototype, isRunning, isSingleton, isTypeMatch, obtainFreshBeanFactory, onClose, onRefresh, prepareBeanFactory, prepareRefresh, publishEvent, registerBeanPostProcessors, registerListeners, registerShutdownHook, setDisplayName, setParent, start, stop, toString |
DEFAULT_CONFIG_LOCATION
public static final String DEFAULT_CONFIG_LOCATION
- Note this location uses
OsgiBundleResource.BUNDLE_JAR_URL_PREFIX
prefix temporary as a work around for resource acquisition problems(OSGI-210)
with Felix and Knopflerfish. We expect the prefix to be removed (from jar to
bundle space) before the final release.
- See Also:
- Constant Field Values
OsgiBundleXmlApplicationContext
public OsgiBundleXmlApplicationContext()
- Create a new OsgiBundleXmlApplicationContext with no parent.
OsgiBundleXmlApplicationContext
public OsgiBundleXmlApplicationContext(ApplicationContext parent)
- Create a new OsgiBundleXmlApplicationContext with the given parent
context.
- Parameters:
parent
- the parent context
OsgiBundleXmlApplicationContext
public OsgiBundleXmlApplicationContext(String[] configLocations)
- Create a new OsgiBundleXmlApplicationContext with the given
configLocations.
- Parameters:
configLocations
- array of configuration resources
OsgiBundleXmlApplicationContext
public OsgiBundleXmlApplicationContext(String[] configLocations,
ApplicationContext parent)
- Create a new OsgiBundleXmlApplicationContext with the given
configLocations and parent context.
- Parameters:
configLocations
- array of configuration resourcesparent
- the parent context
loadBeanDefinitions
protected void loadBeanDefinitions(DefaultListableBeanFactory beanFactory)
throws IOException
- Loads the bean definitions via an XmlBeanDefinitionReader.
- Specified by:
loadBeanDefinitions
in class AbstractRefreshableApplicationContext
- Throws:
IOException
- See Also:
XmlBeanDefinitionReader
,
initBeanDefinitionReader(org.springframework.beans.factory.xml.XmlBeanDefinitionReader)
,
loadBeanDefinitions(org.springframework.beans.factory.support.DefaultListableBeanFactory)
initBeanDefinitionReader
protected void initBeanDefinitionReader(XmlBeanDefinitionReader beanDefinitionReader)
- Allows subclasses to do custom initialisation here.
- Parameters:
beanDefinitionReader
-
loadBeanDefinitions
protected void loadBeanDefinitions(XmlBeanDefinitionReader reader)
throws BeansException,
IOException
- Load the bean definitions with the given XmlBeanDefinitionReader.
The lifecycle of the bean factory is handled by the refreshBeanFactory
method; therefore this method is just supposed to load and/or register
bean definitions.
Delegates to a ResourcePatternResolver for resolving location patterns
into Resource instances.
- Throws:
BeansException
- in case of bean
registration errors
IOException
- if the required XML document isn't found- See Also:
AbstractRefreshableApplicationContext.refreshBeanFactory()
,
AbstractOsgiBundleApplicationContext.getConfigLocations()
,
AbstractOsgiBundleApplicationContext.getResources(java.lang.String)
,
AbstractOsgiBundleApplicationContext.getResourcePatternResolver()
getDefaultConfigLocations
protected String[] getDefaultConfigLocations()
- Provide default locations for XML files. This implementation returns
META-INF/spring/*.xml
relying on the default resource environment for actual localisation.
By default, the bundle space will be used for locating the
resources.
- Overrides:
getDefaultConfigLocations
in class AbstractOsgiBundleApplicationContext
- Returns:
- xml default config locations
- See Also:
AbstractOsgiBundleApplicationContext.setConfigLocations(java.lang.String[])
Copyright © 2006-2007 Spring Framework. All Rights Reserved.