use of org.apache.cxf.cdi.CXFCdiServlet 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