当前位置: 首页>>代码示例>>Java>>正文


Java RequestContextListener类代码示例

本文整理汇总了Java中org.springframework.web.context.request.RequestContextListener的典型用法代码示例。如果您正苦于以下问题:Java RequestContextListener类的具体用法?Java RequestContextListener怎么用?Java RequestContextListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


RequestContextListener类属于org.springframework.web.context.request包,在下文中一共展示了RequestContextListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: startServer

import org.springframework.web.context.request.RequestContextListener; //导入依赖的package包/类
private static void startServer() throws Exception, InterruptedException {
  Server server = new Server(port);
  Context context = new Context(server, "/", Context.SESSIONS);
  context.addServlet(DefaultServlet.class, "/*");

  context.addEventListener(new ContextLoaderListener(getContext()));
  context.addEventListener(new RequestContextListener());

  WicketFilter filter = new WicketFilter();
  filter.setFilterPath("/");
  FilterHolder holder = new FilterHolder(filter);
  holder.setInitParameter("applicationFactoryClassName", APP_FACTORY_NAME);
  context.addFilter(holder, "/*", Handler.DEFAULT);

  server.setHandler(context);
  server.start();
  server.join();
}
 
开发者ID:jorcox,项目名称:GeoCrawler,代码行数:19,代码来源:NutchUiServer.java

示例2: onStartup

import org.springframework.web.context.request.RequestContextListener; //导入依赖的package包/类
@Override
public void onStartup(ServletContext servletContext) throws ServletException {

    super.onStartup(servletContext);
    servletContext.addListener(new RequestContextListener());

    // verifying configs for features activation
    Set<String> profiles = new HashSet<String>();
    if (isEmailFeaturesEnabled()) {
        profiles.add("email");
    }
    if (isCdnFeaturesEnabled()) {
        profiles.add("cdn");
    }
    if (isSslFeaturesEnabled()) {
        profiles.add("ssl");
    }

    servletContext.setInitParameter("spring.profiles.active", StringUtils.arrayToCommaDelimitedString(profiles.toArray()));
}
 
开发者ID:KonkerLabs,项目名称:konker-platform,代码行数:21,代码来源:RegistryAppInitializer.java

示例3: onStartup

import org.springframework.web.context.request.RequestContextListener; //导入依赖的package包/类
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
	
	//create a new Spring webapp context and add core listeners for requests and lifecycle events
       AnnotationConfigWebApplicationContext webAppContext = new AnnotationConfigWebApplicationContext();
	servletContext.addListener(RequestContextListener.class);
	servletContext.addListener(new ContextLoaderListener(webAppContext));
	
       //tell Spring where to find @Configuration classes for further Spring config
       webAppContext.setConfigLocation(SPRING_CONFIG_PACKAGE);
       
       //create Spring's Dispatcher servlet and tell the servletContext it is present
       DispatcherServlet dispatcherServlet = new DispatcherServlet(webAppContext);
       dispatcherServlet.setThrowExceptionIfNoHandlerFound(true);
       ServletRegistration.Dynamic dispatcher = servletContext.addServlet("dispatcherServlet", dispatcherServlet);
       
       //perform additional dispatcher servlet config
       dispatcher.setLoadOnStartup(1);
       dispatcher.addMapping("/");
}
 
开发者ID:orb15,项目名称:embeddedjetty9-spring4,代码行数:21,代码来源:SpringMvcInitializer.java

示例4: testGetPage

import org.springframework.web.context.request.RequestContextListener; //导入依赖的package包/类
/**
 * Test of getPage method, of class fr.paris.lutece.portal.web.search.SearchApp.
 * 
 * @throws SiteMessageException
 */
public void testGetPage( ) throws SiteMessageException
{
    System.out.println( "getPage" );

    MockHttpServletRequest request = new MockHttpServletRequest( );
    request.addParameter( "query", "lutece" );
    request.addParameter( "items_per_page", "5" );

    RequestContextListener listener = new RequestContextListener( );
    ServletContext context = new MockServletContext( );
    listener.requestInitialized( new ServletRequestEvent( context, request ) );

    int nMode = 0;
    Plugin plugin = null;
    SearchApp instance = SpringContextService.getBean( "core.xpage.search" );

    XPage result = instance.getPage( request, nMode, plugin );

    listener.requestDestroyed( new ServletRequestEvent( context, request ) );
}
 
开发者ID:lutece-platform,项目名称:lutece-core,代码行数:26,代码来源:SearchAppTest.java

示例5: startServer

