|
||||||||||
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 ConfigurableOsgiApplicationContext interface for OSGi environments. Pre-implements a "configLocation" property, to be populated through the ConfigurableOsgiApplicationContext interface on OSGi bundle startup.
This class is as easy to subclass as AbstractRefreshableApplicationContext:
All you need to implement is the loadBeanDefinitions
method;
see the superclass javadoc for details. Note that implementations are
supposed to load bean definitions from the files specified by the locations
returned by the getConfigLocations
method.
Interprets resource paths as OSGi bundle resources (either from the bundle classpath or OSGi entries).
In addition to the special beans detected by AbstractApplicationContext, this
class registers the BundleContextAwareProcessor
for processing
beans that implement the BundleContextAware
interface.
This application context offers the OSGi-specific, "bundle" scope. See
OsgiBundleScope
.
Note that OsgiApplicationContext implementations are generally supposed to configure themselves based on the configuration received through the ConfigurableOsgiBundleApplicationContext interface. In contrast, a standalone 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 |
---|
LOAD_TIME_WEAVER_BEAN_NAME |
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()
|
Method Summary | |
---|---|
protected void |
cleanOsgiBundleScope(ConfigurableListableBeanFactory beanFactory)
|
protected ClassLoader |
createBundleClassLoader(Bundle bundle)
Create the classloader that delegates to the underlying OSGi bundle. |
protected void |
destroyBeans()
|
protected void |
doClose()
|
Bundle |
getBundle()
Return the OSGi bundle for this application context. |
BundleContext |
getBundleContext()
Get the OSGi BundleContext for this application context |
String |
getBundleSymbolicName()
|
ClassLoader |
getClassLoader()
|
String[] |
getConfigLocations()
|
protected String[] |
getDefaultConfigLocations()
Return the default config locations to use, for the case where no explicit config 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 ConfigurableListableBeanFactory |
obtainFreshBeanFactory()
|
protected void |
postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
Register post processor for BeanContextAware beans. |
protected void |
publishContextAsOsgiServiceIfNecessary()
Publish the application context as an OSGi service. |
void |
setBundleContext(BundleContext bundleContext)
Set the bundleContext for this application context. |
void |
setClassLoader(ClassLoader classLoader)
|
void |
setConfigLocations(String[] configLocations)
Set the config locations for this OSGi bundle application context. |
void |
setPublishContextAsService(boolean publishContextAsService)
Publish the application context as an OSGi service. |
Methods inherited from class org.springframework.context.support.AbstractRefreshableApplicationContext |
---|
closeBeanFactory, createBeanFactory, customizeBeanFactory, getBeanFactory, loadBeanDefinitions, refreshBeanFactory |
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, 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.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()
Method Detail |
---|
public void setBundleContext(BundleContext bundleContext)
setBundleContext
in interface ConfigurableOsgiBundleApplicationContext
ConfigurableApplicationContext.refresh()
public BundleContext getBundleContext()
getBundleContext
in interface ConfigurableOsgiBundleApplicationContext
ConfigurableOsgiBundleApplicationContext.getBundle()
public Bundle getBundle()
ConfigurableOsgiBundleApplicationContext
getBundle
in interface ConfigurableOsgiBundleApplicationContext
public void setConfigLocations(String[] configLocations)
ConfigurableOsgiBundleApplicationContext
setConfigLocations
in interface ConfigurableOsgiBundleApplicationContext
public String[] getConfigLocations()
protected void doClose()
doClose
in class AbstractApplicationContext
protected void destroyBeans()
destroyBeans
in class AbstractApplicationContext
protected String[] getDefaultConfigLocations()
Default implementation returns null, requiring explicit config locations.
setConfigLocations(java.lang.String[])
protected void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException
postProcessBeanFactory
in class AbstractApplicationContext
BeansException
protected ConfigurableListableBeanFactory obtainFreshBeanFactory()
obtainFreshBeanFactory
in class AbstractApplicationContext
protected void cleanOsgiBundleScope(ConfigurableListableBeanFactory beanFactory)
protected void publishContextAsOsgiServiceIfNecessary()
public String getBundleSymbolicName()
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
setPublishContextAsService
in interface ConfigurableOsgiBundleApplicationContext
publishContextAsService
- The publishContextAsService to set.protected ClassLoader createBundleClassLoader(Bundle bundle)
bundle
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |