public class OsgiBundleXmlApplicationContext extends AbstractDelegatedExecutionApplicationContext
The configuration location defaults can be overridden via getDefaultConfigLocations(). Note that
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 configuration 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.| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
DEFAULT_CONFIG_LOCATION
Default config location for the root context(s)
|
APPLICATION_EVENT_MULTICASTER_BEAN_NAME, LIFECYCLE_PROCESSOR_BEAN_NAME, logger, MESSAGE_SOURCE_BEAN_NAMEAPPLICATION_CONTEXT_SERVICE_PROPERTY_NAME, BUNDLE_BEAN_NAME, BUNDLE_CONTEXT_BEAN_NAME, SPRING_DM_APPLICATION_CONTEXT_SERVICE_PROPERTY_NAMECONFIG_LOCATION_DELIMITERS, CONVERSION_SERVICE_BEAN_NAME, ENVIRONMENT_BEAN_NAME, LOAD_TIME_WEAVER_BEAN_NAME, SYSTEM_ENVIRONMENT_BEAN_NAME, SYSTEM_PROPERTIES_BEAN_NAME| Constructor and Description |
|---|
OsgiBundleXmlApplicationContext()
Creates a new
OsgiBundleXmlApplicationContext with no parent. |
OsgiBundleXmlApplicationContext(org.springframework.context.ApplicationContext parent)
Creates a new
OsgiBundleXmlApplicationContext with the given parent context. |
OsgiBundleXmlApplicationContext(java.lang.String[] configLocations)
Creates a new
OsgiBundleXmlApplicationContext with the given configLocations. |
OsgiBundleXmlApplicationContext(java.lang.String[] configLocations,
org.springframework.context.ApplicationContext parent)
Creates a new
OsgiBundleXmlApplicationContext with the given configLocations and parent context. |
| Modifier and Type | Method and Description |
|---|---|
private org.xml.sax.EntityResolver |
createEntityResolver(org.osgi.framework.BundleContext bundleContext,
java.lang.String filter,
java.lang.ClassLoader bundleClassLoader)
Similar to
#createNamespaceHandlerResolver(BundleContext, ClassLoader, ClassLoader) , this method creates
a special OSGi entity resolver that considers the bundle class path first, falling back to the entity resolver
service provided by the Spring DM extender. |
private org.springframework.beans.factory.xml.NamespaceHandlerResolver |
createNamespaceHandlerResolver(org.osgi.framework.BundleContext bundleContext,
java.lang.String filter,
java.lang.ClassLoader bundleClassLoader)
Creates a special OSGi namespace handler resolver that first searches the bundle class path falling back to the
namespace service published by Spring-DM.
|
private java.lang.String[] |
expandLocations(java.lang.String[] configLocations)
Expands any folder entries supplied as configuration location.
|
java.lang.String[] |
getConfigLocations()
Returns this application context configuration locations.
|
protected java.lang.String[] |
getDefaultConfigLocations()
Provide default locations for XML files.
|
protected void |
initBeanDefinitionReader(org.springframework.beans.factory.xml.XmlBeanDefinitionReader beanDefinitionReader)
Allows subclasses to do custom initialisation here.
|
protected void |
loadBeanDefinitions(org.springframework.beans.factory.support.DefaultListableBeanFactory beanFactory)
Loads the bean definitions via an
XmlBeanDefinitionReader. |
protected void |
loadBeanDefinitions(org.springframework.beans.factory.xml.XmlBeanDefinitionReader reader)
Loads the bean definitions with the given
XmlBeanDefinitionReader. |
private org.xml.sax.EntityResolver |
lookupEntityResolver(org.osgi.framework.BundleContext bundleContext,
java.lang.String filter,
java.lang.Object fallbackObject) |
private org.springframework.beans.factory.xml.NamespaceHandlerResolver |
lookupNamespaceHandlerResolver(org.osgi.framework.BundleContext bundleContext,
java.lang.String filter,
java.lang.Object fallbackObject) |
completeRefresh, doClose, getDelegatedEventMulticaster, invokeBeanFactoryPostProcessors, normalClose, normalRefresh, refresh, registerBeanPostProcessors, registerBeanPostProcessors, setContextClassLoaderProvider, setDelegatedEventMulticaster, setDelegatedEventMulticaster, setExecutor, startRefreshcreateResourcePatternResolver, customizeApplicationContextServiceProperties, destroyBeans, finishRefresh, getBundle, getBundleContext, getClassLoader, getResource, getResourceByPath, getResourcePatternResolver, getResources, postProcessBeanFactory, prepareRefresh, setBundleContext, setClassLoader, setConfigLocations, setPublishContextAsServicecancelRefresh, closeBeanFactory, createBeanFactory, customizeBeanFactory, getBeanFactory, hasBeanFactory, refreshBeanFactory, setAllowBeanDefinitionOverriding, setAllowCircularReferencesaddApplicationListener, addBeanFactoryPostProcessor, addListener, close, containsBean, containsBeanDefinition, containsLocalBean, createEnvironment, destroy, findAnnotationOnBean, finishBeanFactoryInitialization, getAliases, getApplicationListeners, getApplicationName, getAutowireCapableBeanFactory, getBean, getBean, getBean, getBean, getBeanDefinitionCount, getBeanDefinitionNames, getBeanFactoryPostProcessors, getBeanNamesForType, getBeanNamesForType, getBeansOfType, getBeansOfType, getBeansWithAnnotation, getDisplayName, getEnvironment, getId, getInternalParentBeanFactory, getInternalParentMessageSource, getMessage, getMessage, getMessage, getParent, getParentBeanFactory, getStartupDate, getType, initApplicationEventMulticaster, initLifecycleProcessor, initMessageSource, initPropertySources, isActive, isPrototype, isRunning, isSingleton, isTypeMatch, obtainFreshBeanFactory, onClose, onRefresh, prepareBeanFactory, publishEvent, registerListeners, registerShutdownHook, setDisplayName, setEnvironment, setId, setParent, start, stop, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetBundle, getBundleContext, setBundleContext, setConfigLocations, setPublishContextAsServiceaddApplicationListener, addBeanFactoryPostProcessor, close, getBeanFactory, getEnvironment, isActive, registerShutdownHook, setEnvironment, setId, setParentgetApplicationName, getAutowireCapableBeanFactory, getDisplayName, getId, getParent, getStartupDatecontainsBeanDefinition, findAnnotationOnBean, getBeanDefinitionCount, getBeanDefinitionNames, getBeanNamesForType, getBeanNamesForType, getBeansOfType, getBeansOfType, getBeansWithAnnotationcontainsLocalBean, getParentBeanFactorycontainsBean, getAliases, getBean, getBean, getBean, getBean, getType, isPrototype, isSingleton, isTypeMatchgetMessage, getMessage, getMessagegetResourcespublic static final java.lang.String DEFAULT_CONFIG_LOCATION
public OsgiBundleXmlApplicationContext()
OsgiBundleXmlApplicationContext with no parent.public OsgiBundleXmlApplicationContext(org.springframework.context.ApplicationContext parent)
OsgiBundleXmlApplicationContext with the given parent context.parent - the parent contextpublic OsgiBundleXmlApplicationContext(java.lang.String[] configLocations)
OsgiBundleXmlApplicationContext with the given configLocations.configLocations - array of configuration resourcespublic OsgiBundleXmlApplicationContext(java.lang.String[] configLocations,
org.springframework.context.ApplicationContext parent)
OsgiBundleXmlApplicationContext with the given configLocations and parent context.configLocations - array of configuration resourcesparent - the parent contextprotected void loadBeanDefinitions(org.springframework.beans.factory.support.DefaultListableBeanFactory beanFactory)
throws java.io.IOException
XmlBeanDefinitionReader.loadBeanDefinitions in class AbstractDelegatedExecutionApplicationContextjava.io.IOExceptionprotected void initBeanDefinitionReader(org.springframework.beans.factory.xml.XmlBeanDefinitionReader beanDefinitionReader)
beanDefinitionReader - protected void loadBeanDefinitions(org.springframework.beans.factory.xml.XmlBeanDefinitionReader reader)
throws org.springframework.beans.BeansException,
java.io.IOException
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.
org.springframework.beans.BeansException - in case of bean registration errorsjava.io.IOException - if the required XML document isn't foundAbstractRefreshableApplicationContext.refreshBeanFactory(),
getConfigLocations(),
AbstractOsgiBundleApplicationContext.getResources(java.lang.String),
AbstractOsgiBundleApplicationContext.getResourcePatternResolver()private java.lang.String[] expandLocations(java.lang.String[] configLocations)
configLocations - protected java.lang.String[] getDefaultConfigLocations()
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.
Note: Instead of overriding this method, consider using the Spring-DM specific header
inside your manifest bundle.getDefaultConfigLocations in class AbstractOsgiBundleApplicationContextAbstractOsgiBundleApplicationContext.setConfigLocations(java.lang.String[])private org.springframework.beans.factory.xml.NamespaceHandlerResolver createNamespaceHandlerResolver(org.osgi.framework.BundleContext bundleContext,
java.lang.String filter,
java.lang.ClassLoader bundleClassLoader)
bundleContext - the OSGi context of which the resolver should be aware offilter - OSGi service filterbundleClassLoader - classloader for creating the OSGi namespace resolver proxyprivate org.xml.sax.EntityResolver createEntityResolver(org.osgi.framework.BundleContext bundleContext,
java.lang.String filter,
java.lang.ClassLoader bundleClassLoader)
#createNamespaceHandlerResolver(BundleContext, ClassLoader, ClassLoader) , this method creates
a special OSGi entity resolver that considers the bundle class path first, falling back to the entity resolver
service provided by the Spring DM extender.bundleContext - the OSGi context of which the resolver should be aware offilter - OSGi service filterbundleClassLoader - classloader for creating the OSGi namespace resolver proxyprivate org.springframework.beans.factory.xml.NamespaceHandlerResolver lookupNamespaceHandlerResolver(org.osgi.framework.BundleContext bundleContext,
java.lang.String filter,
java.lang.Object fallbackObject)
private org.xml.sax.EntityResolver lookupEntityResolver(org.osgi.framework.BundleContext bundleContext,
java.lang.String filter,
java.lang.Object fallbackObject)
public java.lang.String[] getConfigLocations()
AbstractOsgiBundleApplicationContextgetConfigLocations in class AbstractOsgiBundleApplicationContextAbstractOsgiBundleApplicationContext.getDefaultConfigLocations()