javax.servlet.DispatcherType Java Examples
The following examples show how to use
javax.servlet.DispatcherType.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Jetty9ServerTest.java From gocd with Apache License 2.0 | 6 votes |
@Test public void shouldAddDefaultHeadersForRootContext() throws Exception { jetty9Server.configure(); jetty9Server.startHandlers(); HttpServletResponse response = mock(HttpServletResponse.class); when(response.getWriter()).thenReturn(mock(PrintWriter.class)); HttpServletRequest request = mock(HttpServletRequest.class); Request baseRequest = mock(Request.class); when(baseRequest.getDispatcherType()).thenReturn(DispatcherType.REQUEST); when(baseRequest.getHttpFields()).thenReturn(mock(HttpFields.class)); ContextHandler rootPathHandler = getLoadedHandlers().get(GoServerLoadingIndicationHandler.class); rootPathHandler.setServer(server); rootPathHandler.start(); rootPathHandler.handle("/something", baseRequest, request, response); verify(response).setHeader("X-XSS-Protection", "1; mode=block"); verify(response).setHeader("X-Content-Type-Options", "nosniff"); verify(response).setHeader("X-Frame-Options", "SAMEORIGIN"); verify(response).setHeader("X-UA-Compatible", "chrome=1"); }
Example #2
Source File: OWBAutoSetup.java From openwebbeans-meecrowave with Apache License 2.0 | 6 votes |
@Override public void onStartup(final Set<Class<?>> c, final ServletContext ctx) { final Configuration builder = Configuration.class.cast(ctx.getAttribute("meecrowave.configuration")); final Meecrowave instance = Meecrowave.class.cast(ctx.getAttribute("meecrowave.instance")); if (builder.isCdiConversation()) { try { final Class<? extends Filter> clazz = (Class<? extends Filter>) OWBAutoSetup.class.getClassLoader() .loadClass("org.apache.webbeans.web.context.WebConversationFilter"); final FilterRegistration.Dynamic filter = ctx.addFilter("owb-conversation", clazz); filter.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), false, "/*"); } catch (final Exception e) { // no-op } } // eager boot to let injections work in listeners final EagerBootListener bootListener = new EagerBootListener(instance); bootListener.doContextInitialized(new ServletContextEvent(ctx)); ctx.addListener(bootListener); }
Example #3
Source File: FilterMap.java From tomcatsrc with Apache License 2.0 | 6 votes |
public String[] getDispatcherNames() { ArrayList<String> result = new ArrayList<String>(); if ((dispatcherMapping & FORWARD) > 0) { result.add(DispatcherType.FORWARD.name()); } if ((dispatcherMapping & INCLUDE) > 0) { result.add(DispatcherType.INCLUDE.name()); } if ((dispatcherMapping & REQUEST) > 0) { result.add(DispatcherType.REQUEST.name()); } if ((dispatcherMapping & ERROR) > 0) { result.add(DispatcherType.ERROR.name()); } if ((dispatcherMapping & ASYNC) > 0) { result.add(DispatcherType.ASYNC.name()); } return result.toArray(new String[result.size()]); }
Example #4
Source File: ServletSecurityRoleHandler.java From lams with GNU General Public License v2.0 | 6 votes |
@Override public void handleRequest(final HttpServerExchange exchange) throws Exception { final ServletRequestContext servletRequestContext = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY); ServletRequest request = servletRequestContext.getServletRequest(); if (request.getDispatcherType() == DispatcherType.REQUEST) { List<SingleConstraintMatch> constraints = servletRequestContext.getRequiredConstrains(); SecurityContext sc = exchange.getSecurityContext(); if (!authorizationManager.canAccessResource(constraints, sc.getAuthenticatedAccount(), servletRequestContext.getCurrentServlet().getManagedServlet().getServletInfo(), servletRequestContext.getOriginalRequest(), servletRequestContext.getDeployment())) { HttpServletResponse response = (HttpServletResponse) servletRequestContext.getServletResponse(); response.sendError(StatusCodes.FORBIDDEN); return; } } next.handleRequest(exchange); }
Example #5
Source File: RegistryApplication.java From registry with Apache License 2.0 | 6 votes |
private void addServletFilters(RegistryConfiguration registryConfiguration, Environment environment) { List<ServletFilterConfiguration> servletFilterConfigurations = registryConfiguration.getServletFilters(); if (servletFilterConfigurations != null && !servletFilterConfigurations.isEmpty()) { for (ServletFilterConfiguration servletFilterConfig : servletFilterConfigurations) { try { String className = servletFilterConfig.getClassName(); Map<String, String> params = servletFilterConfig.getParams(); String typeSuffix = params.get("type") != null ? ("-" + params.get("type").toString()) : ""; LOG.info("Registering servlet filter [{}]", servletFilterConfig); Class<? extends Filter> filterClass = (Class<? extends Filter>) Class.forName(className); FilterRegistration.Dynamic dynamic = environment.servlets().addFilter(className + typeSuffix, filterClass); if (params != null) { dynamic.setInitParameters(params); } dynamic.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), true, "/*"); } catch (Exception e) { LOG.error("Error registering servlet filter {}", servletFilterConfig); throw new RuntimeException(e); } } } }
Example #6
Source File: FilterHandler.java From quarkus-http with Apache License 2.0 | 6 votes |
@Override public void handleRequest(final HttpServerExchange exchange) throws Exception { final ServletRequestContext servletRequestContext = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY); ServletRequest request = servletRequestContext.getServletRequest(); ServletResponse response = servletRequestContext.getServletResponse(); DispatcherType dispatcher = servletRequestContext.getDispatcherType(); Boolean supported = asyncSupported.get(dispatcher); if(supported != null && ! supported) { servletRequestContext.setAsyncSupported(false); } final List<ManagedFilter> filters = this.filters.get(dispatcher); if(filters == null) { next.handleRequest(exchange); } else { final FilterChainImpl filterChain = new FilterChainImpl(exchange, filters, next, allowNonStandardWrappers); filterChain.doFilter(request, response); } }
Example #7
Source File: FilterHandler.java From lams with GNU General Public License v2.0 | 6 votes |
public FilterHandler(final Map<DispatcherType, List<ManagedFilter>> filters, final boolean allowNonStandardWrappers, final HttpHandler next) { this.allowNonStandardWrappers = allowNonStandardWrappers; this.next = next; this.filters = new EnumMap<>(filters); Map<DispatcherType, Boolean> asyncSupported = new EnumMap<>(DispatcherType.class); for(Map.Entry<DispatcherType, List<ManagedFilter>> entry : filters.entrySet()) { boolean supported = true; for(ManagedFilter i : entry.getValue()) { if(!i.getFilterInfo().isAsyncSupported()) { supported = false; break; } } asyncSupported.put(entry.getKey(), supported); } this.asyncSupported = asyncSupported; }
Example #8
Source File: ServletInvocationServiceInterceptor.java From pinpoint with Apache License 2.0 | 6 votes |
@Override public void before(Object target, Object[] args) { if (isDebug) { logger.beforeInterceptor(target, args); } if (!argumentValidator.validate(args)) { return; } try { final HttpServletRequest request = (HttpServletRequest) args[0]; if (request.getDispatcherType() == DispatcherType.ASYNC) { if (isDebug) { logger.debug("Skip async servlet Request. isAsyncStarted={}, dispatcherType={}", request.isAsyncStarted(), request.getDispatcherType()); } return; } this.servletRequestListenerInterceptorHelper.initialized(request, ResinConstants.RESIN_METHOD, this.methodDescriptor); } catch (Throwable t) { if (isInfo) { logger.info("Failed to servlet request event handle.", t); } } }
Example #9
Source File: AbstractServerHandleInterceptor.java From pinpoint with Apache License 2.0 | 6 votes |
@Override public void after(Object target, Object[] args, Object result, Throwable throwable) { if (isDebug) { logger.afterInterceptor(target, args, result, throwable); } try { final HttpServletRequest request = toHttpServletRequest(args); final HttpServletResponse response = toHttpServletResponse(args); if (request.getDispatcherType() == DispatcherType.ASYNC || request.getDispatcherType() == DispatcherType.ERROR) { if (isDebug) { logger.debug("Skip async servlet request event. isAsyncStarted={}, dispatcherType={}", request.isAsyncStarted(), request.getDispatcherType()); } return; } final int statusCode = getStatusCode(response); this.servletRequestListenerInterceptorHelper.destroyed(request, throwable, statusCode); } catch (Throwable t) { if (isInfo) { logger.info("Failed to servlet request event handle.", t); } } }
Example #10
Source File: ForwardedHeaderFilterTests.java From spring-analysis-note with MIT License | 6 votes |
@Test // SPR-16983 public void forwardedRequestWithServletForward() throws Exception { this.request.setRequestURI("/foo"); this.request.addHeader(X_FORWARDED_PROTO, "https"); this.request.addHeader(X_FORWARDED_HOST, "www.mycompany.com"); this.request.addHeader(X_FORWARDED_PORT, "443"); this.filter.doFilter(this.request, new MockHttpServletResponse(), this.filterChain); HttpServletRequest wrappedRequest = (HttpServletRequest) this.filterChain.getRequest(); this.request.setDispatcherType(DispatcherType.FORWARD); this.request.setRequestURI("/bar"); this.filterChain.reset(); this.filter.doFilter(wrappedRequest, new MockHttpServletResponse(), this.filterChain); HttpServletRequest actual = (HttpServletRequest) this.filterChain.getRequest(); assertNotNull(actual); assertEquals("/bar", actual.getRequestURI()); assertEquals("https://www.mycompany.com/bar", actual.getRequestURL().toString()); }
Example #11
Source File: DefaultWebApplicationRequest.java From piranha with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Constructor. */ public DefaultWebApplicationRequest() { this.authType = null; this.asyncStarted = false; this.asyncSupported = false; this.attributeManager = new DefaultAttributeManager(); this.characterEncoding = "ISO-8859-1"; this.contentLength = -1; this.contentType = null; this.contextPath = ""; this.cookies = null; this.dispatcherType = DispatcherType.REQUEST; this.headerManager = new DefaultHttpHeaderManager(); this.headerManager.setHeader("Accept", "*/*"); this.inputStream = new ByteArrayInputStream(new byte[0]); this.method = "GET"; this.protocol = "HTTP/1.1"; this.scheme = "http"; this.serverName = "localhost"; this.serverPort = 80; this.servletPath = ""; this.parameters = new HashMap<>(); this.upgraded = false; }
Example #12
Source File: FilterMap.java From tomcatsrc with Apache License 2.0 | 6 votes |
/** * * This method will be used to set the current state of the FilterMap * representing the state of when filters should be applied. */ public void setDispatcher(String dispatcherString) { String dispatcher = dispatcherString.toUpperCase(Locale.ENGLISH); if (dispatcher.equals(DispatcherType.FORWARD.name())) { // apply FORWARD to the global dispatcherMapping. dispatcherMapping |= FORWARD; } else if (dispatcher.equals(DispatcherType.INCLUDE.name())) { // apply INCLUDE to the global dispatcherMapping. dispatcherMapping |= INCLUDE; } else if (dispatcher.equals(DispatcherType.REQUEST.name())) { // apply REQUEST to the global dispatcherMapping. dispatcherMapping |= REQUEST; } else if (dispatcher.equals(DispatcherType.ERROR.name())) { // apply ERROR to the global dispatcherMapping. dispatcherMapping |= ERROR; } else if (dispatcher.equals(DispatcherType.ASYNC.name())) { // apply ERROR to the global dispatcherMapping. dispatcherMapping |= ASYNC; } }
Example #13
Source File: TestELInJsp.java From Tomcat8-Source-Read with MIT License | 6 votes |
@Test public void testBug57142() throws Exception { getTomcatInstanceTestWebapp(false, true); ByteChunk res = getUrl("http://localhost:" + getPort() + "/test/bug5nnnn/bug57142.jsp"); String result = res.toString(); // javax.servlet assertEcho(result, "00-" + DispatcherType.ASYNC); // No obvious static fields for javax.servlet.http // Could hack something with HttpUtils... // No obvious static fields for javax.servlet.jsp // Wild card (package) import assertEcho(result, "01-" + RoundingMode.HALF_UP); // Class import assertEcho(result, "02-" + Collections.EMPTY_LIST.size()); }
Example #14
Source File: TestJspContextWrapper.java From Tomcat8-Source-Read with MIT License | 6 votes |
@Test public void testELTagFileImports() throws Exception { getTomcatInstanceTestWebapp(false, true); ByteChunk out = new ByteChunk(); int rc = getUrl("http://localhost:" + getPort() + "/test/bug5nnnn/bug58178b.jsp", out, null); Assert.assertEquals(HttpServletResponse.SC_OK, rc); String result = out.toString(); Assert.assertTrue(result, result.contains("00-" + DispatcherType.ASYNC)); // No obvious status fields for javax.servlet.http // Could hack something with HttpUtils... // No obvious status fields for javax.servlet.jsp // Wild card (package) import Assert.assertTrue(result, result.contains("01-" + RoundingMode.HALF_UP)); // Class import Assert.assertTrue(result, result.contains("02-" + Collections.EMPTY_LIST.size())); }
Example #15
Source File: FilterConfig.java From supplierShop with MIT License | 6 votes |
@SuppressWarnings({ "rawtypes", "unchecked" }) @Bean public FilterRegistrationBean xssFilterRegistration() { FilterRegistrationBean registration = new FilterRegistrationBean(); registration.setDispatcherTypes(DispatcherType.REQUEST); registration.setFilter(new XssFilter()); registration.addUrlPatterns(StringUtils.split(urlPatterns, ",")); registration.setName("xssFilter"); registration.setOrder(Integer.MAX_VALUE); Map<String, String> initParameters = new HashMap<String, String>(); initParameters.put("excludes", excludes); initParameters.put("enabled", enabled); registration.setInitParameters(initParameters); return registration; }
Example #16
Source File: ITSpanCustomizingAsyncHandlerInterceptor.java From brave with Apache License 2.0 | 6 votes |
@Override public void init(ServletContextHandler handler) { AnnotationConfigWebApplicationContext appContext = new AnnotationConfigWebApplicationContext() { // overriding this allows us to register dependencies of TracingHandlerInterceptor // without passing static state to a configuration class. @Override protected void loadBeanDefinitions(DefaultListableBeanFactory beanFactory) { beanFactory.registerSingleton("httpTracing", httpTracing); super.loadBeanDefinitions(beanFactory); } }; appContext.register(Servlet3TestController.class); // the test resource appContext.register(TracingConfig.class); // generic tracing setup DispatcherServlet servlet = new DispatcherServlet(appContext); servlet.setDispatchOptionsRequest(true); ServletHolder servletHolder = new ServletHolder(servlet); servletHolder.setAsyncSupported(true); handler.addServlet(servletHolder, "/*"); handler.addEventListener(new ContextLoaderListener(appContext)); // add the trace filter, which lazy initializes a real tracing filter from the spring context Dynamic filterRegistration = handler.getServletContext().addFilter("tracingFilter", DelegatingTracingFilter.class); filterRegistration.setAsyncSupported(true); filterRegistration.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), true, "/*"); }
Example #17
Source File: AbstractServerHandleInterceptor.java From pinpoint with Apache License 2.0 | 6 votes |
@Override public void before(Object target, Object[] args) { if (isDebug) { logger.beforeInterceptor(target, args); } try { final HttpServletRequest request = toHttpServletRequest(args); if (request.getDispatcherType() == DispatcherType.ASYNC || request.getDispatcherType() == DispatcherType.ERROR) { if (isDebug) { logger.debug("Skip async servlet request event. isAsyncStarted={}, dispatcherType={}", request.isAsyncStarted(), request.getDispatcherType()); } return; } this.servletRequestListenerInterceptorHelper.initialized(request, JettyConstants.JETTY_METHOD, this.methodDescriptor); } catch (Throwable t) { logger.info("Failed to servlet request event handle.", t); } }
Example #18
Source File: FilterMap.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
public String[] getDispatcherNames() { ArrayList<String> result = new ArrayList<String>(); if ((dispatcherMapping & FORWARD) > 0) { result.add(DispatcherType.FORWARD.name()); } if ((dispatcherMapping & INCLUDE) > 0) { result.add(DispatcherType.INCLUDE.name()); } if ((dispatcherMapping & REQUEST) > 0) { result.add(DispatcherType.REQUEST.name()); } if ((dispatcherMapping & ERROR) > 0) { result.add(DispatcherType.ERROR.name()); } if ((dispatcherMapping & ASYNC) > 0) { result.add(DispatcherType.ASYNC.name()); } return result.toArray(new String[result.size()]); }
Example #19
Source File: NewtsService.java From newts with Apache License 2.0 | 5 votes |
private void configureAuthentication(Environment environment, NewtsConfig config) { if (config.getAuthenticationConfig().isEnabled()) { environment.servlets() .addFilter("BasicAuth", new HttpBasicAuthenticationFilter(config)) .addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), true, "/*"); } }
Example #20
Source File: J2EHelper.java From dropwizard-pac4j with Apache License 2.0 | 5 votes |
private static void registerFilter(Environment environment, Config config, AbstractConfigFilter filter, String mapping) { filter.setConfigOnly(config); final FilterRegistration.Dynamic filterRegistration = environment .servlets().addFilter(filter.getClass().getName(), filter); filterRegistration.addMappingForUrlPatterns( EnumSet.of(DispatcherType.REQUEST), true, mapping); }
Example #21
Source File: BlockExplorerApp.java From fabric-api with Apache License 2.0 | 5 votes |
@Override public void run(BlockExplorerConfiguration configuration, Environment environment) throws Exception { BCSAPI api = hyperLedgerBundle.getBCSAPI(); final FilterRegistration.Dynamic cors = environment.servlets().addFilter("CORS", CrossOriginFilter.class); // Configure CORS parameters cors.setInitParameter("allowedOrigins", "*"); cors.setInitParameter("allowedHeaders", "*"); cors.setInitParameter("allowedMethods", "OPTIONS,GET,PUT,POST,DELETE,HEAD"); // Add URL mapping cors.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), true, "/*"); environment.jersey().register(new ExplorerResource(api)); }
Example #22
Source File: ITSpanCustomizingApplicationEventListener.java From brave with Apache License 2.0 | 5 votes |
@Override public void init(ServletContextHandler handler) { ResourceConfig config = new ResourceConfig(); config.register(new TestResource(httpTracing)); config.register(SpanCustomizingApplicationEventListener.create()); handler.addServlet(new ServletHolder(new ServletContainer(config)), "/*"); // add the underlying servlet tracing filter which the event listener decorates with more tags Dynamic filterRegistration = handler.getServletContext().addFilter("tracingFilter", TracingFilter.create(httpTracing)); filterRegistration.setAsyncSupported(true); // isMatchAfter=true is required for async tests to pass! filterRegistration.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), true, "/*"); }
Example #23
Source File: Main.java From zooadmin with MIT License | 5 votes |
public static void main(String[] args) throws Exception { DeploymentInfo servletBuilder = Servlets.deployment() .setContextPath("/") .setClassLoader(Main.class.getClassLoader()) .setDeploymentName("zooadmin.war") ; Integer port= PropUtil.getInt("port"); String host=PropUtil.getString("host"); String resource=PropUtil.getString("resource"); FilterInfo jfinalFilter=new FilterInfo("jfinal",JFinalFilter.class); jfinalFilter.addInitParam("configClass","com.baicai.core.Config"); servletBuilder.addFilter(jfinalFilter); servletBuilder.addFilterUrlMapping("jfinal","/*", DispatcherType.REQUEST); servletBuilder.addFilterUrlMapping("jfinal","/*", DispatcherType.FORWARD); servletBuilder.setResourceManager(new FileResourceManager(new File(resource), 1024)); DeploymentManager manager = Servlets.defaultContainer().addDeployment(servletBuilder); manager.deploy(); PathHandler path = Handlers.path(Handlers.redirect("/")) .addPrefixPath("/", manager.start()); Undertow server = Undertow.builder() .addHttpListener(port, host) .setHandler(path) .build(); // start server server.start(); log.info("http://"+host+":"+port); }
Example #24
Source File: AbstractWildcardOperationNameTest.java From java-jaxrs with Apache License 2.0 | 5 votes |
@Override protected void initTracing(ServletContextHandler context) { client.register(new Builder(mockTracer).build()); ServerTracingDynamicFeature serverTracingBuilder = new ServerTracingDynamicFeature.Builder(mockTracer) .withOperationNameProvider(WildcardOperationName.newBuilder()) .build(); context.addFilter(new FilterHolder(new SpanFinishingFilter()), "/*", EnumSet.of(DispatcherType.REQUEST)); context.setAttribute(TRACER_ATTRIBUTE, mockTracer); context.setAttribute(CLIENT_ATTRIBUTE, client); context.setAttribute(SERVER_TRACING_FEATURE, serverTracingBuilder); }
Example #25
Source File: AnnotationConfigDispatcherServletInitializerTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void register() throws ServletException { initializer.onStartup(servletContext); assertEquals(1, servlets.size()); assertNotNull(servlets.get(SERVLET_NAME)); DispatcherServlet servlet = (DispatcherServlet) servlets.get(SERVLET_NAME); WebApplicationContext wac = servlet.getWebApplicationContext(); ((AnnotationConfigWebApplicationContext) wac).refresh(); assertTrue(wac.containsBean("bean")); assertTrue(wac.getBean("bean") instanceof MyBean); assertEquals(1, servletRegistrations.size()); assertNotNull(servletRegistrations.get(SERVLET_NAME)); MockServletRegistration servletRegistration = servletRegistrations.get(SERVLET_NAME); assertEquals(Collections.singleton(SERVLET_MAPPING), servletRegistration.getMappings()); assertEquals(1, servletRegistration.getLoadOnStartup()); assertEquals(ROLE_NAME, servletRegistration.getRunAsRole()); assertTrue(servletRegistration.isAsyncSupported()); assertEquals(4, filterRegistrations.size()); assertNotNull(filterRegistrations.get("hiddenHttpMethodFilter")); assertNotNull(filterRegistrations.get("delegatingFilterProxy")); assertNotNull(filterRegistrations.get("delegatingFilterProxy#0")); assertNotNull(filterRegistrations.get("delegatingFilterProxy#1")); for (MockFilterRegistration filterRegistration : filterRegistrations.values()) { assertTrue(filterRegistration.isAsyncSupported()); EnumSet<DispatcherType> enumSet = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD, DispatcherType.INCLUDE, DispatcherType.ASYNC); assertEquals(enumSet, filterRegistration.getMappings().get(SERVLET_NAME)); } }
Example #26
Source File: AbstractServerDefaultConfigurationTest.java From java-jaxrs with Apache License 2.0 | 5 votes |
@Override protected void initTracing(ServletContextHandler context) { client.register(new Builder(mockTracer).build()); ServerTracingDynamicFeature serverTracingBuilder = new ServerTracingDynamicFeature.Builder(mockTracer) .build(); context.addFilter(new FilterHolder(new SpanFinishingFilter()), "/*", EnumSet.of(DispatcherType.REQUEST)); context.setAttribute(TRACER_ATTRIBUTE, mockTracer); context.setAttribute(CLIENT_ATTRIBUTE, client); context.setAttribute(SERVER_TRACING_FEATURE, serverTracingBuilder); }
Example #27
Source File: DispatcherServlet.java From spring-analysis-note with MIT License | 5 votes |
private void logRequest(HttpServletRequest request) { LogFormatUtils.traceDebug(logger, traceOn -> { String params; if (isEnableLoggingRequestDetails()) { params = request.getParameterMap().entrySet().stream() .map(entry -> entry.getKey() + ":" + Arrays.toString(entry.getValue())) .collect(Collectors.joining(", ")); } else { params = (request.getParameterMap().isEmpty() ? "" : "masked"); } String queryString = request.getQueryString(); String queryClause = (StringUtils.hasLength(queryString) ? "?" + queryString : ""); String dispatchType = (!request.getDispatcherType().equals(DispatcherType.REQUEST) ? "\"" + request.getDispatcherType().name() + "\" dispatch for " : ""); String message = (dispatchType + request.getMethod() + " \"" + getRequestUri(request) + queryClause + "\", parameters={" + params + "}"); if (traceOn) { List<String> values = Collections.list(request.getHeaderNames()); String headers = values.size() > 0 ? "masked" : ""; if (isEnableLoggingRequestDetails()) { headers = values.stream().map(name -> name + ":" + Collections.list(request.getHeaders(name))) .collect(Collectors.joining(", ")); } return message + ", headers={" + headers + "} in DispatcherServlet '" + getServletName() + "'"; } else { return message; } }); }
Example #28
Source File: EventApisFactory.java From eventapis with Apache License 2.0 | 5 votes |
@Bean public FilterRegistrationBean createOpContextFilter(@Autowired OperationContext operationContext) { FilterRegistrationBean registration = new FilterRegistrationBean(); registration.setFilter(new OpContextFilter(operationContext)); // registration.setOrder(Ordered.HIGHEST_PRECEDENCE); registration.setDispatcherTypes(EnumSet.allOf(DispatcherType.class)); return registration; }
Example #29
Source File: ApplicationInitializer.java From AIDR with GNU Affero General Public License v3.0 | 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 #30
Source File: WebConfigurer.java From flair-engine with Apache License 2.0 | 5 votes |
@Override public void onStartup(ServletContext servletContext) throws ServletException { if (env.getActiveProfiles().length != 0) { log.info("Web application configuration, using profiles: {}", (Object[]) env.getActiveProfiles()); } EnumSet<DispatcherType> disps = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD, DispatcherType.ASYNC); initMetrics(servletContext, disps); if (env.acceptsProfiles(JHipsterConstants.SPRING_PROFILE_PRODUCTION)) { initCachingHttpHeadersFilter(servletContext, disps); } log.info("Web application fully configured"); }