|
||||||||||
| 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.eclipse.gemini.blueprint.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, LIFECYCLE_PROCESSOR_BEAN_NAME, logger, MESSAGE_SOURCE_BEAN_NAME |
| Fields inherited from interface org.eclipse.gemini.blueprint.context.ConfigurableOsgiBundleApplicationContext |
|---|
APPLICATION_CONTEXT_SERVICE_PROPERTY_NAME, BUNDLE_BEAN_NAME, BUNDLE_CONTEXT_BEAN_NAME, SPRING_DM_APPLICATION_CONTEXT_SERVICE_PROPERTY_NAME |
| Fields inherited from interface org.springframework.context.ConfigurableApplicationContext |
|---|
CONFIG_LOCATION_DELIMITERS, CONVERSION_SERVICE_BEAN_NAME, ENVIRONMENT_BEAN_NAME, LOAD_TIME_WEAVER_BEAN_NAME, SYSTEM_ENVIRONMENT_BEAN_NAME, SYSTEM_PROPERTIES_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(org.springframework.context.ApplicationContext parent)
Creates a new AbstractOsgiBundleApplicationContext with the given parent context. |
|
| Method Summary | |
|---|---|
protected org.springframework.core.io.support.ResourcePatternResolver |
createResourcePatternResolver()
Creates an OSGi specific resource pattern resolver. |
protected void |
customizeApplicationContextServiceProperties(Map<Object,Object> 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). |
protected void |
finishRefresh()
|
org.osgi.framework.Bundle |
getBundle()
Returns the OSGi Bundle for this application context. |
org.osgi.framework.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. |
org.springframework.core.io.Resource |
getResource(String location)
|
protected org.springframework.core.io.Resource |
getResourceByPath(String path)
|
protected org.springframework.core.io.support.ResourcePatternResolver |
getResourcePatternResolver()
This implementation supports pattern matching inside the OSGi bundle. |
org.springframework.core.io.Resource[] |
getResources(String locationPattern)
|
protected void |
postProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory)
|
protected void |
prepareRefresh()
|
void |
setBundleContext(org.osgi.framework.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 |
|---|
cancelRefresh, closeBeanFactory, createBeanFactory, customizeBeanFactory, getBeanFactory, hasBeanFactory, loadBeanDefinitions, refreshBeanFactory, setAllowBeanDefinitionOverriding, setAllowCircularReferences |
| Methods inherited from class org.springframework.context.support.AbstractApplicationContext |
|---|
addApplicationListener, addBeanFactoryPostProcessor, addListener, close, containsBean, containsBeanDefinition, containsLocalBean, createEnvironment, destroy, findAnnotationOnBean, finishBeanFactoryInitialization, getAliases, getApplicationListeners, 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, invokeBeanFactoryPostProcessors, isActive, isPrototype, isRunning, isSingleton, isTypeMatch, obtainFreshBeanFactory, onClose, onRefresh, prepareBeanFactory, publishEvent, refresh, registerBeanPostProcessors, registerListeners, registerShutdownHook, setDisplayName, setEnvironment, setId, setParent, start, stop, toString |
| 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, getEnvironment, isActive, refresh, registerShutdownHook, setEnvironment, setId, setParent |
| Methods inherited from interface org.springframework.context.ApplicationContext |
|---|
getAutowireCapableBeanFactory, getDisplayName, getId, getParent, getStartupDate |
| Methods inherited from interface org.springframework.beans.factory.ListableBeanFactory |
|---|
containsBeanDefinition, findAnnotationOnBean, getBeanDefinitionCount, getBeanDefinitionNames, getBeanNamesForType, getBeanNamesForType, getBeansOfType, getBeansOfType, getBeansWithAnnotation |
| Methods inherited from interface org.springframework.beans.factory.BeanFactory |
|---|
containsBean, getAliases, getBean, 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, 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(org.springframework.context.ApplicationContext parent)
AbstractOsgiBundleApplicationContext with the given parent context.
parent - the parent context| Method Detail |
|---|
public void setBundleContext(org.osgi.framework.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 ConfigurableOsgiBundleApplicationContextbundleContext - the BundleContext used by this
application context.ConfigurableApplicationContext.refresh()public org.osgi.framework.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 org.osgi.framework.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 org.springframework.context.support.AbstractApplicationContextprotected void destroyBeans()
destroyBeans in class org.springframework.context.support.AbstractApplicationContextprotected String[] getDefaultConfigLocations()
Default implementation returns null, requiring explicit configuration locations.
setConfigLocations(java.lang.String[])protected void prepareRefresh()
prepareRefresh in class org.springframework.context.support.AbstractApplicationContextprotected void finishRefresh()
finishRefresh in class org.springframework.context.support.AbstractApplicationContext
protected void postProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory)
throws org.springframework.beans.BeansException
postProcessBeanFactory in class org.springframework.context.support.AbstractApplicationContextorg.springframework.beans.BeansExceptionprotected void customizeApplicationContextServiceProperties(Map<Object,Object> 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 org.springframework.core.io.support.ResourcePatternResolver createResourcePatternResolver()
protected org.springframework.core.io.support.ResourcePatternResolver getResourcePatternResolver()
getResourcePatternResolver in class org.springframework.context.support.AbstractApplicationContextOsgiBundleResourcePatternResolverpublic ClassLoader getClassLoader()
getClassLoader in interface org.springframework.core.io.ResourceLoadergetClassLoader in class org.springframework.core.io.DefaultResourceLoaderpublic org.springframework.core.io.Resource getResource(String location)
getResource in interface org.springframework.core.io.ResourceLoadergetResource in class org.springframework.core.io.DefaultResourceLoader
public org.springframework.core.io.Resource[] getResources(String locationPattern)
throws IOException
getResources in interface org.springframework.core.io.support.ResourcePatternResolvergetResources in class org.springframework.context.support.AbstractApplicationContextIOExceptionpublic void setClassLoader(ClassLoader classLoader)
setClassLoader in class org.springframework.core.io.DefaultResourceLoaderprotected org.springframework.core.io.Resource getResourceByPath(String path)
getResourceByPath in class org.springframework.core.io.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 | |||||||||