org.springframework.web.context.request.RequestScope Java Examples

The following examples show how to use org.springframework.web.context.request.RequestScope. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WebApplicationContextUtils.java    From spring-analysis-note with MIT License 6 votes vote down vote up
/**
 * Register web-specific scopes ("request", "session", "globalSession", "application")
 * with the given BeanFactory, as used by the WebApplicationContext.
 * @param beanFactory the BeanFactory to configure
 * @param sc the ServletContext that we're running within
 */
public static void registerWebApplicationScopes(ConfigurableListableBeanFactory beanFactory,
		@Nullable ServletContext sc) {

	beanFactory.registerScope(WebApplicationContext.SCOPE_REQUEST, new RequestScope());
	beanFactory.registerScope(WebApplicationContext.SCOPE_SESSION, new SessionScope());
	if (sc != null) {
		ServletContextScope appScope = new ServletContextScope(sc);
		beanFactory.registerScope(WebApplicationContext.SCOPE_APPLICATION, appScope);
		// Register as ServletContext attribute, for ContextCleanupListener to detect it.
		sc.setAttribute(ServletContextScope.class.getName(), appScope);
	}

	beanFactory.registerResolvableDependency(ServletRequest.class, new RequestObjectFactory());
	beanFactory.registerResolvableDependency(ServletResponse.class, new ResponseObjectFactory());
	beanFactory.registerResolvableDependency(HttpSession.class, new SessionObjectFactory());
	beanFactory.registerResolvableDependency(WebRequest.class, new WebRequestObjectFactory());
	if (jsfPresent) {
		FacesDependencyRegistrar.registerFacesDependencies(beanFactory);
	}
}
 
Example #2
Source File: WebApplicationContextUtils.java    From java-technology-stack with MIT License 6 votes vote down vote up
/**
 * Register web-specific scopes ("request", "session", "globalSession", "application")
 * with the given BeanFactory, as used by the WebApplicationContext.
 * @param beanFactory the BeanFactory to configure
 * @param sc the ServletContext that we're running within
 */
public static void registerWebApplicationScopes(ConfigurableListableBeanFactory beanFactory,
		@Nullable ServletContext sc) {

	beanFactory.registerScope(WebApplicationContext.SCOPE_REQUEST, new RequestScope());
	beanFactory.registerScope(WebApplicationContext.SCOPE_SESSION, new SessionScope());
	if (sc != null) {
		ServletContextScope appScope = new ServletContextScope(sc);
		beanFactory.registerScope(WebApplicationContext.SCOPE_APPLICATION, appScope);
		// Register as ServletContext attribute, for ContextCleanupListener to detect it.
		sc.setAttribute(ServletContextScope.class.getName(), appScope);
	}

	beanFactory.registerResolvableDependency(ServletRequest.class, new RequestObjectFactory());
	beanFactory.registerResolvableDependency(ServletResponse.class, new ResponseObjectFactory());
	beanFactory.registerResolvableDependency(HttpSession.class, new SessionObjectFactory());
	beanFactory.registerResolvableDependency(WebRequest.class, new WebRequestObjectFactory());
	if (jsfPresent) {
		FacesDependencyRegistrar.registerFacesDependencies(beanFactory);
	}
}
 
Example #3
Source File: WebApplicationContextUtils.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Register web-specific scopes ("request", "session", "globalSession", "application")
 * with the given BeanFactory, as used by the WebApplicationContext.
 * @param beanFactory the BeanFactory to configure
 * @param sc the ServletContext that we're running within
 */
public static void registerWebApplicationScopes(ConfigurableListableBeanFactory beanFactory, ServletContext sc) {
	beanFactory.registerScope(WebApplicationContext.SCOPE_REQUEST, new RequestScope());
	beanFactory.registerScope(WebApplicationContext.SCOPE_SESSION, new SessionScope(false));
	beanFactory.registerScope(WebApplicationContext.SCOPE_GLOBAL_SESSION, new SessionScope(true));
	if (sc != null) {
		ServletContextScope appScope = new ServletContextScope(sc);
		beanFactory.registerScope(WebApplicationContext.SCOPE_APPLICATION, appScope);
		// Register as ServletContext attribute, for ContextCleanupListener to detect it.
		sc.setAttribute(ServletContextScope.class.getName(), appScope);
	}

	beanFactory.registerResolvableDependency(ServletRequest.class, new RequestObjectFactory());
	beanFactory.registerResolvableDependency(ServletResponse.class, new ResponseObjectFactory());
	beanFactory.registerResolvableDependency(HttpSession.class, new SessionObjectFactory());
	beanFactory.registerResolvableDependency(WebRequest.class, new WebRequestObjectFactory());
	if (jsfPresent) {
		FacesDependencyRegistrar.registerFacesDependencies(beanFactory);
	}
}
 
Example #4
Source File: PortletApplicationContextUtils.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
/**
 * Register web-specific scopes ("request", "session", "globalSession")
 * with the given BeanFactory, as used by the Portlet ApplicationContext.
 * @param bf the BeanFactory to configure
 * @param pc the PortletContext that we're running within
 */
static void registerPortletApplicationScopes(ConfigurableListableBeanFactory bf, PortletContext pc) {
	bf.registerScope(WebApplicationContext.SCOPE_REQUEST, new RequestScope());
	bf.registerScope(WebApplicationContext.SCOPE_SESSION, new SessionScope(false));
	bf.registerScope(WebApplicationContext.SCOPE_GLOBAL_SESSION, new SessionScope(true));
	if (pc != null) {
		PortletContextScope appScope = new PortletContextScope(pc);
		bf.registerScope(WebApplicationContext.SCOPE_APPLICATION, appScope);
		// Register as PortletContext attribute, for ContextCleanupListener to detect it.
		pc.setAttribute(PortletContextScope.class.getName(), appScope);
	}

	bf.registerResolvableDependency(PortletRequest.class, new RequestObjectFactory());
	bf.registerResolvableDependency(PortletResponse.class, new ResponseObjectFactory());
	bf.registerResolvableDependency(PortletSession.class, new SessionObjectFactory());
	bf.registerResolvableDependency(WebRequest.class, new WebRequestObjectFactory());
}
 