import org.springframework.web.context.request.RequestContextListener; //导入依赖的package包/类
public static void startServer(int port) throws Exception {
    final DeploymentInfo deployment = Servlets.deployment().setClassLoader(WebServer.class.getClassLoader());
    deployment.setContextPath("");
    deployment.setDeploymentName("membrane");
    deployment.addInitParameter("contextConfigLocation", "classpath:context/application-context.xml");
    deployment.setResourceManager(new FileResourceManager(new File("."), 0));
    deployment.addListener(Servlets.listener(ContextLoaderListener.class));
    deployment.addListener(Servlets.listener(RequestContextListener.class));
    deployment.addServlet(Servlets.servlet("dispatcher", DispatcherServlet.class).addMapping("/*")
            .addInitParam("contextConfigLocation", "classpath:context/dispatcher-servlet.xml"));
    deployment.addFilter(Servlets.filter(CharacterEncodingFilter.class).addInitParam("forceEncoding", "true")
            .addInitParam("encoding", "UTF-8"));

    final DeploymentManager manager = Servlets.defaultContainer().addDeployment(deployment);
    manager.deploy();

    final Undertow server = Undertow.builder().addHttpListener(port, "0.0.0.0").setHandler(manager.start()).build();
    server.start();

    Runtime.getRuntime().addShutdownHook(new Thread() {
        @Override
        public void run() {
            // graceful shutdown of everything
            server.stop();
            try {
                manager.stop();
            } catch (ServletException e) {
            }
            manager.undeploy();
        }
    });
}
 
开发者ID:apache,项目名称:metamodel-membrane,代码行数:33,代码来源:WebServer.java

示例6: onStartup

import org.springframework.web.context.request.RequestContextListener; //导入依赖的package包/类
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    System.out.println("****** Application Context Initialization ******");

    initSecurityFilter(servletContext);
    servletContext.addListener(new RequestContextListener());
    servletContext.getSessionCookieConfig().setName(SecurityConstants.SESSION_COOKIE_NAME);
    super.onStartup(servletContext);
}
 
开发者ID:kbss-cvut,项目名称:reporting-tool,代码行数:10,代码来源:DispatcherServletInitializer.java

示例7: onStartup

import org.springframework.web.context.request.RequestContextListener; //导入依赖的package包/类
@Override
public void onStartup(ServletContext servletContext) // Define qual é o contexto ativo no momento
        throws ServletException {
    super.onStartup(servletContext);
    servletContext.addListener(RequestContextListener.class);
    servletContext.setInitParameter(
            AbstractEnvironment.DEFAULT_PROFILES_PROPERTY_NAME, "dev");

}
 
开发者ID:nailtonvieira,项目名称:pswot-cloud-java-spring-webapp,代码行数:10,代码来源:ServletSpringMVC.java

示例8: requestContextListener

import org.springframework.web.context.request.RequestContextListener; //导入依赖的package包/类
/**
 * 自定义,并注册   listener 演示
 * 直接用 Bean ,也可以用 ServletListenerRegistrationBean
 *
 * @return
 */
// 向系统注册一个 RequestContextListener Bean ,这样在其他组件中就可以使用了
//  CustomUserDetailsService 用到,用于截获 HttpServletRequest
//  @Autowired
//  private HttpServletRequest request;
@Bean
public RequestContextListener requestContextListener() {

    return new RequestContextListener();
}
 
开发者ID:h819,项目名称:spring-boot,代码行数:16,代码来源:WebMVCConfig.java

示例9: onStartup

import org.springframework.web.context.request.RequestContextListener; //导入依赖的package包/类
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
	super.onStartup(servletContext);
	registerProxyFilter(servletContext, "springSecurityFilterChain");
	registerProxyFilter(servletContext, "oauth2ClientContextFilter");
	registerProxyFilter(servletContext, "customOauth2ClientContextFilter");
	servletContext.addListener(RequestContextListener.class);
}
 
开发者ID:ishaigor,项目名称:rest-retro-sample,代码行数:9,代码来源:ClientSecureWebAppInitializer.java

示例10: onStartup

import org.springframework.web.context.request.RequestContextListener; //导入依赖的package包/类
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    System.out.println("Version: " + VersionUtils.getCurrentVersion());
    properties = loadProperties();
    LogUtils.initLogging(getConfigDir(false), (TypedProperties) properties);
    AnnotationConfigWebApplicationContext applicationContext = new AnnotationConfigWebApplicationContext();
    applicationContext.scan("org.jumpmind.metl");
    MutablePropertySources sources = applicationContext.getEnvironment().getPropertySources();
    sources.addLast(new PropertiesPropertySource("passed in properties", properties));
    servletContext.addListener(new ContextLoaderListener(applicationContext));
    servletContext.addListener(this);
    servletContext.addListener(new RequestContextListener());

    AnnotationConfigWebApplicationContext dispatchContext = new AnnotationConfigWebApplicationContext();
    dispatchContext.setParent(applicationContext);
    ServletRegistration.Dynamic dispatcher = servletContext.addServlet("dispatcher", new DispatcherServlet(dispatchContext));
    dispatcher.setLoadOnStartup(1);
    dispatcher.addMapping("/api/*");
    applicationContextRef.set(dispatchContext);

    ServletRegistration.Dynamic apidocs = servletContext.addServlet("docs", DefaultServlet.class);
    apidocs.addMapping("/api.html", "/ws-api.html", "/doc/*", "/ace/*");
    
    ServletRegistration.Dynamic vaadin = servletContext.addServlet("vaadin", AppServlet.class);
    vaadin.setAsyncSupported(true);
    vaadin.setInitParameter("org.atmosphere.cpr.asyncSupport", JSR356AsyncSupport.class.getName());
    vaadin.setInitParameter("beanName", "appUI");
    vaadin.addMapping("/*");
}
 
