users@grizzly.java.net

Re: Adding a Websocket engine to a context that already has a filter

From: Oleksiy Stashok <oleksiy.stashok_at_oracle.com>
Date: Fri, 03 May 2013 17:29:06 -0700

Hi Christopher,

can you pls. share the entire app, so it would be easier to test?

Thank you.

WBR,
Alexey.

On 03.05.13 11:56, Christopher Piggott wrote:
> I have a jersy/guice/grizzly application that has jersey instantiated
> as a GuiceFilter. It goes something like:
>
> WebappContext ctx = new WebappContext( "xt", "" );
> ctx.addListener( MyServletContextListener.class );
> FilterRegistration filter = ctx.addFilter( "myServletFilter",
> GuiceFilter.class );
>
> filter.addMappingForUrlPatterns( EnumSet.of( DispatcherType.REQUEST ),
> "/myJersey/*" );
>
>
> ws = new HttpServer();
>
>
> NetworkListener nl = new NetworkListener( "xt-listener",
> NetworkListener.DEFAULT_NETWORK_HOST, port );
>
> WebSocketAddOn webSocketAddon = new WebSocketAddOn();
> nl.registerAddOn( webSocketAddon );
>
> MyWebSocketApp app = new AhmWebSocketApp();
> WebSocketEngine.getEngine().register( "", "/ws/*", app );
>
>
> ServletRegistration sreg = ctx.addServlet( "defaultServlet",
> MyDefaultServlet.class );
> sreg.addMapping( "*" );
> ctx.deploy( ws );
> ws.addListener( nl );
>
> The problem is that the filter picks up everything it's mapped to,
> then my default servlet picks up everything else. Because of that,
> the /ws/* piece that should be directed to the WSE never gets there.
>
> If there any way to influence the order that these paths are
> processed, to make it look for /ws/* FIRST ?
>
> --C
>