Skip to main content

Extending the Grizzly HTTP Runtime part V: Programatically configuring Servlet and GrizzlyAdapter

Posted by jfarcand on January 8, 2009 at 4:12 PM PST

This blog has moved here

Related Topics >>


@bragest -> I've posted the response here: . Ins hort. I agree with you we need to improve the API.

I see, thank you. However my use case is a bit more complicated ;-) I have two filters with different mappings and a context listener. It is important that the listener has servlet API semantics (singleton, methods invoked just once, ...). Currently my code in Jetty looks with this: Context context = new Context(null, "/", options); context.addEventListener(new EventListener()); context.addFilter(AFilter.class, "/a*", Handler.REQUEST); context.addFilter(BFilter.class, "/b*", Handler.REQUEST); which is very simple. I fear that when I add two ServletAdapters to a GrizzlyWebServer or a GrizzlyAdapterChain that the context listener will receive events twice.

I've posted the response here -> so the community can comments/help. Thanks!!

When adding filters is it also possible to set a filter mapping and the dispatcher types? I need this and it can be done with Jetty.

See the answer here: and the following discussion.

Is it possible to have an embedded version but that reads the configuration from files like a regular container would do?

I say so because I currently use Jetty embedded and I use always the same "Jetty launcher" code and I just point it to the proper directory to be mounted and it reads the web.xml and deploys the application, etc.

This was I can re-use the same code for every tiny application I want to, without harcoding the servlets, filters etc. that I need. And at the same time, the web application can be mounted in a regular container without a change.
I understand how doing everything in code can be very useful sometimes, but in my case I'd rather do it like that..
Salute and good job!