use of org.eclipse.jetty.server.handler.DefaultHandler in project cxf by apache.
the class NioBookStoreServer method run.
protected void run() {
server = new org.eclipse.jetty.server.Server(Integer.parseInt(PORT));
WebAppContext webappcontext = new WebAppContext();
String contextPath = null;
try {
contextPath = getClass().getResource("/jaxrs_nio").toURI().getPath();
} catch (URISyntaxException e1) {
e1.printStackTrace();
}
webappcontext.setContextPath("/");
webappcontext.setWar(contextPath);
HandlerCollection handlers = new HandlerCollection();
handlers.setHandlers(new Handler[] { webappcontext, new DefaultHandler() });
server.setHandler(handlers);
try {
server.start();
} catch (Exception e) {
e.printStackTrace();
}
}
use of org.eclipse.jetty.server.handler.DefaultHandler in project cxf by apache.
the class ResolverTest method startServer.
@Test
public void startServer() throws Throwable {
Server server = new org.eclipse.jetty.server.Server(Integer.parseInt(PORT));
WebAppContext webappcontext = new WebAppContext();
webappcontext.setContextPath("/resolver");
URL res = getClass().getResource("/resolver");
String warPath = res.toURI().getPath();
webappcontext.setWar(warPath);
HandlerCollection handlers = new HandlerCollection();
handlers.setHandlers(new Handler[] { webappcontext, new DefaultHandler() });
server.setHandler(handlers);
server.start();
Throwable e = webappcontext.getUnavailableException();
if (e != null) {
throw e;
}
server.stop();
}
use of org.eclipse.jetty.server.handler.DefaultHandler in project athenz by yahoo.
the class SSLUtilsTest method createHttpsJettyServer.
private static JettyServer createHttpsJettyServer(boolean clientAuth) throws MalformedURLException, IOException {
Server server = new Server();
HttpConfiguration https_config = new HttpConfiguration();
https_config.setSecureScheme("https");
int port = 0;
try (ServerSocket socket = new ServerSocket(0)) {
port = socket.getLocalPort();
}
https_config.setSecurePort(port);
https_config.setOutputBufferSize(32768);
String keystorePath = DEFAULT_SERVER_KEY_STORE;
SslContextFactory sslContextFactory = new SslContextFactory();
File keystoreFile = new File(keystorePath);
if (!keystoreFile.exists()) {
throw new FileNotFoundException();
}
String trustStorePath = DEFAULT_CA_TRUST_STORE;
File trustStoreFile = new File(trustStorePath);
if (!trustStoreFile.exists()) {
throw new FileNotFoundException();
}
sslContextFactory.setTrustStorePath(trustStorePath);
sslContextFactory.setTrustStoreType(DEFAULT_SSL_STORE_TYPE);
sslContextFactory.setTrustStorePassword(DEFAULT_CERT_PWD);
sslContextFactory.setKeyStorePath(keystoreFile.getAbsolutePath());
sslContextFactory.setKeyStoreType(DEFAULT_SSL_STORE_TYPE);
sslContextFactory.setKeyStorePassword(DEFAULT_CERT_PWD);
sslContextFactory.setProtocol(DEFAULT_SSL_PROTOCOL);
sslContextFactory.setNeedClientAuth(clientAuth);
ServerConnector https = new ServerConnector(server, new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString()), new HttpConnectionFactory(https_config));
https.setPort(port);
https.setIdleTimeout(500000);
server.setConnectors(new Connector[] { https });
HandlerList handlers = new HandlerList();
ResourceHandler resourceHandler = new ResourceHandler();
resourceHandler.setBaseResource(Resource.newResource("."));
handlers.setHandlers(new Handler[] { resourceHandler, new DefaultHandler() });
server.setHandler(handlers);
return new JettyServer(server, port);
}
Aggregations