users@grizzly.java.net

Grizzly 2 + Guice + Jersey

From: Christopher Piggott <cpiggott_at_gmail.com>
Date: Tue, 5 Jun 2012 10:01:47 -0400

Hi,

I'm trying to upgrade from Grizzly 1.9 to Grizzly 2, and with a lot of
problems. I'm currently importing jersey-grizzly2-1.12 as well as
jersey-grizzly2-servlet-1.12 but neither one of those seems to get me
what I need, at least not as far as I can tell. It looks like those
packages might be intended for the non-guice configuration; what I
really need is to create a webapp that is driven by a filter, not a
servlet.

I create my main injector (which has bindings for all my jersey
resource classes):

                Injector mainInjector = Guice.createInjector(new ResourceModule());

From that, I can create a GuiceContainer:

                ServletConfig cfg = new GuiceContainer(mainInjector);

An SSL Context:
                SSLContextConfigurator sslContext = new SSLContextConfigurator();
                sslContext.setKeyStoreFile("xxx");
                sslContext.setKeyStorePass("yyy");
                sslContext.setTrustStoreFile("zzz");
                sslContext.setTrustStorePass("aaa");

                
A web server:
                HttpServer server = HttpServer.createSimpleServer();
                

Set all the web server's listeners to use SSL only:
                for (NetworkListener listener : server.getListeners()) {
                        listener.setSecure(true);
                        listener.setSSLEngineConfig(
                                        new SSLEngineConfigurator(sslContext).setClientMode(false).setNeedClientAuth(true));
                }

but here is where I'm stuck: I dont' know how to take that
ServletConfig and attach it to the server.

Where am i going wrong?

--Chris