當前位置: 首頁>>代碼示例>>Java>>正文


Java FilterHolder類代碼示例

本文整理匯總了Java中org.eclipse.jetty.servlet.FilterHolder的典型用法代碼示例。如果您正苦於以下問題:Java FilterHolder類的具體用法?Java FilterHolder怎麽用?Java FilterHolder使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


FilterHolder類屬於org.eclipse.jetty.servlet包,在下文中一共展示了FilterHolder類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: addApplication

import org.eclipse.jetty.servlet.FilterHolder; //導入依賴的package包/類
private void addApplication(final ServletContextHandler context, final MinijaxApplication application)
        throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {

    // (0) Sort the resource methods by literal length
    application.sortResourceMethods();

    // (1) Add Minijax filter (must come before websocket!)
    context.addFilter(new FilterHolder(new MinijaxFilter(application)), "/*", EnumSet.of(DispatcherType.REQUEST));

    // (2) WebSocket endpoints
    if (OptionalClasses.WEB_SOCKET_UTILS != null) {
        OptionalClasses.WEB_SOCKET_UTILS
                .getMethod("init", ServletContextHandler.class, MinijaxApplication.class)
                .invoke(null, context, application);
    }

    // (3) Dynamic JAX-RS content
    final MinijaxServlet servlet = new MinijaxServlet(application);
    final ServletHolder servletHolder = new ServletHolder(servlet);
    servletHolder.getRegistration().setMultipartConfig(new MultipartConfigElement(""));
    context.addServlet(servletHolder, "/*");
}
 
開發者ID:minijax,項目名稱:minijax,代碼行數:23,代碼來源:Minijax.java

示例2: testConfiguredHttpsProxy

import org.eclipse.jetty.servlet.FilterHolder; //導入依賴的package包/類
public void testConfiguredHttpsProxy() throws Exception {
  File testRepo = createMyModuleRepository("testConfiguredHttpsProxy");
  File emptyRepo = Files.createTempDirectory("vertx").toFile();
  emptyRepo.deleteOnExit();
  startRemoteServer(configureTls(createRemoteServer(testRepo)));
  Server server = new Server(8081);
  ServletHandler handler = new ServletHandler();
  server.setHandler(handler);
  handler.addServletWithMapping(ProxyServlet.class, "/").setInitParameter("maxThreads", "10");
  UrlCollectorFilter urlCollector = new UrlCollectorFilter();
  handler.addFilterWithMapping(new FilterHolder(urlCollector), "/*", 0);
  server.start();
  servers.add(server);
  System.setProperty(MavenVerticleFactory.HTTP_PROXY_SYS_PROP, "http://localhost:8081");
  configureRepos(emptyRepo, "https://localhost:8443/");
  URL expectedHost = new URL("http://localhost:8443/");
  vertx.deployVerticle("maven:my:module:1.0::my.serviceA", new DeploymentOptions(), onSuccess(id -> {
    assertTrue("Was expecting " + urlCollector.requestedHosts + " to contain " + expectedHost, urlCollector.requestedHosts.contains(expectedHost));
    testComplete();
  }));
  await();
}
 
開發者ID:vert-x3,項目名稱:vertx-maven-service-factory,代碼行數:23,代碼來源:FactoryTest.java

示例3: setFilters

import org.eclipse.jetty.servlet.FilterHolder; //導入依賴的package包/類
private void setFilters(JettyHttpEndpoint endpoint, Server server, String connectorKey) {
    ServletContextHandler context = server.getChildHandlerByClass(ServletContextHandler.class);
    List<Filter> filters = endpoint.getFilters();
    for (Filter filter : filters) {
        FilterHolder filterHolder = new FilterHolder();
        filterHolder.setFilter(new CamelFilterWrapper(filter));
        String pathSpec = endpoint.getPath();
        if (pathSpec == null || "".equals(pathSpec)) {
            pathSpec = "/";
        }
        if (endpoint.isMatchOnUriPrefix()) {
            pathSpec = pathSpec.endsWith("/") ? pathSpec + "*" : pathSpec + "/*";
        }
        addFilter(context, filterHolder, pathSpec);
    }
}
 
開發者ID:nkasvosve,項目名稱:beyondj,代碼行數:17,代碼來源:JettyHttpComponent.java

示例4: init

