use of org.eclipse.jetty.servlet.ServletHandler in project nifi by apache.
the class TestPostHTTP method setup.
private void setup(final Map<String, String> sslProperties) throws Exception {
// set up web service
ServletHandler handler = new ServletHandler();
handler.addServletWithMapping(CaptureServlet.class, "/*");
// create the service
server = new TestServer(sslProperties);
server.addHandler(handler);
server.startServer();
servlet = (CaptureServlet) handler.getServlets()[0].getServlet();
runner = TestRunners.newTestRunner(PostHTTP.class);
}
use of org.eclipse.jetty.servlet.ServletHandler in project nifi by apache.
the class TestHttpClient method setup.
@BeforeClass
public static void setup() throws Exception {
// Create embedded Jetty server
// Use less threads to mitigate Gateway Timeout (504) with proxy test
// Minimum thread pool size = (acceptors=2 + selectors=8 + request=1), defaults to max=200
final QueuedThreadPool threadPool = new QueuedThreadPool(50);
server = new Server(threadPool);
final ContextHandlerCollection handlerCollection = new ContextHandlerCollection();
final ServletContextHandler contextHandler = new ServletContextHandler();
contextHandler.setContextPath("/nifi-api");
final ServletContextHandler wrongPathContextHandler = new ServletContextHandler();
wrongPathContextHandler.setContextPath("/wrong/nifi-api");
handlerCollection.setHandlers(new Handler[] { contextHandler, wrongPathContextHandler });
server.setHandler(handlerCollection);
final ServletHandler servletHandler = new ServletHandler();
contextHandler.insertHandler(servletHandler);
final ServletHandler wrongPathServletHandler = new ServletHandler();
wrongPathContextHandler.insertHandler(wrongPathServletHandler);
final SslContextFactory sslContextFactory = new SslContextFactory();
sslContextFactory.setKeyStorePath("src/test/resources/certs/localhost-ks.jks");
sslContextFactory.setKeyStorePassword("localtest");
sslContextFactory.setKeyStoreType("JKS");
httpConnector = new ServerConnector(server);
final HttpConfiguration https = new HttpConfiguration();
https.addCustomizer(new SecureRequestCustomizer());
sslConnector = new ServerConnector(server, new SslConnectionFactory(sslContextFactory, "http/1.1"), new HttpConnectionFactory(https));
server.setConnectors(new Connector[] { httpConnector, sslConnector });
wrongPathServletHandler.addServletWithMapping(WrongSiteInfoServlet.class, "/site-to-site");
servletHandler.addServletWithMapping(SiteInfoServlet.class, "/site-to-site");
servletHandler.addServletWithMapping(PeersServlet.class, "/site-to-site/peers");
servletHandler.addServletWithMapping(PortTransactionsAccessDeniedServlet.class, "/data-transfer/input-ports/input-access-denied-id/transactions");
servletHandler.addServletWithMapping(PortTransactionsServlet.class, "/data-transfer/input-ports/input-running-id/transactions");
servletHandler.addServletWithMapping(InputPortTransactionServlet.class, "/data-transfer/input-ports/input-running-id/transactions/transaction-id");
servletHandler.addServletWithMapping(FlowFilesServlet.class, "/data-transfer/input-ports/input-running-id/transactions/transaction-id/flow-files");
servletHandler.addServletWithMapping(PortTransactionsServlet.class, "/data-transfer/input-ports/input-timeout-id/transactions");
servletHandler.addServletWithMapping(InputPortTransactionServlet.class, "/data-transfer/input-ports/input-timeout-id/transactions/transaction-id");
servletHandler.addServletWithMapping(FlowFilesTimeoutServlet.class, "/data-transfer/input-ports/input-timeout-id/transactions/transaction-id/flow-files");
servletHandler.addServletWithMapping(PortTransactionsServlet.class, "/data-transfer/input-ports/input-timeout-data-ex-id/transactions");
servletHandler.addServletWithMapping(InputPortTransactionServlet.class, "/data-transfer/input-ports/input-timeout-data-ex-id/transactions/transaction-id");
servletHandler.addServletWithMapping(FlowFilesTimeoutAfterDataExchangeServlet.class, "/data-transfer/input-ports/input-timeout-data-ex-id/transactions/transaction-id/flow-files");
servletHandler.addServletWithMapping(PortTransactionsServlet.class, "/data-transfer/output-ports/output-running-id/transactions");
servletHandler.addServletWithMapping(OutputPortTransactionServlet.class, "/data-transfer/output-ports/output-running-id/transactions/transaction-id");
servletHandler.addServletWithMapping(FlowFilesServlet.class, "/data-transfer/output-ports/output-running-id/transactions/transaction-id/flow-files");
servletHandler.addServletWithMapping(PortTransactionsServlet.class, "/data-transfer/output-ports/output-timeout-id/transactions");
servletHandler.addServletWithMapping(OutputPortTransactionServlet.class, "/data-transfer/output-ports/output-timeout-id/transactions/transaction-id");
servletHandler.addServletWithMapping(FlowFilesTimeoutServlet.class, "/data-transfer/output-ports/output-timeout-id/transactions/transaction-id/flow-files");
servletHandler.addServletWithMapping(PortTransactionsServlet.class, "/data-transfer/output-ports/output-timeout-data-ex-id/transactions");
servletHandler.addServletWithMapping(OutputPortTransactionServlet.class, "/data-transfer/output-ports/output-timeout-data-ex-id/transactions/transaction-id");
servletHandler.addServletWithMapping(FlowFilesTimeoutAfterDataExchangeServlet.class, "/data-transfer/output-ports/output-timeout-data-ex-id/transactions/transaction-id/flow-files");
server.start();
logger.info("Starting server on port {} for HTTP, and {} for HTTPS", httpConnector.getLocalPort(), sslConnector.getLocalPort());
startProxyServer();
startProxyServerWithAuth();
}
use of org.eclipse.jetty.servlet.ServletHandler in project nifi by apache.
the class AtlasAPIV2ServerEmulator method createServer.
private void createServer() throws Exception {
server = new Server();
final ContextHandlerCollection handlerCollection = new ContextHandlerCollection();
final ServletContextHandler staticContext = new ServletContextHandler();
staticContext.setContextPath("/");
final ServletContextHandler atlasApiV2Context = new ServletContextHandler();
atlasApiV2Context.setContextPath("/api/atlas/v2/");
handlerCollection.setHandlers(new Handler[] { staticContext, atlasApiV2Context });
server.setHandler(handlerCollection);
final ResourceHandler resourceHandler = new ResourceHandler();
resourceHandler.setBaseResource(Resource.newClassPathResource("public", false, false));
staticContext.setHandler(resourceHandler);
final ServletHandler servletHandler = new ServletHandler();
atlasApiV2Context.insertHandler(servletHandler);
httpConnector = new ServerConnector(server);
httpConnector.setPort(21000);
server.setConnectors(new Connector[] { httpConnector });
servletHandler.addServletWithMapping(TypeDefsServlet.class, "/types/typedefs/");
servletHandler.addServletWithMapping(EntityBulkServlet.class, "/entity/bulk/");
servletHandler.addServletWithMapping(EntityGuidServlet.class, "/entity/guid/*");
servletHandler.addServletWithMapping(SearchByUniqueAttributeServlet.class, "/entity/uniqueAttribute/type/*");
servletHandler.addServletWithMapping(SearchBasicServlet.class, "/search/basic/");
servletHandler.addServletWithMapping(LineageServlet.class, "/debug/lineage/");
notificationServerEmulator = new AtlasNotificationServerEmulator();
}
use of org.eclipse.jetty.servlet.ServletHandler in project core by weld.
the class EclipseWeldServletHandler method findWAC.
protected static WebAppContext findWAC(ServletContext context) {
if (context instanceof ContextHandler.Context) {
ContextHandler.Context sContext = (ContextHandler.Context) context;
ContextHandler contextHandler = sContext.getContextHandler();
Handler handler = contextHandler.getHandler();
if (handler instanceof ServletHandler) {
ServletHandler servletHandler = (ServletHandler) handler;
Server server = servletHandler.getServer();
Handler serverHandler = server.getHandler();
if (serverHandler instanceof HandlerCollection) {
HandlerCollection hc = (HandlerCollection) serverHandler;
for (Handler h : hc.getHandlers()) {
if (h instanceof WebAppContext) {
WebAppContext wac = (WebAppContext) h;
if (wac.getServletHandler() == servletHandler) {
return wac;
}
}
}
}
}
}
return null;
}
use of org.eclipse.jetty.servlet.ServletHandler in project oozie by apache.
the class ServletMapper method mapOozieServlets.
/**
* Maps Oozie servlets to path specs. Make sure it is in sync with FilterMapper when making changes.
*/
void mapOozieServlets() {
mapServlet(VersionServlet.class, "/versions");
mapServlet(V0AdminServlet.class, "/v0/admin/*");
mapServlet(V1AdminServlet.class, "/v1/admin/*");
mapServlet(V2AdminServlet.class, "/v2/admin/*");
mapServlet(CallbackServlet.class, "/callback/*");
ServletHandler servletHandler = servletContextHandler.getServletHandler();
String v0JobsServletName = V0JobsServlet.class.getSimpleName();
servletHandler.addServlet(new ServletHolder(v0JobsServletName, new V0JobsServlet()));
ServletMapping jobServletMappingV0 = new ServletMapping();
jobServletMappingV0.setPathSpec("/v0/jobs");
jobServletMappingV0.setServletName(v0JobsServletName);
String v1JobsServletName = V1JobsServlet.class.getSimpleName();
servletHandler.addServlet(new ServletHolder(v1JobsServletName, new V1JobsServlet()));
ServletMapping jobServletMappingV1 = new ServletMapping();
jobServletMappingV1.setPathSpec("/v1/jobs");
jobServletMappingV1.setServletName(v1JobsServletName);
// v1 and v2 version for the jobs API are same.
ServletMapping jobServletMappingV2 = new ServletMapping();
jobServletMappingV2.setPathSpec("/v2/jobs");
jobServletMappingV2.setServletName(v1JobsServletName);
servletHandler.addServletMapping(jobServletMappingV0);
servletHandler.addServletMapping(jobServletMappingV1);
servletHandler.addServletMapping(jobServletMappingV2);
mapServlet(V0JobServlet.class, "/v0/job/*");
mapServlet(V1JobServlet.class, "/v1/job/*");
mapServlet(V2JobServlet.class, "/v2/job/*");
mapServlet(SLAServlet.class, "/v1/sla/*");
mapServlet(V2SLAServlet.class, "/v2/sla/*");
mapServlet(V2ValidateServlet.class, "/v2/validate/*");
mapServlet(ErrorServlet.class, "/error/*");
}
Aggregations