|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.core.io.DefaultResourceLoader org.springframework.context.support.AbstractApplicationContext org.springframework.context.support.AbstractRefreshableApplicationContext org.springframework.osgi.context.support.AbstractOsgiBundleApplicationContext
public abstract class AbstractOsgiBundleApplicationContext
AbstractRefreshableApplicationContext
subclass that implements
the ConfigurableOsgiBundleApplicationContext
interface for OSGi
environments. Pre-implements a configLocation
property, to be
populated through the ConfigurableOsgiApplicationContext
interface after OSGi bundle startup.
This class is as easy to subclass as
AbstractRefreshableApplicationContext
(see the javadoc for
details): all you need to implement is the loadBeanDefinitions
method Note that implementations are supposed to load bean definitions from
the files specified by the locations returned by
getConfigLocations
method.
In addition to the special beans detected by
AbstractApplicationContext
, this class registers the
BundleContextAwareProcessor
for processing beans that
implement the BundleContextAware
interface. Also it interprets
resource paths as OSGi bundle resources (either from the bundle class space,
bundle space or jar space).
This application context implementation offers the OSGi-specific, bundle scope.
Note: OsgiApplicationContext
implementations
are generally supposed to configure themselves based on the configuration
received through the ConfigurableOsgiBundleApplicationContext
interface. In contrast, a stand-alone application context might allow for
configuration in custom startup code (for example,
GenericApplicationContext
).
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 | |
---|---|
AbstractOsgiBundleApplicationContext()
Creates a new AbstractOsgiBundleApplicationContext with no
parent. |
|
AbstractOsgiBundleApplicationContext(ApplicationContext parent)
Creates a new AbstractOsgiBundleApplicationContext with
the given parent context. |
Method Summary | |
---|---|
protected ResourcePatternResolver |
createResourcePatternResolver()
Creates an OSGi specific resource pattern resolver. |
protected void |
customizeApplicationContextServiceProperties(Map serviceProperties)
Customizes the properties of the application context OSGi service. |
protected void |
destroyBeans()
|
protected void |
doClose()
Unregister the ApplicationContext OSGi service (in case there is any). |
Bundle |
getBundle()
Returns the OSGi Bundle for this application context. |
BundleContext |
getBundleContext()
Return the BundleContext for this application context. |
ClassLoader |
getClassLoader()
|
String[] |
getConfigLocations()
Returns this application context configuration locations. |
protected String[] |
getDefaultConfigLocations()
Returns the default configuration locations to use, for the case where no explicit configuration locations have been specified. |
Resource |
getResource(String location)
|
protected Resource |
getResourceByPath(String path)
|
protected ResourcePatternResolver |
getResourcePatternResolver()
This implementation supports pattern matching inside the OSGi bundle. |
Resource[] |
getResources(String locationPattern)
|
protected void |
postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
|
void |
setBundleContext(BundleContext bundleContext)
Sets the BundleContext used by this OSGi bundle
application context.
Will automatically determine the bundle, create a new
ResourceLoader (and set its ClassLoader (if
none is set already) to a custom implementation that will delegate the
calls to the bundle). |
void |
setClassLoader(ClassLoader classLoader)
|
void |
setConfigLocations(String[] configLocations)
Sets the config locations for this OSGi bundle application context. |
void |
setPublishContextAsService(boolean publishContextAsService)
Indicates whether this application context should be publish as an OSGi service if successfully started. |
Methods inherited from class org.springframework.context.support.AbstractRefreshableApplicationContext |
---|
closeBeanFactory, createBeanFactory, customizeBeanFactory, getBeanFactory, hasBeanFactory, loadBeanDefinitions, refreshBeanFactory, setAllowBeanDefinitionOverriding, setAllowCircularReferences |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.springframework.context.ConfigurableApplicationContext |
---|
addApplicationListener, addBeanFactoryPostProcessor, close, getBeanFactory, isActive, refresh, 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.context.Lifecycle |
---|
isRunning, start, stop |
Constructor Detail |
---|
public AbstractOsgiBundleApplicationContext()
AbstractOsgiBundleApplicationContext
with no
parent.
public AbstractOsgiBundleApplicationContext(ApplicationContext parent)
AbstractOsgiBundleApplicationContext
with
the given parent context.
parent
- the parent contextMethod Detail |
---|
public void setBundleContext(BundleContext bundleContext)
BundleContext
used by this OSGi bundle
application context. Normally it's the BundleContext
in
which the context runs.
Does not cause an initialization of the context: ConfigurableApplicationContext.refresh()
needs
to be called after the setting of all configuration properties.
ResourceLoader
(and set its ClassLoader
(if
none is set already) to a custom implementation that will delegate the
calls to the bundle).
setBundleContext
in interface ConfigurableOsgiBundleApplicationContext
bundleContext
- the BundleContext
used by this
application context.ConfigurableApplicationContext.refresh()
public BundleContext getBundleContext()
ConfigurableOsgiBundleApplicationContext
BundleContext
for this application context.
This method is offered as a helper since as of OSGi 4.1, the bundle
context can be discovered directly from the given bundle.
getBundleContext
in interface ConfigurableOsgiBundleApplicationContext
BundleContext
in which this application
context runsConfigurableOsgiBundleApplicationContext.getBundle()
public Bundle getBundle()
ConfigurableOsgiBundleApplicationContext
Bundle
for this application context.
getBundle
in interface ConfigurableOsgiBundleApplicationContext
Bundle
for this OSGi bundle application
context.public void setConfigLocations(String[] configLocations)
ConfigurableOsgiBundleApplicationContext
setConfigLocations
in interface ConfigurableOsgiBundleApplicationContext
configLocations
- array of configuration locationspublic String[] getConfigLocations()
getDefaultConfigLocations()
protected void doClose()
doClose
in class AbstractApplicationContext
protected void destroyBeans()
destroyBeans
in class AbstractApplicationContext
protected String[] getDefaultConfigLocations()
Default implementation returns null
, requiring explicit
configuration locations.
setConfigLocations(java.lang.String[])
protected void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException
postProcessBeanFactory
in class AbstractApplicationContext
BeansException
protected void customizeApplicationContextServiceProperties(Map serviceProperties)
Constants.BUNDLE_SYMBOLICNAME
and
ConfigurableOsgiBundleApplicationContext.APPLICATION_CONTEXT_SERVICE_PROPERTY_NAME
and the bundle version under Constants.BUNDLE_VERSION
property.
Can be overridden by subclasses to add more properties if needed (for
example for web applications where multiple application contexts are
available inside the same bundle).
serviceProperties
- service properties map (can be casted to
Dictionary
)protected ResourcePatternResolver createResourcePatternResolver()
protected ResourcePatternResolver getResourcePatternResolver()
getResourcePatternResolver
in class AbstractApplicationContext
OsgiBundleResourcePatternResolver
public ClassLoader getClassLoader()
getClassLoader
in interface ResourceLoader
getClassLoader
in class DefaultResourceLoader
public Resource getResource(String location)
getResource
in interface ResourceLoader
getResource
in class DefaultResourceLoader
public Resource[] getResources(String locationPattern) throws IOException
getResources
in interface ResourcePatternResolver
getResources
in class AbstractApplicationContext
IOException
public void setClassLoader(ClassLoader classLoader)
setClassLoader
in class DefaultResourceLoader
protected Resource getResourceByPath(String path)
getResourceByPath
in class DefaultResourceLoader
public void setPublishContextAsService(boolean publishContextAsService)
ConfigurableOsgiBundleApplicationContext
true
.
setPublishContextAsService
in interface ConfigurableOsgiBundleApplicationContext
publishContextAsService
- true if the application context should be
published as a service, false otherwise
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |