use of org.glassfish.jersey.servlet.ServletContainer in project incubator-pulsar by apache.
the class WebServer method addRestResources.
public void addRestResources(String basePath, String javaPackages, String attribute, Object attributeValue) {
JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider();
provider.setMapper(ObjectMapperFactory.create());
ResourceConfig config = new ResourceConfig();
config.packages("jersey.config.server.provider.packages", javaPackages);
config.register(provider);
ServletHolder servletHolder = new ServletHolder(new ServletContainer(config));
servletHolder.setAsyncSupported(true);
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
context.setContextPath(basePath);
context.addServlet(servletHolder, "/*");
context.setAttribute(attribute, attributeValue);
handlers.add(context);
}
use of org.glassfish.jersey.servlet.ServletContainer in project incubator-pulsar by apache.
the class WorkerServer method newServletContextHandler.
public static ServletContextHandler newServletContextHandler(String contextPath, ResourceConfig config, WorkerService workerService) {
final ServletContextHandler contextHandler = new ServletContextHandler(ServletContextHandler.NO_SESSIONS);
contextHandler.setAttribute(FunctionApiResource.ATTRIBUTE_FUNCTION_WORKER, workerService);
contextHandler.setContextPath(contextPath);
final ServletHolder apiServlet = new ServletHolder(new ServletContainer(config));
contextHandler.addServlet(apiServlet, "/*");
return contextHandler;
}
use of org.glassfish.jersey.servlet.ServletContainer in project openscoring by openscoring.
the class Main method createServer.
private Server createServer(InetSocketAddress address) {
Server server = new Server(address);
Openscoring application = new Openscoring();
ServletContainer jerseyServlet = new ServletContainer(application);
ServletContextHandler servletHandler = new ServletContextHandler();
servletHandler.setContextPath(this.contextPath);
servletHandler.addServlet(new ServletHolder(jerseyServlet), "/*");
ContextHandlerCollection handlerCollection = new ContextHandlerCollection();
handlerCollection.addHandler(servletHandler);
if (this.consoleWar != null) {
WebAppContext consoleHandler = new WebAppContext();
// XXX
consoleHandler.setContextPath(this.contextPath + "/console");
consoleHandler.setWar(this.consoleWar.getAbsolutePath());
handlerCollection.addHandler(consoleHandler);
}
server.setHandler(handlerCollection);
return server;
}
use of org.glassfish.jersey.servlet.ServletContainer in project JsonPath by json-path.
the class Main method createJerseyServlet.
private static ServletContainer createJerseyServlet() throws IOException {
ResourceConfig resourceConfig = new ResourceConfig();
resourceConfig.register(JacksonFeature.class);
resourceConfig.register(new ApiResource());
return new ServletContainer(resourceConfig);
}
use of org.glassfish.jersey.servlet.ServletContainer in project helix by apache.
the class HelixRestServer method initServlet.
private void initServlet(ResourceConfig cfg, String servletPathSpec) {
ServletHolder servlet = new ServletHolder(new ServletContainer(cfg));
_servletContextHandler.addServlet(servlet, servletPathSpec);
}
Aggregations