当前位置: 首页>>代码示例>>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;未经允许,请勿转载。