org.springframework.osgi.web.context.support
Class OsgiBundleXmlWebApplicationContext
java.lang.Object
org.springframework.core.io.DefaultResourceLoader
org.springframework.context.support.AbstractApplicationContext
org.springframework.context.support.AbstractRefreshableApplicationContext
org.springframework.osgi.context.support.AbstractOsgiBundleApplicationContext
org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext
org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext
org.springframework.osgi.web.context.support.OsgiBundleXmlWebApplicationContext
- All Implemented Interfaces:
- BeanFactory, DisposableBean, HierarchicalBeanFactory, ListableBeanFactory, ApplicationContext, ApplicationEventPublisher, ConfigurableApplicationContext, Lifecycle, MessageSource, ResourceLoader, ResourcePatternResolver, ConfigurableOsgiBundleApplicationContext, DelegatedExecutionOsgiBundleApplicationContext, ThemeSource, ConfigurableWebApplicationContext, WebApplicationContext
public class OsgiBundleXmlWebApplicationContext
- extends OsgiBundleXmlApplicationContext
- implements ConfigurableWebApplicationContext, ThemeSource
OSGi variant for XmlWebApplicationContext
. The implementation
mandates that the OSGi bundle context is either set (AbstractOsgiBundleApplicationContext.setBundleContext(BundleContext)
before setting the ServletContext or that the given ServletContext contains
the BundleContext as an attribute under BUNDLE_CONTEXT_ATTRIBUTE
(org.springframework.osgi.web.org.osgi.framework.BundleContext
).
Additionally, this implementation replaces the ServletContext
resource loading with an OSGi specific loader which provides equivalent
functionality.
The OSGi service published for this application context contains the
namespace property (if non-null) under
org.springframework.web.context.namespace
property.
- Author:
- Costin Leau
- See Also:
XmlWebApplicationContext
,
OsgiBundleResourceLoader
,
OsgiBundleXmlApplicationContext
Methods inherited from class org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext |
completeRefresh, doClose, finishRefresh, getContextClassLoader, getDelegatedEventMulticaster, getMonitor, normalClose, normalRefresh, refresh, setContextClassLoaderProvider, setDelegatedEventMulticaster, setDelegatedEventMulticaster, setExecutor, startRefresh |
Methods inherited from class org.springframework.osgi.context.support.AbstractOsgiBundleApplicationContext |
createResourcePatternResolver, destroyBeans, getBundle, getBundleContext, getClassLoader, getResource, getResourceByPath, getResourcePatternResolver, getResources, setBundleContext, setClassLoader, setConfigLocations, setPublishContextAsService |
Methods inherited from class org.springframework.context.support.AbstractApplicationContext |
addApplicationListener, addBeanFactoryPostProcessor, addListener, cancelRefresh, close, containsBean, containsBeanDefinition, containsLocalBean, destroy, finishBeanFactoryInitialization, getAliases, getApplicationListeners, getAutowireCapableBeanFactory, getBean, getBean, getBean, getBeanDefinitionCount, getBeanDefinitionNames, getBeanFactoryPostProcessors, getBeanNamesForType, getBeanNamesForType, getBeansOfType, getBeansOfType, getDisplayName, getId, getInternalParentBeanFactory, getInternalParentMessageSource, getMessage, getMessage, getMessage, getParent, getParentBeanFactory, getStartupDate, getType, initApplicationEventMulticaster, initMessageSource, invokeBeanFactoryPostProcessors, isActive, isPrototype, isRunning, isSingleton, isTypeMatch, obtainFreshBeanFactory, onClose, prepareBeanFactory, prepareRefresh, publishEvent, registerBeanPostProcessors, registerListeners, registerShutdownHook, setDisplayName, setId, setParent, start, stop, toString |
BUNDLE_CONTEXT_ATTRIBUTE
public static final String BUNDLE_CONTEXT_ATTRIBUTE
- ServletContext attribute for retrieving the bundle context
OsgiBundleXmlWebApplicationContext
public OsgiBundleXmlWebApplicationContext()
setServletContext
public void setServletContext(ServletContext servletContext)
-
Additionally, if the
BundleContext
is not set, it is looked up
under BUNDLE_CONTEXT_ATTRIBUTE
.
- Specified by:
setServletContext
in interface ConfigurableWebApplicationContext
getServletContext
public ServletContext getServletContext()
- Specified by:
getServletContext
in interface WebApplicationContext
setServletConfig
public void setServletConfig(ServletConfig servletConfig)
-
Additionally, it also sets the context namespace if it's not initialized
(null).
- Specified by:
setServletConfig
in interface ConfigurableWebApplicationContext
getServletConfig
public ServletConfig getServletConfig()
- Specified by:
getServletConfig
in interface ConfigurableWebApplicationContext
setNamespace
public void setNamespace(String namespace)
- Specified by:
setNamespace
in interface ConfigurableWebApplicationContext
getNamespace
public String getNamespace()
- Specified by:
getNamespace
in interface ConfigurableWebApplicationContext
postProcessBeanFactory
protected void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
-
Registers request/session scopes, a
ServletContextAwareProcessor
,
etc.
- Overrides:
postProcessBeanFactory
in class AbstractOsgiBundleApplicationContext
customizeApplicationContextServiceProperties
protected void customizeApplicationContextServiceProperties(Map serviceProperties)
- Customizes the properties of the application context OSGi service. This
method is called only if the application context will be published as an
OSGi service.
The default implementation stores the bundle symbolic name under
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).
Additionally, this implementation published the context namespace under
org.springframework.context.web.namespace
property.
- Overrides:
customizeApplicationContextServiceProperties
in class AbstractOsgiBundleApplicationContext
- Parameters:
serviceProperties
- service properties map (can be casted to
Dictionary
)
onRefresh
protected void onRefresh()
-
Initializes the theme capability.
- Overrides:
onRefresh
in class AbstractApplicationContext
getTheme
public Theme getTheme(String themeName)
- Specified by:
getTheme
in interface ThemeSource
getDefaultConfigLocations
protected String[] getDefaultConfigLocations()
- Provide default locations for XML files. This implementation returns
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.
Returns the default location for the root context. Default values are
"/WEB-INF/applicationContext.xml", and "/WEB-INF/test-servlet.xml" for a
context with the namespace "test-servlet" (like for a DispatcherServlet
instance with the servlet-name "test").
- Overrides:
getDefaultConfigLocations
in class OsgiBundleXmlApplicationContext
- Returns:
- default XML configuration locations
- See Also:
XmlWebApplicationContext.getDefaultConfigLocations()
,
XmlWebApplicationContext.DEFAULT_CONFIG_LOCATION
setConfigLocation
public void setConfigLocation(String location)
-
Sets the config locations for this application context in init-param
style, i.e. with distinct locations separated by commas, semicolons or
whitespace.
If not set, the implementation may use a default as appropriate.
- Specified by:
setConfigLocation
in interface ConfigurableWebApplicationContext
- See Also:
ConfigurableApplicationContext.CONFIG_LOCATION_DELIMITERS
Copyright © 2006-2009 Spring Framework. All Rights Reserved.