use of org.eclipse.jetty.server.handler.HandlerCollection in project cxf by apache.
the class AegisServer 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("/");
webappcontext.setBaseResource(Resource.newClassPathResource("/webapp"));
server.setHandler(new HandlerCollection(webappcontext, new DefaultHandler()));
try {
server.start();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of org.eclipse.jetty.server.handler.HandlerCollection 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.setBaseResource(Resource.newClassPathResource(resourcePath));
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());
}
}
use of org.eclipse.jetty.server.handler.HandlerCollection in project athenz by yahoo.
the class AthenzJettyContainer method createServer.
public void createServer(int maxThreads) {
// Setup Thread pool
QueuedThreadPool threadPool = new QueuedThreadPool();
threadPool.setMaxThreads(maxThreads);
server = new Server(threadPool);
handlers = new HandlerCollection();
server.setHandler(handlers);
}
use of org.eclipse.jetty.server.handler.HandlerCollection in project gocd by gocd.
the class Jetty9Server method configure.
@Override
public void configure() throws Exception {
server.addEventListener(mbeans());
server.addConnector(plainConnector());
ContextHandlerCollection handlers = new ContextHandlerCollection();
deploymentManager.setContexts(handlers);
createWebAppContext();
JettyCustomErrorPageHandler errorHandler = new JettyCustomErrorPageHandler();
webAppContext.setErrorHandler(errorHandler);
webAppContext.setGzipHandler(gzipHandler());
server.addBean(errorHandler);
server.addBean(deploymentManager);
HandlerCollection serverLevelHandlers = new HandlerCollection();
serverLevelHandlers.setHandlers(new Handler[] { handlers });
server.setHandler(serverLevelHandlers);
performCustomConfiguration();
server.setStopAtShutdown(true);
}
use of org.eclipse.jetty.server.handler.HandlerCollection in project incubator-pulsar by apache.
the class WorkerServer method run.
@Override
public void run() {
final Server server = new Server(this.workerConfig.getWorkerPort());
List<Handler> handlers = new ArrayList<>(2);
handlers.add(newServletContextHandler("/admin", new ResourceConfig(Resources.getApiResources()), workerService));
handlers.add(newServletContextHandler("/admin/v2", new ResourceConfig(Resources.getApiResources()), workerService));
handlers.add(newServletContextHandler("/", new ResourceConfig(Resources.getRootResources()), workerService));
ContextHandlerCollection contexts = new ContextHandlerCollection();
contexts.setHandlers(handlers.toArray(new Handler[handlers.size()]));
HandlerCollection handlerCollection = new HandlerCollection();
handlerCollection.setHandlers(new Handler[] { contexts, new DefaultHandler() });
server.setHandler(handlerCollection);
try {
server.start();
log.info("Worker Server started at {}", server.getURI());
server.join();
} catch (Exception ex) {
log.error("ex: {}", ex, ex);
final String message = getErrorMessage(server, this.workerConfig.getWorkerPort(), ex);
log.error(message);
System.exit(1);
} finally {
server.destroy();
}
}
Aggregations