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


Java ServletHandler.addFilterWithMapping方法代碼示例

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


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

示例1: testConfiguredHttpsProxy

import org.eclipse.jetty.servlet.ServletHandler; //導入方法依賴的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

示例2: startServer1

import org.eclipse.jetty.servlet.ServletHandler; //導入方法依賴的package包/類
public void startServer1() throws Exception
{
    Server server = new Server(9091);
    ServletHandler handler = new ServletHandler();

    AwesomeService.Processor<AwesomeService.Iface> processor = new AwesomeService.Processor<>(referenceServer);
    ServletHolder holder = new ServletHolder(new TServlet(processor, new TJSONProtocol.Factory()));
    handler.addFilterWithMapping(CORSFilter.class, "/*", 0);
    handler.addServletWithMapping(holder, "/*");
    server.setHandler(handler);
    server.start();
    logger.info("Started JSON interface.");

    joinMethods.add(() -> {
        try {
            server.join();
        } catch (InterruptedException ignored) {
        }
    });
}
 
開發者ID:coveord,項目名稱:Blitz-2015,代碼行數:21,代碼來源:ReferenceMain.java

示例3: startHttp1

import org.eclipse.jetty.servlet.ServletHandler; //導入方法依賴的package包/類
private static Server startHttp1() throws Exception {
    Server server = new Server(0);

    ServletHandler handler = new ServletHandler();
    handler.addServletWithMapping(newServletHolder(thriftServlet), TSERVLET_PATH);
    handler.addServletWithMapping(newServletHolder(rootServlet), "/");
    handler.addFilterWithMapping(new FilterHolder(new ConnectionCloseFilter()), "/*",
                                 EnumSet.of(DispatcherType.REQUEST));

    server.setHandler(handler);

    for (Connector c : server.getConnectors()) {
        for (ConnectionFactory f : c.getConnectionFactories()) {
            for (String p : f.getProtocols()) {
                if (p.startsWith("h2c")) {
                    fail("Attempted to create a Jetty server without HTTP/2 support, but failed: " +
                         f.getProtocols());
                }
            }
        }
    }

    server.start();
    return server;
}
 
開發者ID:line,項目名稱:armeria,代碼行數:26,代碼來源:ThriftOverHttpClientTServletIntegrationTest.java

示例4: testConfiguredHttpProxy

import org.eclipse.jetty.servlet.ServletHandler; //導入方法依賴的package包/類
@Test
public void testConfiguredHttpProxy() throws Exception {
  File testRepo = createMyModuleRepository("testConfiguredHttpProxy");
  File emptyRepo = Files.createTempDirectory("vertx").toFile();
  emptyRepo.deleteOnExit();
  startRemoteServer(createRemoteServer(testRepo));
  System.setProperty(MavenVerticleFactory.HTTP_PROXY_SYS_PROP, "http://localhost:8081");
  Server server = new Server(8081);
  ServletHandler handler = new ServletHandler();
  server.setHandler(handler);
  handler.addServletWithMapping(ProxyServlet.class, "/*").setInitParameter("maxThreads", "10");
  URL expectedHost = new URL("http://localhost:8080/");
  UrlCollectorFilter urlCollector = new UrlCollectorFilter();
  handler.addFilterWithMapping(new FilterHolder(urlCollector), "/*", 0);
  server.start();
  servers.add(server);
  configureRepos(emptyRepo, "http://localhost:8080/");
  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,代碼行數:24,代碼來源:FactoryTest.java

示例5: testConfiguredAuthenticatingHttpProxy

import org.eclipse.jetty.servlet.ServletHandler; //導入方法依賴的package包/類
@Test
public void testConfiguredAuthenticatingHttpProxy() throws Exception {
  File testRepo = createMyModuleRepository("testConfiguredAuthenticatingHttpProxy");
  File emptyRepo = Files.createTempDirectory("vertx").toFile();
  emptyRepo.deleteOnExit();
  startRemoteServer(createRemoteServer(testRepo));
  System.setProperty(MavenVerticleFactory.HTTP_PROXY_SYS_PROP, "http://username_value:[email protected]:8081");
  Server server = new Server(8081);
  ServletHandler handler = new ServletHandler();
  server.setHandler(handler);
  AuthFilter filter = AuthFilter.proxyAuthenticator("username_value", "password_value");
  handler.addFilterWithMapping(new FilterHolder(filter), "/*", 0);
  handler.addServletWithMapping(ProxyServlet.class, "/*").setInitParameter("maxThreads", "10");
  URL expectedHost = new URL("http://localhost:8080/");
  UrlCollectorFilter urlCollector = new UrlCollectorFilter();
  handler.addFilterWithMapping(new FilterHolder(urlCollector), "/*", 0);
  server.start();
  servers.add(server);
  configureRepos(emptyRepo, "http://localhost:8080/");
  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));
    assertTrue(filter.authenticated.get());
    testComplete();
  }));
  await();
}
 
開發者ID:vert-x3,項目名稱:vertx-maven-service-factory,代碼行數:27,代碼來源:FactoryTest.java

示例6: before

import org.eclipse.jetty.servlet.ServletHandler; //導入方法依賴的package包/類
@BeforeClass
public static void before() throws Exception {
	teiid = new EmbeddedServer();
	teiid.start(new EmbeddedConfiguration());
	teiid.addTranslator(LoopbackExecutionFactory.class);

	server = new Server();

	SocketConnector connector = new SocketConnector();
	server.setConnectors(new Connector[] {connector});

	ServletHandler handler = new ServletHandler();
       server.setHandler(handler);

       handler.addFilterWithMapping(new FilterHolder(new ODataFilter() {
       	@Override
       	public Client buildClient(String vdbName, int version, Properties props) {
       		LocalClient c=  new LocalClient(vdbName, version, props);
       		c.setDriver(teiid.getDriver());
       		return c;
       	}
       }), "/*", 0);
       handler.addServletWithMapping(ODataServlet.class, "/*");
       server.start();
       port = connector.getLocalPort();
       deployVDB();
}
 
開發者ID:kenweezy,項目名稱:teiid,代碼行數:28,代碼來源:TestODataIntegration.java

示例7: createBoshHandler

import org.eclipse.jetty.servlet.ServletHandler; //導入方法依賴的package包/類
private void createBoshHandler(ContextHandlerCollection contexts, String boshPath) {
    ServletHandler handler = new ServletHandler();
    handler.addServletWithMapping(HttpBindServlet.class, "/");

    handler.addFilterWithMapping(org.eclipse.jetty.continuation.ContinuationFilter.class,"/*",0);
    ContextHandler boshContextHandler = new ContextHandler(contexts, boshPath);
    boshContextHandler.setHandler(handler);
}
 
開發者ID:coodeer,項目名稱:g3server,代碼行數:9,代碼來源:HttpBindManager.java

示例8: createServer

import org.eclipse.jetty.servlet.ServletHandler; //導入方法依賴的package包/類
private void createServer() throws MalformedURLException {
    server = new Server(port);
    
    if (Boolean.parseBoolean(Config.getBlurConfig().get("blur.console.ssl.enable", "false"))) {
    	SslContextFactory factory = new SslContextFactory(Boolean.parseBoolean(Config.getBlurConfig().get("blur.console.ssl.hostname.match", "true")));
    	factory.setKeyStorePath(Config.getBlurConfig().get("blur.console.ssl.keystore.path"));
    	factory.setKeyStorePassword(Config.getBlurConfig().get("blur.console.ssl.keystore.password"));
    	factory.setTrustStore(Config.getBlurConfig().get("blur.console.ssl.truststore.path"));
    	factory.setTrustStorePassword(Config.getBlurConfig().get("blur.console.ssl.truststore.password"));
    	
    	SslSelectChannelConnector sslConnector = new SslSelectChannelConnector(factory);
    	sslConnector.setPort(port);
    	
    	server.addConnector(sslConnector);
    }

    // for localhost:port/console/index.html and whatever else is in the webapp directory
    URL warUrl = null;
      if (devMode) {
          warUrl = new URL("file://" + new File(DEV_WEBAPPDIR).getAbsolutePath());
      } else {
          warUrl = this.getClass().getClassLoader().getResource(PROD_WEBAPPDIR);
      }
    String warUrlString = warUrl.toExternalForm();
    WebAppContext staticContext = new WebAppContext(warUrlString, CONTEXTPATH);
    staticContext.setSessionHandler(new SessionHandler());

    // service calls
//    ContextHandler servletContext = new ServletContextHandler(ServletContextHandler.SESSIONS);
//    servletContext.setContextPath("/console/service");
    ServletHandler serviceHandler = new ServletHandler();
    serviceHandler.addServletWithMapping(AuthServlet.class, "/service/auth/*");
    serviceHandler.addServletWithMapping(NodesServlet.class, "/service/nodes/*");
    serviceHandler.addServletWithMapping(TablesServlet.class, "/service/tables/*");
    serviceHandler.addServletWithMapping(QueriesServlet.class, "/service/queries/*");
    serviceHandler.addServletWithMapping(SearchServlet.class, "/service/search/*");
    serviceHandler.addServletWithMapping(JavascriptServlet.class, "/service/config.js");
    serviceHandler.addFilterWithMapping(LoggedInFilter.class, "/service/*", FilterMapping.REQUEST);
//    servletContext.setHandler(serviceHandler);
    staticContext.setServletHandler(serviceHandler);


//    ContextHandlerCollection handlers = new ContextHandlerCollection();
//    handlers.setHandlers(new Handler[] { /*servletContext,*/ staticContext  });

    server.setHandler(staticContext);
    System.out.println("started server on http://localhost:" + port + CONTEXTPATH);
    try {
      server.start();
      System.out.println(server.getHandlers()[0]);
    } catch (Exception e) {
      log.error("Error starting Blur Console Jetty Server.  Exiting", e);
      System.exit(1);
    }
  }
 
開發者ID:apache,項目名稱:incubator-blur,代碼行數:56,代碼來源:JettyServer.java


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