import org.eclipse.jetty.servlet.FilterHolder; //導入依賴的package包/類
public void init() {
    // Attach servlets
    for(Servlet servlet : context.servlets()) {
        final ServletHolder servletHolder = new ServletHolder(servlet);
        addServlet(servletHolder, MAPPING_URL);
    }

    // Attach event listeners
    for(EventListener listener : context.listeners()) {
        addEventListener(listener);
    }

    // Attach filters
    for(Filter filter : context.filters()) {
        addFilter(new FilterHolder(filter), MAPPING_URL, EnumSet.allOf(DispatcherType.class));
    }
}
 
開發者ID:gravitee-io,項目名稱:graviteeio-access-management,代碼行數:18,代碼來源:SecurityDomainHandler.java

示例5: init

import org.eclipse.jetty.servlet.FilterHolder; //導入依賴的package包/類
public void init() {
    setContextPath("/management");

    // REST configuration
    Servlet servlet = context.servlets().iterator().next();
    final ServletHolder servletHolder = new ServletHolder(servlet);
    servletHolder.setInitParameter("javax.ws.rs.Application", "io.gravitee.am.gateway.handler.management.api.ManagementApplication");
    servletHolder.setInitOrder(0);
    addServlet(servletHolder, "/*");

    // Attach event listeners
    for(EventListener listener : context.listeners()) {
        addEventListener(listener);
    }

    // Attach filters
    for(Filter filter : context.filters()) {
        addFilter(new FilterHolder(filter), MAPPING_URL, EnumSet.allOf(DispatcherType.class));
    }
}
 
開發者ID:gravitee-io,項目名稱:graviteeio-access-management,代碼行數:21,代碼來源:ManagementContextHandler.java

示例6: addServlet

import org.eclipse.jetty.servlet.FilterHolder; //導入依賴的package包/類
public void addServlet(String path, ServletHolder servletHolder, boolean requiresAuthentication) {
    ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
    context.setContextPath(path);
    context.addServlet(servletHolder, MATCH_ALL);
    context.setAttribute(WebService.ATTRIBUTE_PULSAR_NAME, pulsar);

    if (requiresAuthentication && pulsar.getConfiguration().isAuthenticationEnabled()) {
        FilterHolder filter = new FilterHolder(new AuthenticationFilter(pulsar));
        context.addFilter(filter, MATCH_ALL, EnumSet.allOf(DispatcherType.class));
    }

    FilterHolder responseFilter = new FilterHolder(new ResponseHandlerFilter(pulsar));
    context.addFilter(responseFilter, MATCH_ALL, EnumSet.allOf(DispatcherType.class));

    handlers.add(context);
}
 
開發者ID:apache,項目名稱:incubator-pulsar,代碼行數:17,代碼來源:WebService.java

示例7: initTracing

import org.eclipse.jetty.servlet.FilterHolder; //導入依賴的package包/類
protected void initTracing(ServletContextHandler context) {
    client.register(new Builder(mockTracer).build());

    ServerTracingDynamicFeature serverTracingFeature =
        new ServerTracingDynamicFeature.Builder(mockTracer)
            .withOperationNameProvider(HTTPMethodOperationName.newBuilder())
            .withDecorators(Collections.singletonList(ServerSpanDecorator.STANDARD_TAGS))
            .withSkipPattern("/health")
        .build();
    // TODO clarify dispatcher types
    context.addFilter(new FilterHolder(new SpanFinishingFilter(mockTracer)), "/*",
        EnumSet.of(
            DispatcherType.REQUEST,
            DispatcherType.FORWARD,
            // TODO CXF does not call AsyncListener#onComplete() without this (it calls only onStartAsync)
            DispatcherType.ASYNC,
            DispatcherType.ERROR,
            DispatcherType.INCLUDE));

    context.setAttribute(CLIENT_ATTRIBUTE, client);
    context.setAttribute(TRACER_ATTRIBUTE, mockTracer);
    context.setAttribute(SERVER_TRACING_FEATURE, serverTracingFeature);
}
 
開發者ID:opentracing-contrib,項目名稱:java-jaxrs,代碼行數:24,代碼來源:AbstractJettyTest.java

示例8: run