Example #5
Source File: WebApplicationContextUtils.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
/**
 * Register web-specific scopes ("request", "session", "globalSession", "application")
 * with the given BeanFactory, as used by the WebApplicationContext.
 * @param beanFactory the BeanFactory to configure
 * @param sc the ServletContext that we're running within
 */
public static void registerWebApplicationScopes(ConfigurableListableBeanFactory beanFactory, ServletContext sc) {
	beanFactory.registerScope(WebApplicationContext.SCOPE_REQUEST, new RequestScope());
	beanFactory.registerScope(WebApplicationContext.SCOPE_SESSION, new SessionScope(false));
	beanFactory.registerScope(WebApplicationContext.SCOPE_GLOBAL_SESSION, new SessionScope(true));
	if (sc != null) {
		ServletContextScope appScope = new ServletContextScope(sc);
		beanFactory.registerScope(WebApplicationContext.SCOPE_APPLICATION, appScope);
		// Register as ServletContext attribute, for ContextCleanupListener to detect it.
		sc.setAttribute(ServletContextScope.class.getName(), appScope);
	}

	beanFactory.registerResolvableDependency(ServletRequest.class, new RequestObjectFactory());
	beanFactory.registerResolvableDependency(ServletResponse.class, new ResponseObjectFactory());
	beanFactory.registerResolvableDependency(HttpSession.class, new SessionObjectFactory());
	beanFactory.registerResolvableDependency(WebRequest.class, new WebRequestObjectFactory());
	if (jsfPresent) {
		FacesDependencyRegistrar.registerFacesDependencies(beanFactory);
	}
}
 
Example #6
Source File: AnnotationMethodHandlerAdapter.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void setBeanFactory(BeanFactory beanFactory) {
	if (beanFactory instanceof ConfigurableBeanFactory) {
		this.beanFactory = (ConfigurableBeanFactory) beanFactory;
		this.expressionContext = new BeanExpressionContext(this.beanFactory, new RequestScope());
	}
}
 
Example #7
Source File: AnnotationMethodHandlerAdapter.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
public void setBeanFactory(BeanFactory beanFactory) {
	if (beanFactory instanceof ConfigurableBeanFactory) {
		this.beanFactory = (ConfigurableBeanFactory) beanFactory;
		this.expressionContext = new BeanExpressionContext(this.beanFactory, new RequestScope());
	}
}
 
Example #8
Source File: AnnotationMethodHandlerAdapter.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
public void setBeanFactory(BeanFactory beanFactory) {
	if (beanFactory instanceof ConfigurableBeanFactory) {
		this.beanFactory = (ConfigurableBeanFactory) beanFactory;
		this.expressionContext = new BeanExpressionContext(this.beanFactory, new RequestScope());
	}
}
 
Example #9
Source File: AbstractNamedValueMethodArgumentResolver.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @param beanFactory a bean factory to use for resolving ${...} placeholder
 * and #{...} SpEL expressions in default values, or {@code null} if default
 * values are not expected to contain expressions
 */
public AbstractNamedValueMethodArgumentResolver(ConfigurableBeanFactory beanFactory) {
	this.configurableBeanFactory = beanFactory;
	this.expressionContext =
			(beanFactory != null ? new BeanExpressionContext(beanFactory, new RequestScope()) : null);
}
 
Example #10
Source File: AbstractNamedValueMethodArgumentResolver.java    From spring-analysis-note with MIT License 2 votes vote down vote up
/**
 * Create a new {@link AbstractNamedValueMethodArgumentResolver} instance.
 * @param beanFactory a bean factory to use for resolving ${...} placeholder
 * and #{...} SpEL expressions in default values, or {@code null} if default
 * values are not expected to contain expressions
 */
public AbstractNamedValueMethodArgumentResolver(@Nullable ConfigurableBeanFactory beanFactory) {
	this.configurableBeanFactory = beanFactory;
	this.expressionContext =
			(beanFactory != null ? new BeanExpressionContext(beanFactory, new RequestScope()) : null);
}
 
Example #11
Source File: AbstractNamedValueMethodArgumentResolver.java    From java-technology-stack with MIT License 2 votes vote down vote up
/**
 * Create a new {@link AbstractNamedValueMethodArgumentResolver} instance.
 * @param beanFactory a bean factory to use for resolving ${...} placeholder
 * and #{...} SpEL expressions in default values, or {@code null} if default
 * values are not expected to contain expressions
 */
public AbstractNamedValueMethodArgumentResolver(@Nullable ConfigurableBeanFactory beanFactory) {
	this.configurableBeanFactory = beanFactory;
	this.expressionContext =
			(beanFactory != null ? new BeanExpressionContext(beanFactory, new RequestScope()) : null);
}
 
Example #12
Source File: AbstractNamedValueMethodArgumentResolver.java    From spring4-understanding with Apache License 2.0 2 votes vote down vote up
/**
 * @param beanFactory a bean factory to use for resolving ${...} placeholder
 * and #{...} SpEL expressions in default values, or {@code null} if default
 * values are not expected to contain expressions
 */
public AbstractNamedValueMethodArgumentResolver(ConfigurableBeanFactory beanFactory) {
	this.configurableBeanFactory = beanFactory;
	this.expressionContext = (beanFactory != null ? new BeanExpressionContext(beanFactory, new RequestScope()) : null);
}