Java 类org.springframework.web.context.request.RequestContextListener 实例源码

项目:GeoCrawler    文件:NutchUiServer.java   
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();
}
项目:konker-platform    文件:RegistryAppInitializer.java   
@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()));
}
项目:embeddedjetty9-spring4    文件:SpringMvcInitializer.java   
@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("/");
}
项目:lutece-core    文件:SearchAppTest.java   
/**
 * 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 ) );
}
项目:metamodel-membrane    文件:WebServer.java   
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();
        }
    });
}
项目:reporting-tool    文件:DispatcherServletInitializer.java   
@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);
}
项目:pswot-cloud-java-spring-webapp    文件:ServletSpringMVC.java   
@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");

}
项目:spring-boot    文件:WebMVCConfig.java   
/**
 * 自定义,并注册   listener 演示
 * 直接用 Bean ,也可以用 ServletListenerRegistrationBean
 *
 * @return
 */
// 向系统注册一个 RequestContextListener Bean ,这样在其他组件中就可以使用了
//  CustomUserDetailsService 用到,用于截获 HttpServletRequest
//  @Autowired
//  private HttpServletRequest request;
@Bean
public RequestContextListener requestContextListener() {

    return new RequestContextListener();
}
项目:rest-retro-sample    文件:ClientSecureWebAppInitializer.java   
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    super.onStartup(servletContext);
    registerProxyFilter(servletContext, "springSecurityFilterChain");
    registerProxyFilter(servletContext, "oauth2ClientContextFilter");
    registerProxyFilter(servletContext, "customOauth2ClientContextFilter");
    servletContext.addListener(RequestContextListener.class);
}
项目:metl    文件:AppInitializer.java   
@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("/*");
}
项目:jsf-exmple    文件:MyWebAppInitializer.java   
@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);
}
项目:bearchoke    文件:AbstractWebApplicationInitializer.java   
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");
    }
项目:AIDR    文件:ApplicationInitializer.java   
@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("/*");
}
项目:sweiproject-tg2b-1    文件:MvcConfig.java   
@Bean
@ConditionalOnMissingBean(RequestContextListener.class)
public RequestContextListener requestContextListener() {
    return new RequestContextListener();
}
项目:kafka-webview    文件:SecurityConfig.java   
@Bean
public RequestContextListener requestContextListener() {
    return new RequestContextListener();
}
项目:DiscussionPortal    文件:DiscussionPortalApplication.java   
@Bean
public RequestContextListener requestContextListener() {
    return new RequestContextListener();
}
项目:ait-platform    文件:AitOAuth2ConfigBase.java   
@Bean
public RequestContextListener requestContextListener() {
    return new RequestContextListener();
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:WebMvcAutoConfiguration.java   
@Bean
@ConditionalOnMissingBean({ RequestContextListener.class,
        RequestContextFilter.class })
public static RequestContextFilter requestContextFilter() {
    return new OrderedRequestContextFilter();
}
项目:spring-security-registration    文件:MvcConfig.java   
@Bean
@ConditionalOnMissingBean(RequestContextListener.class)
public RequestContextListener requestContextListener() {
    return new RequestContextListener();
}
项目:spring-security-registration    文件:Application.java   
@Bean
public RequestContextListener requestContextListener() {
    return new RequestContextListener();
}
项目:spring-security-registration    文件:TestIntegrationConfig.java   
@Bean
@ConditionalOnMissingBean(RequestContextListener.class)
public RequestContextListener requestContextListener() {

    return new RequestContextListener();
}
项目:singular-server    文件:SpringHibernateInitializer.java   
protected void addSpringRequestContextListener(ServletContext ctx, AnnotationConfigWebApplicationContext applicationContext) {
    ctx.addListener(RequestContextListener.class);
}
项目:spring-boot-concourse    文件:WebMvcAutoConfiguration.java   
@Bean
@ConditionalOnMissingBean({ RequestContextListener.class,
        RequestContextFilter.class })
public RequestContextFilter requestContextFilter() {
    return new OrderedRequestContextFilter();
}
项目:dxa-modules    文件:AudienceManagerInitializer.java   
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    InitializationUtils.registerListener(servletContext, RequestContextListener.class);
    InitializationUtils.registerFilter(servletContext, "springSecurityFilterChain", DelegatingFilterProxy.class, "/*");
}
项目:contestparser    文件:WebMvcAutoConfiguration.java   
@Bean
@ConditionalOnMissingBean({ RequestContextListener.class,
        RequestContextFilter.class })