import org.eclipse.jetty.servlet.FilterHolder; //導入依賴的package包/類
@Override
public void run(Environment environment) {
    SkillzFilter filter = typeFactory.create(SkillzFilter.class);
    filter.setPathPrefix(skillzPath.substring(0, skillzPath.length() -2));
    FilterHolder holder = new FilterHolder(filter);
    environment.getApplicationContext().addFilter(holder, skillzPath,
            EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD, DispatcherType.INCLUDE) );
    StringBuilder sb = new StringBuilder("Skillz: ")
            .append(System.lineSeparator())
            .append(System.lineSeparator());
    String filterPath = skillzPath.substring(0, skillzPath.length() -1);
    for(IntrospectionData data :filter.getRegistry().getAllIntrospectionData()){
        String path = ((Skill) data.getType().getAnnotation(Skill.class)).path();
        sb.append(String.format("   SKILL    %s (%s)", filterPath+path, data.getType().getName())).append(System.lineSeparator());
    }
    LOG.info(sb.toString());
}
 
開發者ID:kebernet,項目名稱:skillz,代碼行數:18,代碼來源:SkillzBundle.java

示例9: setFilters

import org.eclipse.jetty.servlet.FilterHolder; //導入依賴的package包/類
private void setFilters(JettyHttpEndpoint endpoint, Server server, String connectorKey) {
    ServletContextHandler context = server.getChildHandlerByClass(ServletContextHandler.class);
    List<Filter> filters = endpoint.getFilters();
    for (Filter filter : filters) {
        FilterHolder filterHolder = new FilterHolder();
        if (endpoint.getFilterInitParameters() != null) {
            filterHolder.setInitParameters(endpoint.getFilterInitParameters());
        }
        filterHolder.setFilter(new CamelFilterWrapper(filter));
        String pathSpec = endpoint.getPath();
        if (pathSpec == null || "".equals(pathSpec)) {
            pathSpec = "/";
        }
        if (endpoint.isMatchOnUriPrefix()) {
            pathSpec = pathSpec.endsWith("/") ? pathSpec + "*" : pathSpec + "/*";
        }
        addFilter(context, filterHolder, pathSpec);
    }
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:20,代碼來源:JettyHttpComponent.java

示例10: testCrossOriginFilterAddedWhenOn

import org.eclipse.jetty.servlet.FilterHolder; //導入依賴的package包/類
@Test
public void testCrossOriginFilterAddedWhenOn() throws Exception {
    // setup
    CometdComponent component = context.getComponent("cometd", CometdComponent.class);
    Server server = new Server();

    when(endpoint.isCrossOriginFilterOn()).thenReturn(true);
    when(endpoint.getFilterPath()).thenReturn(FILTER_PATH);
    when(endpoint.getAllowedOrigins()).thenReturn(ALLOWED_ORIGINS);

    // act
    component.createServletForConnector(server, connector, endpoint);

    // assert
    ServletContextHandler handler = (ServletContextHandler) server.getHandler();
    assertEquals(1, handler.getServletHandler().getFilters().length);

    FilterHolder filterHolder = handler.getServletHandler().getFilters()[0];
    Filter filter = filterHolder.getFilter();
    assertTrue(filter instanceof CrossOriginFilter);
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:22,代碼來源:CometdCrossOriginConsumerTest.java

示例11: createServletHandlerWithServlet

import org.eclipse.jetty.servlet.FilterHolder; //導入依賴的package包/類
private ServletContextHandler createServletHandlerWithServlet() {
    ServletContextHandler context = new ServletContextHandler(
            ServletContextHandler.SESSIONS);

    FilterHolder pushCacheFilter = context.addFilter(PushCacheFilter.class, "/*",
            null);
    Map<String, String> config = new HashMap<>();
    config.put("maxAssociations", "32");
    config.put("ports", Objects.toString(SSL_PORT));
    pushCacheFilter.setInitParameters(config);

    context.addServlet(NoopServlet.class, "/*");
    context.setContextPath("/");

    return context;
}
 
開發者ID:AndreasKl,項目名稱:embedded-jetty-http2,代碼行數:17,代碼來源:Application.java

示例12: run

import org.eclipse.jetty.servlet.FilterHolder; //導入依賴的package包/類
public int run() throws Exception {
    org.eclipse.jetty.server.Server server = new org.eclipse.jetty.server.Server(port);
    HandlerList handlerList = new HandlerList();

    ServletContextHandler servletContextHandler = new ServletContextHandler();
    FilterHolder cof = new FilterHolder(new CrossOriginFilter());
    cof.setInitParameter(
            CrossOriginFilter.EXPOSED_HEADERS_PARAM,
            "Date");
    servletContextHandler.addFilter(cof, "/*", EnumSet.of(DispatcherType.INCLUDE, DispatcherType.REQUEST));
    servletContextHandler.addServlet(new ServletHolder(new SmoothStreamingServlet(dataDir)), "/*");
    ResourceHandler resourceHandler = new ResourceHandler();
    resourceHandler.setBaseResource(Resource.newClassPathResource("supportfiles"));
    handlerList.addHandler(resourceHandler);
    handlerList.addHandler(servletContextHandler);
    server.setHandler(handlerList);

    server.start();
    server.dumpStdErr();
    server.join();
    return 0;
}
 
開發者ID:sannies,項目名稱:ismv-server,代碼行數:23,代碼來源:Server.java

示例13: JettyRule

import org.eclipse.jetty.servlet.FilterHolder; //導入依賴的package包/類
public JettyRule(final Filter filter, final Trace trace) {
    this.server = new Server(0);

    final ServletContextHandler handler = new ServletContextHandler();
    handler.setContextPath("/");
    handler.addServlet(new ServletHolder(new AsyncServlet(trace)), "/async");
    handler.addServlet(new ServletHolder(new TraceServlet(trace)), "/traced");
    handler.addServlet(new ServletHolder(new TraceServlet(trace)), "/untraced");
    handler.addServlet(ForwardServlet.class, "/forward");
    handler.addServlet(IncludeServlet.class, "/include");
    handler.addServlet(FailingServlet.class, "/failure");
    handler.addServlet(DefaultServlet.class, "/");

    handler.addFilter(new FilterHolder(filter), "/async", EnumSet.allOf(DispatcherType.class));
    // /untraced is intentionally NOT traced!
    handler.addFilter(new FilterHolder(filter), "/traced", EnumSet.allOf(DispatcherType.class));
    handler.addFilter(new FilterHolder(filter), "/forward", EnumSet.allOf(DispatcherType.class));
    handler.addFilter(new FilterHolder(filter), "/include", EnumSet.allOf(DispatcherType.class));
    handler.addFilter(new FilterHolder(filter), "/failure", EnumSet.allOf(DispatcherType.class));

    server.setHandler(handler);
}
 
開發者ID:zalando,項目名稱:tracer,代碼行數:23,代碼來源:JettyRule.java

示例14: addHttpsForward

import org.eclipse.jetty.servlet.FilterHolder; //導入依賴的package包/類
private void addHttpsForward(ServletContextHandler handler) {
    handler.addFilter(new FilterHolder(new Filter() {

        public void init(FilterConfig filterConfig) throws ServletException {
        }

        public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
                throws IOException, ServletException {
            StringBuffer uri = ((HttpServletRequest) request).getRequestURL();
            if (uri.toString().startsWith("http://")) {
                String location = "https://" + uri.substring("http://".length());
                ((HttpServletResponse) response).sendRedirect(location);
            } else {
                chain.doFilter(request, response);
            }
        }

        public void destroy() {
        }
    }), "/*", EnumSet.of(DispatcherType.REQUEST));
}
 
開發者ID:Krillsson,項目名稱:sys-api,代碼行數:22,代碼來源:SystemApiApplication.java

示例15: initJerseyServlet

import org.eclipse.jetty.servlet.FilterHolder; //導入依賴的package包/類
/**
 * Initializes the Jersey Servlet.
 */
private void initJerseyServlet() {
  servletContext = new ServletContextHandler(ServletContextHandler.SESSIONS);
  servletContext.setContextPath("/");
  // This is used for allowing access to different domains/ports.
  FilterHolder filterHolder = new FilterHolder(CrossOriginFilter.class);
  filterHolder.setInitParameter("allowedOrigins", "*");
  filterHolder.setInitParameter("allowedMethods", "GET, POST");
  servletContext.addFilter(filterHolder, "/*", null);

  jerseyServlet = servletContext.addServlet(org.glassfish.jersey.servlet.ServletContainer.class, "/*");
  jerseyServlet.setInitOrder(0);

  // Tell the Jersey Servlet which REST class to load.
  jerseyServlet.setInitParameter("jersey.config.server.provider.classnames",
      ProvisioningAction.class.getCanonicalName());
}
 
開發者ID:google,項目名稱:account-provisioning-for-google-apps,代碼行數:20,代碼來源:RESTApp.java


注:本文中的org.eclipse.jetty.servlet.FilterHolder類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。