spring-framework / org.springframework.web.context.support / ServletContextAttributeFactoryBean

ServletContextAttributeFactoryBean

open class ServletContextAttributeFactoryBean : FactoryBean<Any>, 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.

Author
Juergen Hoeller

Since
1.1.4

See Also
org.springframework.web.context.WebApplicationContext#CONTEXT_ATTRIBUTES_BEAN_NAMEServletContextParameterFactoryBean

Constructors

<init>

ServletContextAttributeFactoryBean()

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.

Functions

getObject

open fun getObject(): Any

getObjectType

open fun getObjectType(): Class<*>

isSingleton

open fun isSingleton(): Boolean

setAttributeName

open fun setAttributeName(attributeName: String): Unit

Set the name of the ServletContext attribute to expose.

setServletContext

open fun setServletContext(servletContext: ServletContext): Unit