public RequestContextFilter requestContextFilter() {
    return new OrderedRequestContextFilter();
}
项目:nextrtc-videochat-with-rest    文件:WebSecurityConfig.java   
@Bean
public RequestContextListener requestContextListener() {
    return new RequestContextListener();
}
项目:Estudo-Spring    文件:ServletDispatcherInitializer.java   
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    super.onStartup(servletContext);
    servletContext.addListener(RequestContextListener.class);
    servletContext.setInitParameter("spring.profiles.active", "dev");
}
项目:faostat-api    文件:TestMetadata.java   
public TestMetadata() {
    super(new WebAppDescriptor.Builder("org.fao.faostat.api.web.rest").contextPath("testing")
            .contextParam("contextConfigLocation", "classpath:testApplicationContext.xml")
            .contextListenerClass(ContextLoaderListener.class).servletClass(SpringServlet.class)
            .requestListenerClass(RequestContextListener.class).build());
}
项目:faostat-api    文件:TestDimensions.java   
public TestDimensions() {
    super(new WebAppDescriptor.Builder("org.fao.faostat.api.web.rest").contextPath("testing")
            .contextParam("contextConfigLocation", "classpath:testApplicationContext.xml")
            .contextListenerClass(ContextLoaderListener.class).servletClass(SpringServlet.class)
            .requestListenerClass(RequestContextListener.class).build());
}
项目:faostat-api    文件:TestData.java   
public TestData() {
    super(new WebAppDescriptor.Builder("org.fao.faostat.api.web.rest").contextPath("testing")
            .contextParam("contextConfigLocation", "classpath:testApplicationContext.xml")
            .contextListenerClass(ContextLoaderListener.class).servletClass(SpringServlet.class)
            .requestListenerClass(RequestContextListener.class).build());
}
项目:faostat-api    文件:TestDataAllDomains.java   
public TestDataAllDomains() {
    super(new WebAppDescriptor.Builder("org.fao.faostat.api.web.rest").contextPath("testing")
            .contextParam("contextConfigLocation", "classpath:testApplicationContext.xml")
            .contextListenerClass(ContextLoaderListener.class).servletClass(SpringServlet.class)
            .requestListenerClass(RequestContextListener.class).build());
}
项目:faostat-api    文件:TestSearch.java   
public TestSearch() {
    super(new WebAppDescriptor.Builder("org.fao.faostat.api.web.rest").contextPath("testing")
            .contextParam("contextConfigLocation", "classpath:testApplicationContext.xml")
            .contextListenerClass(ContextLoaderListener.class).servletClass(SpringServlet.class)
            .requestListenerClass(RequestContextListener.class).build());
}
项目:faostat-api    文件:TestDocuments.java   
public TestDocuments() {
    super(new WebAppDescriptor.Builder("org.fao.faostat.api.web.rest").contextPath("testing")
            .contextParam("contextConfigLocation", "classpath:testApplicationContext.xml")
            .contextListenerClass(ContextLoaderListener.class).servletClass(SpringServlet.class)
            .requestListenerClass(RequestContextListener.class).build());
}
项目:faostat-api    文件:TestGroupsAndDomains.java   
public TestGroupsAndDomains() {
    super(new WebAppDescriptor.Builder("org.fao.faostat.api.web.rest").contextPath("testing")
            .contextParam("contextConfigLocation", "classpath:testApplicationContext.xml")
            .contextListenerClass(ContextLoaderListener.class).servletClass(SpringServlet.class)
            .requestListenerClass(RequestContextListener.class).build());
}
项目:faostat-api    文件:TestSchema.java   
public TestSchema() {
    super(new WebAppDescriptor.Builder("org.fao.faostat.api.web.rest").contextPath("testing")
            .contextParam("contextConfigLocation", "classpath:testApplicationContext.xml")
            .contextListenerClass(ContextLoaderListener.class).servletClass(SpringServlet.class)
            .requestListenerClass(RequestContextListener.class).build());
}
项目:faostat-api    文件:TestBulkDownloads.java   
public TestBulkDownloads() {
    super(new WebAppDescriptor.Builder("org.fao.faostat.api.web.rest").contextPath("testing")
            .contextParam("contextConfigLocation", "classpath:testApplicationContext.xml")
            .contextListenerClass(ContextLoaderListener.class).servletClass(SpringServlet.class)
            .requestListenerClass(RequestContextListener.class).build());
}
项目:faostat-api    文件:TestCodes.java   
public TestCodes() {
    super(new WebAppDescriptor.Builder("org.fao.faostat.api.web.rest").contextPath("testing")
            .contextParam("contextConfigLocation", "classpath:testApplicationContext.xml")
            .contextListenerClass(ContextLoaderListener.class).servletClass(SpringServlet.class)
            .requestListenerClass(RequestContextListener.class).build());
}
项目:faostat-api    文件:TestCodesAllDomains.java   
public TestCodesAllDomains() {
    super(new WebAppDescriptor.Builder("org.fao.faostat.api.web.rest").contextPath("testing")
            .contextParam("contextConfigLocation", "classpath:testApplicationContext.xml")
            .contextListenerClass(ContextLoaderListener.class).servletClass(SpringServlet.class)
            .requestListenerClass(RequestContextListener.class).build());
}
项目:faostat-api    文件:TestDefinitions.java   
public TestDefinitions() {
    super(new WebAppDescriptor.Builder("org.fao.faostat.api.web.rest").contextPath("testing")
            .contextParam("contextConfigLocation", "classpath:testApplicationContext.xml")
            .contextListenerClass(ContextLoaderListener.class).servletClass(SpringServlet.class)
            .requestListenerClass(RequestContextListener.class).build());
}
项目:pa165_haunted_houses    文件:Initializer.java   
@Override
public void onStartup(javax.servlet.ServletContext servletContext) throws javax.servlet.ServletException {
    super.onStartup(servletContext);
    servletContext.addListener(RequestContextListener.class);
}