• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java RequestScope类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:25,代码来源:WebApplicationContextUtils.java


示例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());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:23,代码来源:PortletApplicationContextUtils.java


示例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);
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:26,代码来源:WebApplicationContextUtils.java


示例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());
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:22,代码来源:PortletApplicationContextUtils.java


示例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());
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:8,代码来源:AnnotationMethodHandlerAdapter.java


示例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;
}
 
开发者ID:passion1014,项目名称:metaworks_framework,代码行数:32,代码来源:BaseTest.java


示例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;
}
 
开发者ID:akdasari,项目名称:SparkCommerce,代码行数:32,代码来源:BaseTest.java


示例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;
}
 
开发者ID:takbani,项目名称:blcdemo,代码行数:37,代码来源:BaseTest.java


示例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());
	}
}
 
开发者ID:xiyelife,项目名称:jresplus,代码行数:8,代码来源:ExtendableAnnotationMethodHandlerAdapter.java


示例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);
}
 
开发者ID:geub,项目名称:spring-struts-testcase,代码行数:10,代码来源:TestXmlWebApplicationContext.java


示例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());
	}
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:7,代码来源:AnnotationMethodHandlerAdapter.java


示例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);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:AbstractNamedValueMethodArgumentResolver.java


示例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;
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:10,代码来源:AbstractNamedValueMethodArgumentResolver.java



注:本文中的org.springframework.web.context.request.RequestScope类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ByteEntityData类代码示例发布时间:2022-05-22
下一篇:
Java EntityExplosionPrimeEvent类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap