Java Code Examples for org.springframework.web.context.request.RequestContextListener
The following are top voted examples for showing how to use
org.springframework.web.context.request.RequestContextListener. These examples are extracted from open source projects.
You can vote up the examples you like and your votes will be used in our system to generate
more good examples.
Example 1
Project: GeoCrawler File: NutchUiServer.java View source code | 7 votes |
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(); }
Example 2
Project: konker-platform File: RegistryAppInitializer.java View source code | 6 votes |
@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())); }
Example 3
Project: embeddedjetty9-spring4 File: SpringMvcInitializer.java View source code | 6 votes |
@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("/"); }
Example 4
Project: lutece-core File: SearchAppTest.java View source code | 6 votes |
/** * 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 ) ); }
Example 5
Project: metamodel-membrane File: WebServer.java View source code | 5 votes |
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(); } }); }
Example 6
Project: reporting-tool File: DispatcherServletInitializer.java View source code | 5 votes |
@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); }
Example 7
Project: pswot-cloud-java-spring-webapp File: ServletSpringMVC.java View source code | 5 votes |
@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"); }
Example 8
Project: spring-boot File: WebMVCConfig.java View source code | 5 votes |
/** * 自定义,并注册 listener 演示 * 直接用 Bean ,也可以用 ServletListenerRegistrationBean * * @return */ // 向系统注册一个 RequestContextListener Bean ,这样在其他组件中就可以使用了 // CustomUserDetailsService 用到,用于截获 HttpServletRequest // @Autowired // private HttpServletRequest request; @Bean public RequestContextListener requestContextListener() { return new RequestContextListener(); }
Example 9
Project: rest-retro-sample File: ClientSecureWebAppInitializer.java View source code | 5 votes |
@Override public void onStartup(ServletContext servletContext) throws ServletException { super.onStartup(servletContext); registerProxyFilter(servletContext, "springSecurityFilterChain"); registerProxyFilter(servletContext, "oauth2ClientContextFilter"); registerProxyFilter(servletContext, "customOauth2ClientContextFilter"); servletContext.addListener(RequestContextListener.class); }
Example 10
Project: metl File: AppInitializer.java View source code | 5 votes |
@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("/*"); }
Example 11
Project: jsf-exmple File: MyWebAppInitializer.java View source code | 5 votes |
@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); }
Example 12
Project: bearchoke File: AbstractWebApplicationInitializer.java View source code | 5 votes |
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"); }
Example 13
Project: AIDR File: ApplicationInitializer.java View source code | 5 votes |
@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("/*"); }
Example 14
Project: sweiproject-tg2b-1 File: MvcConfig.java View source code | 4 votes |
@Bean @ConditionalOnMissingBean(RequestContextListener.class) public RequestContextListener requestContextListener() { return new RequestContextListener(); }
Example 15
Project: kafka-webview File: SecurityConfig.java View source code | 4 votes |
@Bean public RequestContextListener requestContextListener() { return new RequestContextListener(); }
Example 16
Project: DiscussionPortal File: DiscussionPortalApplication.java View source code | 4 votes |
@Bean public RequestContextListener requestContextListener() { return new RequestContextListener(); }
Example 17
Project: ait-platform File: AitOAuth2ConfigBase.java View source code | 4 votes |
@Bean public RequestContextListener requestContextListener() { return new RequestContextListener(); }
Example 18
Project: https-github.com-g0t4-jenkins2-course-spring-boot File: WebMvcAutoConfiguration.java View source code | 4 votes |
@Bean @ConditionalOnMissingBean({ RequestContextListener.class, RequestContextFilter.class }) public static RequestContextFilter requestContextFilter() { return new OrderedRequestContextFilter(); }
Example 19
Project: spring-security-registration File: MvcConfig.java View source code | 4 votes |
@Bean @ConditionalOnMissingBean(RequestContextListener.class) public RequestContextListener requestContextListener() { return new RequestContextListener(); }
Example 20
Project: spring-security-registration File: Application.java View source code | 4 votes |
@Bean public RequestContextListener requestContextListener() { return new RequestContextListener(); }
Example 21
Project: spring-security-registration File: TestIntegrationConfig.java View source code | 4 votes |
@Bean @ConditionalOnMissingBean(RequestContextListener.class) public RequestContextListener requestContextListener() { return new RequestContextListener(); }
Example 22
Project: singular-server File: SpringHibernateInitializer.java View source code | 4 votes |
protected void addSpringRequestContextListener(ServletContext ctx, AnnotationConfigWebApplicationContext applicationContext) { ctx.addListener(RequestContextListener.class); }
Example 23
Project: spring-boot-concourse File: WebMvcAutoConfiguration.java View source code | 4 votes |
@Bean @ConditionalOnMissingBean({ RequestContextListener.class, RequestContextFilter.class }) public RequestContextFilter requestContextFilter() { return new OrderedRequestContextFilter(); }
Example 24
Project: dxa-modules File: AudienceManagerInitializer.java View source code | 4 votes |
@Override public void onStartup(ServletContext servletContext) throws ServletException { InitializationUtils.registerListener(servletContext, RequestContextListener.class); InitializationUtils.registerFilter(servletContext, "springSecurityFilterChain", DelegatingFilterProxy.class, "/*"); }
Example 25
Project: contestparser File: WebMvcAutoConfiguration.java View source code | 4 votes |
@Bean @ConditionalOnMissingBean({ RequestContextListener.class, RequestContextFilter.class }) public RequestContextFilter requestContextFilter() { return new OrderedRequestContextFilter(); }
Example 26
Project: nextrtc-videochat-with-rest File: WebSecurityConfig.java View source code | 4 votes |
@Bean public RequestContextListener requestContextListener() { return new RequestContextListener(); }
Example 27
Project: Estudo-Spring File: ServletDispatcherInitializer.java View source code | 4 votes |
@Override public void onStartup(ServletContext servletContext) throws ServletException { super.onStartup(servletContext); servletContext.addListener(RequestContextListener.class); servletContext.setInitParameter("spring.profiles.active", "dev"); }
Example 28
Project: faostat-api File: TestMetadata.java View source code | 4 votes |
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()); }
Example 29
Project: faostat-api File: TestDimensions.java View source code | 4 votes |
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()); }
Example 30
Project: faostat-api File: TestData.java View source code | 4 votes |
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()); }
Example 31
Project: faostat-api File: TestDataAllDomains.java View source code | 4 votes |
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()); }
Example 32
Project: faostat-api File: TestSearch.java View source code | 4 votes |
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()); }
Example 33
Project: faostat-api File: TestDocuments.java View source code | 4 votes |
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()); }
Example 34
Project: faostat-api File: TestGroupsAndDomains.java View source code | 4 votes |
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()); }
Example 35
Project: faostat-api File: TestSchema.java View source code | 4 votes |
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()); }
Example 36
Project: faostat-api File: TestBulkDownloads.java View source code | 4 votes |
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()); }
Example 37
Project: faostat-api File: TestCodes.java View source code | 4 votes |
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()); }
Example 38
Project: faostat-api File: TestCodesAllDomains.java View source code | 4 votes |
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()); }
Example 39
Project: faostat-api File: TestDefinitions.java View source code | 4 votes |
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()); }
Example 40
Project: pa165_haunted_houses File: Initializer.java View source code | 4 votes |
@Override public void onStartup(javax.servlet.ServletContext servletContext) throws javax.servlet.ServletException { super.onStartup(servletContext); servletContext.addListener(RequestContextListener.class); }