本文整理汇总了Java中org.springframework.web.context.request.RequestScope类的典型用法代码示例。如果您正苦于以下问题:Java RequestScope类的具体用法?Java RequestScope怎么用?Java RequestScope使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RequestScope类属于org.springframework.web.context.request包,在下文中一共展示了RequestScope类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: registerWebApplicationScopes
import org.springframework.web.context.request.RequestScope; //导入依赖的package包/类
/**
* 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(HttpSession.class, new SessionObjectFactory());
beanFactory.registerResolvableDependency(WebRequest.class, new WebRequestObjectFactory());
if (jsfPresent) {
FacesDependencyRegistrar.registerFacesDependencies(beanFactory);
}
}
示例2: registerPortletApplicationScopes
import org.springframework.web.context.request.RequestScope; //导入依赖的package包/类
/**
* 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());
}
示例3: registerWebApplicationScopes
import org.springframework.web.context.request.RequestScope; //导入依赖的package包/类
/**
* 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);
}
}
示例4: registerPortletApplicationScopes
import org.springframework.web.context.request.RequestScope; //导入依赖的package包/类
/**
* Register web-specific scopes ("request", "session", "globalSession")
* with the given BeanFactory, as used by the Portlet ApplicationContext.
* @param beanFactory the BeanFactory to configure
* @param pc the PortletContext that we're running within
*/
static void registerPortletApplicationScopes(ConfigurableListableBeanFactory beanFactory, PortletContext pc) {
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 (pc != null) {
PortletContextScope appScope = new PortletContextScope(pc);
beanFactory.registerScope(WebApplicationContext.SCOPE_APPLICATION, appScope);
// Register as PortletContext attribute, for ContextCleanupListener to detect it.
pc.setAttribute(PortletContextScope.class.getName(), appScope);
}
beanFactory.registerResolvableDependency(PortletRequest.class, new RequestObjectFactory());
beanFactory.registerResolvableDependency(PortletSession.class, new SessionObjectFactory());
beanFactory.registerResolvableDependency(WebRequest.class, new WebRequestObjectFactory());
}
示例5: setBeanFactory
import org.springframework.web.context.request.RequestScope; //导入依赖的package包/类
@Override
public void setBeanFactory(BeanFactory beanFactory) {
if (beanFactory instanceof ConfigurableBeanFactory) {
this.beanFactory = (ConfigurableBeanFactory) beanFactory;
this.expressionContext = new BeanExpressionContext(this.beanFactory, new RequestScope());
}
}
示例6: getContext
import org.springframework.web.context.request.RequestScope; //导入依赖的package包/类
public static MergeClassPathXMLApplicationContext getContext() {
try {
if (mergeContext == null) {
// Note that as of 2.2.0, this array will no longer include "bl-applicationContext-test", as we want that to
// be the very last context loaded.
String[] contexts = StandardConfigLocations.retrieveAll(StandardConfigLocations.TESTCONTEXTTYPE);
// After the framework applicationContexts are loaded, we want the module ones
List<String> additionalContexts = new ArrayList<String>(moduleContexts);
// Lastly, we want the test applicationContext
additionalContexts.add("bl-applicationContext-test.xml");
// If we're running in legacy test mode, we need that one too
if (ManagementFactory.getRuntimeMXBean().getInputArguments().contains("-Dlegacy=true")) {
additionalContexts.add("bl-applicationContext-test-legacy.xml");
}
String[] strArray = new String[additionalContexts.size()];
mergeContext = new MergeClassPathXMLApplicationContext(contexts, additionalContexts.toArray(strArray));
//allow for request-scoped beans that can occur in web application contexts
RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(new MockHttpServletRequest()));
mergeContext.getBeanFactory().registerScope("request", new RequestScope());
}
} catch (Exception e) {
throw new RuntimeException(e);
}
return mergeContext;
}
示例7: getContext
import org.springframework.web.context.request.RequestScope; //导入依赖的package包/类
public static MergeClassPathXMLApplicationContext getContext() {
try {
if (mergeContext == null) {
// Note that as of 2.2.0, this array will no longer include "spark-applicationContext-test", as we want that to
// be the very last context loaded.
String[] contexts = StandardConfigLocations.retrieveAll(StandardConfigLocations.TESTCONTEXTTYPE);
// After the framework applicationContexts are loaded, we want the module ones
List<String> additionalContexts = new ArrayList<String>(moduleContexts);
// Lastly, we want the test applicationContext
additionalContexts.add("spark-applicationContext-test.xml");
// If we're running in legacy test mode, we need that one too
if (ManagementFactory.getRuntimeMXBean().getInputArguments().contains("-Dlegacy=true")) {
additionalContexts.add("spark-applicationContext-test-legacy.xml");
}
String[] strArray = new String[additionalContexts.size()];
mergeContext = new MergeClassPathXMLApplicationContext(contexts, additionalContexts.toArray(strArray));
//allow for request-scoped beans that can occur in web application contexts
RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(new MockHttpServletRequest()));
mergeContext.getBeanFactory().registerScope("request", new RequestScope());
}
} catch (Exception e) {
throw new RuntimeException(e);
}
return mergeContext;
}
示例8: getContext
import org.springframework.web.context.request.RequestScope; //导入依赖的package包/类
public static MergeClassPathXMLApplicationContext getContext() {
try {
if (mergeContext == null) {
// Note that as of 2.2.0, this array will no longer include "bl-applicationContext-test", as we want that to
// be the very last context loaded.
String[] contexts = StandardConfigLocations.retrieveAll(StandardConfigLocations.TESTCONTEXTTYPE);
// After the framework applicationContexts are loaded, we want the module ones
List<String> additionalContexts = new ArrayList<String>(moduleContexts);
// We need the content applicationContexts and admin applicationContexts
additionalContexts.add("bl-open-admin-contentClient-applicationContext.xml");
additionalContexts.add("bl-open-admin-contentCreator-applicationContext.xml");
additionalContexts.add("bl-admin-applicationContext.xml");
// Lastly, we want the test applicationContext
additionalContexts.add("bl-applicationContext-test.xml");
// If we're running in legacy test mode, we need that one too
if (ManagementFactory.getRuntimeMXBean().getInputArguments().contains("-Dlegacy=true")) {
additionalContexts.add("bl-applicationContext-test-legacy.xml");
}
String[] strArray = new String[additionalContexts.size()];
mergeContext = new MergeClassPathXMLApplicationContext(contexts, additionalContexts.toArray(strArray));
//allow for request-scoped beans that can occur in web application contexts
RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(new MockHttpServletRequest()));
mergeContext.getBeanFactory().registerScope("request", new RequestScope());
}
} catch (Exception e) {
throw new RuntimeException(e);
}
return mergeContext;
}
示例9: setBeanFactory
import org.springframework.web.context.request.RequestScope; //导入依赖的package包/类
public void setBeanFactory(BeanFactory beanFactory) {
if (beanFactory instanceof ConfigurableBeanFactory) {
this.beanFactory = (ConfigurableBeanFactory) beanFactory;
this.expressionContext = new BeanExpressionContext(
this.beanFactory, new RequestScope());
}
}
示例10: addCustomScopeConfigurerBean
import org.springframework.web.context.request.RequestScope; //导入依赖的package包/类
private void addCustomScopeConfigurerBean() {
AutowireCapableBeanFactory autowireCapableBeanFactory = getAutowireCapableBeanFactory();
CustomScopeConfigurer customScopeConfigurer = (CustomScopeConfigurer) autowireCapableBeanFactory.createBean(CustomScopeConfigurer.class);
HashMap map = new HashMap();
map.put(RequestManager.SESSION, SessionScope.class);
map.put(RequestManager.REQUEST, RequestScope.class);
customScopeConfigurer.setScopes(map);
autowireCapableBeanFactory.initializeBean(customScopeConfigurer, SCOPE_CONFIGURER);
}
示例11: setBeanFactory
import org.springframework.web.context.request.RequestScope; //导入依赖的package包/类
public void setBeanFactory(BeanFactory beanFactory) {
if (beanFactory instanceof ConfigurableBeanFactory) {
this.beanFactory = (ConfigurableBeanFactory) beanFactory;
this.expressionContext = new BeanExpressionContext(this.beanFactory, new RequestScope());
}
}
示例12: AbstractNamedValueMethodArgumentResolver
import org.springframework.web.context.request.RequestScope; //导入依赖的package包/类
/**
* @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);
}
示例13: AbstractNamedValueMethodArgumentResolver
import org.springframework.web.context.request.RequestScope; //导入依赖的package包/类
/**
* @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;
}