Difference between GrizzlyServerFactory.createHttpServer and the new GrizzlyWebServer WebServer

I am building RESTful web services using Jersey and the Grizzly Embedded Web Server.

I see that there are two ways to create a Grizzly embedded web server. Can someone tell me the difference between the two?

public static void main(String[] args) throws IOException,  ConfigurationException,    DBException, DaxException {
    GrizzlyWebServer gws = new GrizzlyWebServer(8085, "/var/www");
    ServletAdapter jerseyAdapter = new ServletAdapter();

    jerseyAdapter.addInitParameter(
        PackagesResourceConfig.PROPERTY_PACKAGES,"com.merchant.services");
    jerseyAdapter.setServletInstance(new ServletContainer());

    gws.addGrizzlyAdapter(jerseyAdapter, new String[]{"/"});

    // let Grizzly run
    gws.start();
}  

And the second way:

ResourceConfig rc = new PackagesResourceConfig("com.merchant.services");
HttpServer httpServer = GrizzlyServerFactory.createHttpServer(BASE_URI, rc);
httpServer.start();

The first time it’s easy to set up a web server

+5
source share
1 answer

1

Grizzly Web Servewith the approach ServletAdapteris to support JAX-RS along with Servletand Filters., which gives you

Jersey + ServletContainer

This will give you enough flexibility to provide a more complex configuration.

2

If you think this ServletContaineris an addiction, use the second.

Jersey + Simple Http Server

+3
source

All Articles