users@grizzly.java.net

Re: where is the GrizzlyWebServer class in version 2.x?

From: Oleksiy Stashok <oleksiy.stashok_at_oracle.com>
Date: Sat, 13 Oct 2012 11:45:11 +0200

Hi,

we reworked GrizzlyWebServer and in 2.0 it's HttpServer.
Regarding Grizzly 2.x, Guice and Jersey, you can find sample code here
[1], specifically this class might be interesting [2].

WBR,
Alexey.

[1]
http://java.net/projects/jersey/sources/svn/content/trunk/jersey/contribs/jersey-guice/src/test/java/com/sun/jersey/guice/
[2]
http://java.net/projects/jersey/sources/svn/content/trunk/jersey/contribs/jersey-guice/src/test/java/com/sun/jersey/guice/AbstractGuiceGrizzlyTest.java

On 10/12/2012 11:47 PM, myxjtu_at_yahoo.com wrote:
> I have a code snippet which uses GrizzlyWebServer and it works fine on
> 1.9.52. But it failed on version 2.x. Actually I could not find this
> class in version 2.x. Any hint?
>
> BTW, here is the code: (I use Guice injection as well in the code)
>
> public class JerseyTaxonomyServletAsyncTest {
> @SuppressWarnings("serial")
> public static class DummySevlet extends HttpServlet { }
>
> // @Ignore
> @Test
> public void testWithGrizzly() throws IllegalArgumentException,
> NullPointerException, IOException {
> // sample code for grizzly setup:
> //
> http://code.google.com/p/jersey-guice-demo/source/browse/trunk/src/main
> /java/demo/App.java
> GrizzlyWebServer server = new GrizzlyWebServer(9998);
> ServletAdapter adapter = new ServletAdapter(new DummySevlet());
>
> adapter.addServletListener(GuiceServletConfig.class.getName());
> adapter.addFilter(new GuiceFilter(), "GuiceFilter", null);
> server.addGrizzlyAdapter(adapter, new String[]{ "/" });
> server.start();
>
> Client client = ClientFactory.newClient();
> Response response =
> client.target(UriBuilder.fromUri("http://localhost:9998").path("/taxono
> my").build())
>
> .request(MediaType.APPLICATION_XML).get(Response.class);
>
> int responseCode = response.getStatus();
> TaxonomyResponse taxonomyResponse =
> response.readEntity(TaxonomyResponse.class);
>
> //String responseMsg =
> webResource.path("getAttributes").get(String.class);
> // assertEquals("Hello World", responseMsg);
> assertEquals(responseCode, 200);
>
> server.stop();
> }
>
>
> }