本文整理汇总了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();
}
示例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) {
}
});
}
示例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;
}
示例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();
}
示例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();
}
示例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();
}
示例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);
}
示例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);
}
}