开发者ID:JumpMind,项目名称:metl,代码行数:30,代码来源:AppInitializer.java

示例11: onStartup

import org.springframework.web.context.request.RequestContextListener; //导入依赖的package包/类
@Override
public void onStartup(ServletContext servletContext)
		throws ServletException {
	super.onStartup(servletContext);
	Dynamic faces = servletContext.addServlet("Faces Servlet",
			"javax.faces.webapp.FacesServlet");
	faces.addMapping("*.html");
	//ConfigureListener listener = new ConfigureListener();
	//servletContext.addListener(listener);
	servletContext.addListener(new RequestContextListener());
	Dynamic elResolverInitializer = servletContext.addServlet(
			"elResolverInit", new ELResolverInitializerServlet());
	elResolverInitializer.setLoadOnStartup(2);
}
 
开发者ID:JensKapitza,项目名称:jsf-exmple,代码行数:15,代码来源:MyWebAppInitializer.java

示例12: createWebApplicationContext

import org.springframework.web.context.request.RequestContextListener; //导入依赖的package包/类
protected void createWebApplicationContext(ServletContext servletContext, Class clazz) {
        log.info("Creating Web Application Context started");

        List<Class> configClasses = new ArrayList<>();
        configClasses.add(clazz);

        // let's determine if this is a cloud based server
        Cloud cloud = getCloud();

        String activeProfiles = System.getProperty(SPRING_PROFILES_ACTIVE);

        if (StringUtils.isEmpty(activeProfiles)) {
            if (cloud == null) {
                // if no active profiles are specified, we default to these profiles
                activeProfiles = String.format("%s,%s,%s,%s,%s", MONGODB_LOCAL,REDIS_LOCAL,RABBIT_LOCAL,ELASTICSEARCH_LOCAL,LOCAL);
            } else {
                activeProfiles = String.format("%s,%s,%s,%s,%s", MONGODB_CLOUD,REDIS_CLOUD,RABBIT_CLOUD,ELASTICSEARCH_CLOUD,CLOUD);
            }
        }

        log.info("Active spring profiles: " + activeProfiles);

        // load local or cloud based configs
        if (cloud != null) {

            // list available service - fail servlet initializing if we are missing one that we require below
            printAvailableCloudServices(cloud.getServiceInfos());

        }

        AnnotationConfigWebApplicationContext appContext = new AnnotationConfigWebApplicationContext();
        appContext.register(configClasses.toArray(new Class[configClasses.size()]));

        servletContext.addListener(new ContextLoaderListener(appContext));
        servletContext.addListener(new RequestContextListener());

//        log.info("Creating Web Application Context completed");
    }
 
开发者ID:bjornharvold,项目名称:bearchoke,代码行数:39,代码来源:AbstractWebApplicationInitializer.java

示例13: onStartup

import org.springframework.web.context.request.RequestContextListener; //导入依赖的package包/类
@Override
public void onStartup(ServletContext servletContext) throws ServletException {

	/* Setting the configuration classes */
	AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
	context.setConfigLocation("qa.qcri.aidr.data.config");

	/*Configuring error handler filter for errors out isde the controllers
	FilterRegistration.Dynamic errorHandlerFilter = servletContext.addFilter("errorHandlerFilter", new ErrorHandlerFilter());
	errorHandlerFilter.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), true, "/*");
	*/
	FilterRegistration.Dynamic encodingFilter = servletContext.addFilter("encodingFilter", new org.springframework.web.filter.CharacterEncodingFilter());
	encodingFilter.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), true, "/*");
	encodingFilter.setInitParameter("encoding", "UTF-8");
	encodingFilter.setInitParameter("forceEncoding", "true");
	
	/* Adding context listener */
	servletContext.addListener(new ContextLoaderListener(context));
	
	/* Adding request listener */
	servletContext.addListener(new RequestContextListener());

	/* Configuring dispatcher servlet for spring mvc */
	/*CustomDispatcherServlet servlet = new CustomDispatcherServlet(context); */
	ServletRegistration.Dynamic appServlet = servletContext.addServlet("dispatcher", new DispatcherServlet(context));
	appServlet.setLoadOnStartup(1);
	appServlet.addMapping("/*");
}
 
开发者ID:qcri-social,项目名称:AIDR,代码行数:29,代码来源:ApplicationInitializer.java

示例14: requestContextListener

import org.springframework.web.context.request.RequestContextListener; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean(RequestContextListener.class)
public RequestContextListener requestContextListener() {
    return new RequestContextListener();
}
 
开发者ID:sweIhm,项目名称:sweiproject-tg2b-1,代码行数:6,代码来源:MvcConfig.java

示例15: requestContextListener

import org.springframework.web.context.request.RequestContextListener; //导入依赖的package包/类
@Bean
public RequestContextListener requestContextListener() {
    return new RequestContextListener();
}
 
开发者ID:SourceLabOrg,项目名称:kafka-webview,代码行数:5,代码来源:SecurityConfig.java


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