Class ServletContextAttributeFactoryBean
java.lang.Object
org.springframework.web.context.support.ServletContextAttributeFactoryBean
- All Implemented Interfaces:
org.springframework.beans.factory.Aware,org.springframework.beans.factory.FactoryBean<Object>,ServletContextAware
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: You may also use the "contextAttributes" default bean, which is of type Map, and dereference it using a "#{contextAttributes.myKey}" expression to access a specific attribute by name.
- Since:
- 1.1.4
- Author:
- Juergen Hoeller
- See Also:
-
Field Summary
Fields inherited from interface org.springframework.beans.factory.FactoryBean
OBJECT_TYPE_ATTRIBUTE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionClass<?>booleanvoidsetAttributeName(String attributeName) Set the name of the ServletContext attribute to expose.voidsetServletContext(ServletContext servletContext) Set theServletContextthat this object runs in.
-
Constructor Details
-
ServletContextAttributeFactoryBean
public ServletContextAttributeFactoryBean()
-
-
Method Details
-
setAttributeName
Set the name of the ServletContext attribute to expose. -
setServletContext
Description copied from interface:ServletContextAwareSet theServletContextthat this object runs in.Invoked after population of normal bean properties but before an init callback like InitializingBean's
afterPropertiesSetor a custom init-method. Invoked after ApplicationContextAware'ssetApplicationContext.- Specified by:
setServletContextin interfaceServletContextAware- Parameters:
servletContext- the ServletContext object to be used by this object- See Also:
-
InitializingBean.afterPropertiesSet()ApplicationContextAware.setApplicationContext(org.springframework.context.ApplicationContext)
-
getObject
-
getObjectType
- Specified by:
getObjectTypein interfaceorg.springframework.beans.factory.FactoryBean<Object>
-
isSingleton
public boolean isSingleton()- Specified by:
isSingletonin interfaceorg.springframework.beans.factory.FactoryBean<Object>
-