public class ServletContextAttributeFactoryBean extends Object implements org.springframework.beans.factory.FactoryBean<Object>, ServletContextAware
FactoryBean
that fetches a specific, existing ServletContext attribute.
Exposes that ServletContext attribute when used as bean reference,
effectively making it available as named Spring bean instance.
Intended to link in ServletContext attributes that exist before the startup of the Spring application context. Typically, such attributes will have been put there by third-party web frameworks. In a purely Spring-based web application, no such linking in of ServletContext attributes will be necessary.
NOTE: As of Spring 3.0, you may also use the "contextAttributes" default bean which is of type Map, and dereference it using an "#{contextAttributes.myKey}" expression to access a specific attribute by name.
WebApplicationContext.CONTEXT_ATTRIBUTES_BEAN_NAME
,
ServletContextParameterFactoryBean
Constructor and Description |
---|
ServletContextAttributeFactoryBean() |
Modifier and Type | Method and Description |
---|---|
Object |
getObject() |
Class<?> |
getObjectType() |
boolean |
isSingleton() |
void |
setAttributeName(String attributeName)
Set the name of the ServletContext attribute to expose.
|
void |
setServletContext(ServletContext servletContext)
Set the
ServletContext that this object runs in. |
public void setAttributeName(String attributeName)
public void setServletContext(ServletContext servletContext)
ServletContextAware
ServletContext
that this object runs in.
Invoked after population of normal bean properties but before an init
callback like InitializingBean's afterPropertiesSet
or a
custom init-method. Invoked after ApplicationContextAware's
setApplicationContext
.
setServletContext
in interface ServletContextAware
servletContext
- ServletContext object to be used by this objectInitializingBean.afterPropertiesSet()
,
ApplicationContextAware.setApplicationContext(org.springframework.context.ApplicationContext)
public Class<?> getObjectType()
getObjectType
in interface org.springframework.beans.factory.FactoryBean<Object>
public boolean isSingleton()
isSingleton
in interface org.springframework.beans.factory.FactoryBean<Object>