users@jersey.java.net

Re: [Jersey] AnnotatedClassScanner - Best Practice

From: Craig McClanahan <Craig.McClanahan_at_Sun.COM>
Date: Fri, 02 Oct 2009 09:46:23 -0700

Cemo Koc wrote:
> Hi all,
>
> I am very newbie to JAX-RS. I have read all spec and documentation since
> yesterday although dev.java.net has some serious issues.
>
> I have two different maven modules and each has different dependencies.
>
> Client side (com.x.y:client) has : jersey-client dependency
>
> [INFO] +- com.sun.jersey:jersey-client:jar:1.0.3.1:compile
> [INFO] | \- com.sun.jersey:jersey-core:jar:1.0.3.1:compile
> [INFO] | \- javax.ws.rs:jsr311-api:jar:1.0:compile
>
> Server side (com.x.y:server) has: jersey-server dependency and client
> dependency
> (Server side has resources.)
>
> [INFO] +- com.sun.jersey:jersey-server:jar:1.0.3.1:compile
> [INFO] | +- com.sun.jersey:jersey-core:jar:1.0.3.1:compile
> [INFO] | | \- javax.ws.rs:jsr311-api:jar:1.0:compile
> [INFO] | \- asm:asm:jar:3.1:compile
> [INFO] +- com.x.y:client:jar:2.3.7:compile
> [INFO] | \- com.sun.jersey:jersey-client:jar:1.0.1:compile
>
> 1. Is such implementation best practice in terms maven perspective?
>
> 2. This is about AnnotatedClassScanner which is used by our custom provider.
> Where my custom provider implementation should be? In my case it is at
> client side library because client side is referenced from Server side.
>
> 3. And If my implementation is right, I think that AnnotatedClassScanner
> should be at jersey-core library. Because this class should have been
> accessed from both Client Side and Server Side.
>
>
Why does your server module depend on the client module?

When I have classes that are logically useful in both tiers (most often,
the JAXB based model classes for my representations), I factor those
into a third "models" module that is then depended on by both "server"
and "client". That could of course become a place for other shared
stuff, like providers that are needed at both ends. But this avoids
having your server drag in a bunch of stuff it doesn't otherwise need
(unless, of course, your server is a client for other services that *it*
calls out to).

Craig
> Thanks
>
>
>