Search in sources :

Example 36 with ServletContainer

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);
}
Also used : ServletHolder(org.eclipse.jetty.servlet.ServletHolder) ServletContainer(org.glassfish.jersey.servlet.ServletContainer) JacksonJaxbJsonProvider(com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider) ResourceConfig(org.glassfish.jersey.server.ResourceConfig) ServletContextHandler(org.eclipse.jetty.servlet.ServletContextHandler)

Example 37 with ServletContainer

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;
}
Also used : ServletHolder(org.eclipse.jetty.servlet.ServletHolder) ServletContainer(org.glassfish.jersey.servlet.ServletContainer) ServletContextHandler(org.eclipse.jetty.servlet.ServletContextHandler)

Example 38 with ServletContainer

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;
}
Also used : WebAppContext(org.eclipse.jetty.webapp.WebAppContext) Server(org.eclipse.jetty.server.Server) Openscoring(org.openscoring.service.Openscoring) ServletHolder(org.eclipse.jetty.servlet.ServletHolder) ServletContainer(org.glassfish.jersey.servlet.ServletContainer) ContextHandlerCollection(org.eclipse.jetty.server.handler.ContextHandlerCollection) ServletContextHandler(org.eclipse.jetty.servlet.ServletContextHandler)

Example 39 with ServletContainer

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);
}
Also used : ApiResource(com.jayway.jsonpath.web.resource.ApiResource) ServletContainer(org.glassfish.jersey.servlet.ServletContainer) ResourceConfig(org.glassfish.jersey.server.ResourceConfig)

Example 40 with ServletContainer

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);
}
Also used : ServletHolder(org.eclipse.jetty.servlet.ServletHolder) ServletContainer(org.glassfish.jersey.servlet.ServletContainer)

Aggregations

ServletContainer (org.glassfish.jersey.servlet.ServletContainer)49 ServletHolder (org.eclipse.jetty.servlet.ServletHolder)30 ResourceConfig (org.glassfish.jersey.server.ResourceConfig)29 ServletContextHandler (org.eclipse.jetty.servlet.ServletContextHandler)24 Server (org.eclipse.jetty.server.Server)10 IOException (java.io.IOException)7 DispatcherType (javax.servlet.DispatcherType)6 FilterHolder (org.eclipse.jetty.servlet.FilterHolder)6 JacksonJsonProvider (com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider)5 ServletRegistrationBean (org.springframework.boot.web.servlet.ServletRegistrationBean)5 Bean (org.springframework.context.annotation.Bean)5 JacksonJaxbJsonProvider (com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider)4 DefaultHandler (org.eclipse.jetty.server.handler.DefaultHandler)4 RequestLogHandler (org.eclipse.jetty.server.handler.RequestLogHandler)4 StatisticsHandler (org.eclipse.jetty.server.handler.StatisticsHandler)4 ServletRegistration (javax.servlet.ServletRegistration)3 ConnectException (org.apache.kafka.connect.errors.ConnectException)3 ConnectorPluginsResource (org.apache.kafka.connect.runtime.rest.resources.ConnectorPluginsResource)3 ConnectorsResource (org.apache.kafka.connect.runtime.rest.resources.ConnectorsResource)3 Slf4jRequestLog (org.eclipse.jetty.server.Slf4jRequestLog)3