|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.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 |
|---|
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()
Creates a new AbstractOsgiBundleApplicationContext with no
parent. |
|
AbstractOsgiBundleApplicationContext(ApplicationContext parent)
Creates a new AbstractOsgiBundleApplicationContext with
the given parent context. |
|
| Method Summary | |
|---|---|
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. |
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 |
| 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()
AbstractOsgiBundleApplicationContext with no
parent.
public AbstractOsgiBundleApplicationContext(ApplicationContext parent)
AbstractOsgiBundleApplicationContext with
the given parent context.
parent - the parent context| Method 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 to
a custom implementation that will delegate the calls to the bundle).
setBundleContext in interface ConfigurableOsgiBundleApplicationContextbundleContext - the BundleContext used by this
application context.ConfigurableApplicationContext.refresh()public BundleContext getBundleContext()
ConfigurableOsgiBundleApplicationContextBundleContext 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 ConfigurableOsgiBundleApplicationContextBundleContext in which this application
context runsConfigurableOsgiBundleApplicationContext.getBundle()public Bundle getBundle()
ConfigurableOsgiBundleApplicationContextBundle for this application context.
getBundle in interface ConfigurableOsgiBundleApplicationContextBundle for this OSGi bundle application
context.public void setConfigLocations(String[] configLocations)
ConfigurableOsgiBundleApplicationContext
setConfigLocations in interface ConfigurableOsgiBundleApplicationContextconfigLocations - array of configuration locationspublic String[] getConfigLocations()
getDefaultConfigLocations()protected void doClose()
doClose in class AbstractApplicationContextprotected void destroyBeans()
destroyBeans in class AbstractApplicationContextprotected String[] getDefaultConfigLocations()
Default implementation returns null, requiring explicit
configuration locations.
setConfigLocations(java.lang.String[])
protected void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
throws BeansException
postProcessBeanFactory in class AbstractApplicationContextBeansExceptionprotected ResourcePatternResolver getResourcePatternResolver()
getResourcePatternResolver in class AbstractApplicationContextOsgiBundleResourcePatternResolverpublic ClassLoader getClassLoader()
getClassLoader in interface ResourceLoadergetClassLoader in class DefaultResourceLoaderpublic Resource getResource(String location)
getResource in interface ResourceLoadergetResource in class DefaultResourceLoader
public Resource[] getResources(String locationPattern)
throws IOException
getResources in interface ResourcePatternResolvergetResources in class AbstractApplicationContextIOExceptionpublic void setClassLoader(ClassLoader classLoader)
setClassLoader in class DefaultResourceLoaderprotected Resource getResourceByPath(String path)
getResourceByPath in class DefaultResourceLoaderpublic void setPublishContextAsService(boolean publishContextAsService)
ConfigurableOsgiBundleApplicationContexttrue.
setPublishContextAsService in interface ConfigurableOsgiBundleApplicationContextpublishContextAsService - 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 | |||||||||