use of org.eclipse.jetty.server.handler.DefaultHandler in project gravel by gravel-st.
the class StartJetty method main.
public static void main(String[] args) throws Exception {
File fn;
int port = 8080;
if (args.length == 0) {
fn = ImageBootstrapper.defaultSourceFolder();
} else {
fn = new File(args[0]);
if (args.length != 1) {
port = Integer.parseInt(args[1]);
}
}
ImageBootstrapper.bootstrap(fn);
Server server = new Server(port);
ServletContextHandler servletContext = new ServletContextHandler(ServletContextHandler.SESSIONS);
servletContext.setContextPath("/browser");
ResourceHandler staticFilesHandler = new ResourceHandler();
staticFilesHandler.setResourceBase("src/main/html");
HandlerList handlers = new HandlerList();
handlers.setHandlers(new Handler[] { servletContext, staticFilesHandler, new DefaultHandler() });
Object stServlet = getStServlet();
servletContext.addServlet(new ServletHolder(new JettyToStHttpServletConverter(stServlet)), "/*");
server.setHandler(handlers);
server.start();
server.join();
}
use of org.eclipse.jetty.server.handler.DefaultHandler in project sonarqube by SonarSource.
the class SSLTest method startSSLTransparentReverseProxy.
public static void startSSLTransparentReverseProxy(boolean requireClientAuth) throws Exception {
int httpPort = NetworkUtils.getNextAvailablePort();
httpsPort = NetworkUtils.getNextAvailablePort();
// Setup Threadpool
QueuedThreadPool threadPool = new QueuedThreadPool();
threadPool.setMaxThreads(500);
server = new Server(threadPool);
// HTTP Configuration
HttpConfiguration httpConfig = new HttpConfiguration();
httpConfig.setSecureScheme("https");
httpConfig.setSecurePort(httpsPort);
httpConfig.setSendServerVersion(true);
httpConfig.setSendDateHeader(false);
// Handler Structure
HandlerCollection handlers = new HandlerCollection();
handlers.setHandlers(new Handler[] { proxyHandler(), new DefaultHandler() });
server.setHandler(handlers);
ServerConnector http = new ServerConnector(server, new HttpConnectionFactory(httpConfig));
http.setPort(httpPort);
server.addConnector(http);
Path serverKeyStore = Paths.get(SSLTest.class.getResource("/analysis/SSLTest/serverkeystore.jks").toURI()).toAbsolutePath();
String keyStorePassword = "serverkeystorepwd";
String serverKeyPassword = "serverp12pwd";
Path serverTrustStore = Paths.get(SSLTest.class.getResource("/analysis/SSLTest/servertruststore.jks").toURI()).toAbsolutePath();
String trustStorePassword = "servertruststorepwd";
// SSL Context Factory
SslContextFactory sslContextFactory = new SslContextFactory();
sslContextFactory.setKeyStorePath(serverKeyStore.toString());
sslContextFactory.setKeyStorePassword(keyStorePassword);
sslContextFactory.setKeyManagerPassword(serverKeyPassword);
sslContextFactory.setTrustStorePath(serverTrustStore.toString());
sslContextFactory.setTrustStorePassword(trustStorePassword);
sslContextFactory.setNeedClientAuth(requireClientAuth);
sslContextFactory.setExcludeCipherSuites("SSL_RSA_WITH_DES_CBC_SHA", "SSL_DHE_RSA_WITH_DES_CBC_SHA", "SSL_DHE_DSS_WITH_DES_CBC_SHA", "SSL_RSA_EXPORT_WITH_RC4_40_MD5", "SSL_RSA_EXPORT_WITH_DES40_CBC_SHA", "SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA", "SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA");
// SSL HTTP Configuration
HttpConfiguration httpsConfig = new HttpConfiguration(httpConfig);
// SSL Connector
ServerConnector sslConnector = new ServerConnector(server, new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString()), new HttpConnectionFactory(httpsConfig));
sslConnector.setPort(httpsPort);
server.addConnector(sslConnector);
server.start();
}
use of org.eclipse.jetty.server.handler.DefaultHandler in project pulsar by yahoo.
the class WebService method start.
public void start() throws PulsarServerException {
try {
RequestLogHandler requestLogHandler = new RequestLogHandler();
Slf4jRequestLog requestLog = new Slf4jRequestLog();
requestLog.setExtended(true);
requestLog.setLogTimeZone(WebService.HANDLER_REQUEST_LOG_TZ);
requestLog.setLogLatency(true);
requestLogHandler.setRequestLog(requestLog);
handlers.add(0, new ContextHandlerCollection());
handlers.add(requestLogHandler);
ContextHandlerCollection contexts = new ContextHandlerCollection();
contexts.setHandlers(handlers.toArray(new Handler[handlers.size()]));
HandlerCollection handlerCollection = new HandlerCollection();
handlerCollection.setHandlers(new Handler[] { contexts, new DefaultHandler(), requestLogHandler });
server.setHandler(handlerCollection);
server.start();
log.info("Web Service started at {}", pulsar.getWebServiceAddress());
} catch (Exception e) {
throw new PulsarServerException(e);
}
}
use of org.eclipse.jetty.server.handler.DefaultHandler in project cxf by apache.
the class DigestServer method run.
protected void run() {
// System.out.println("Starting Server");
server = new org.eclipse.jetty.server.Server(Integer.parseInt(PORT));
WebAppContext webappcontext = new WebAppContext();
webappcontext.setContextPath("/digestauth");
String warPath = null;
try {
URL res = getClass().getResource("/digestauth");
warPath = res.toURI().getPath();
} catch (URISyntaxException e1) {
e1.printStackTrace();
}
webappcontext.setWar(warPath);
HandlerCollection handlers = new HandlerCollection();
handlers.setHandlers(new Handler[] { webappcontext, new DefaultHandler() });
server.setHandler(handlers);
try {
configureServer();
server.start();
} catch (Exception e) {
e.printStackTrace();
}
}
use of org.eclipse.jetty.server.handler.DefaultHandler in project cxf by apache.
the class AbstractJettyServer method run.
protected void run() {
System.setProperty("java.naming.factory.url", "org.eclipse.jetty.jndi");
System.setProperty("java.naming.factory.initial", "org.eclipse.jetty.jndi.InitialContextFactory");
server = new Server(port);
try {
if (resourcePath == null) {
// Register and map the dispatcher servlet
final ServletHolder servletHolder = new ServletHolder(new CXFCdiServlet());
final ServletContextHandler context = new ServletContextHandler();
context.setContextPath(contextPath);
context.addEventListener(listener);
context.addServlet(servletHolder, "/rest/*");
server.setHandler(context);
} else {
final WebAppContext context = new WebAppContext();
context.setContextPath(contextPath);
context.setWar(getClass().getResource(resourcePath).toURI().getPath());
context.setServerClasses(new String[] { "org.eclipse.jetty.servlet.ServletContextHandler.Decorator" });
HandlerCollection handlers = new HandlerCollection();
handlers.setHandlers(new Handler[] { context, new DefaultHandler() });
server.setHandler(handlers);
}
server.start();
} catch (final Exception ex) {
ex.printStackTrace();
fail(ex.getMessage());
}
}
Aggregations