users@jersey.java.net

[Jersey] Re: Explicitly declare the root resource and provider classes - not working for provider class

From: Glen Mazza <gmazza_at_talend.com>
Date: Tue, 28 Feb 2012 20:04:39 -0500

Just more detective work, basically see what Jersey does
behind-the-scenes. Go to grepcode on "GrizzlyServerFactory" -- line 75
in the Main.java I linked to below. You'll see what Jersey does:
http://grepcode.com/file/repo1.maven.org/maven2/com.sun.jersey/jersey-grizzly2/1.11/com/sun/jersey/api/container/grizzly2/GrizzlyServerFactory.java#GrizzlyServerFactory.createHttpServer%28java.net.URI%2Ccom.sun.jersey.api.container.grizzly2.ResourceConfig%29

I see an HttpHandler in that method, so I'll leave the rest to you as an
exercise. :)

Glen


On 02/28/2012 07:36 PM, Farrukh Najmi wrote:
> On 02/28/2012 01:22 PM, Glen Mazza wrote:
>> On 02/28/2012 01:04 PM, Farrukh Najmi wrote:
>>> BTW, when I set breakpoints inside my getClasses() and
>>> getSingletons() methods of my "class HubSubscriber extends
>>> javax.ws.rs.core.Application" I find they are never called!
>>
>> Did you remember to wire your Application subclass in like here:
>> http://java.net/projects/jersey/sources/svn/content/tags/jersey-1.11/jersey/samples/jacksonjsonprovider/src/main/java/com/sun/jersey/samples/jacksonjsonprovider/Main.java?rev=5665
>> (lines 72-75)? Also, I'd try a System.out.println() in those two
>> methods to confirm they're not being called -- it could be the
>> debugger is wrong for some reason.
>
> I did not do that! So that explains why the getClasses() and
> getSingletons() methods are not being called.
>
> Now here is my problem. I am using the following method
> <http://grepcode.com/file/repo1.maven.org/maven2/com.sun.jersey/jersey-grizzly2/1.10/com/sun/jersey/api/container/grizzly2/GrizzlyServerFactory.java#GrizzlyServerFactory.createHttpServer%28java.net.URI%2Ccom.sun.jersey.api.container.grizzly2.HttpHandler%2Cboolean%29>
> to create my HttpServer. I need to specify an HttpHandler. So how do I
> pass it a ResourceConfig instance? I think there is a way to create an
> HttpHandler with a specified ResourceConfig but I do not know how to
> do that. Any advice?
>
> Thanks again for your kind help.
> --
> Regards,
> Farrukh Najmi
>
> Web:http://www.wellfleetsoftware.com
>


-- 
Glen Mazza
Talend Community Coders - coders.talend.com
blog: www.jroller.com/gmazza