users@jersey.java.net

Re: [Jersey] Re: generic _at_PathParam??

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Mon, 24 Aug 2009 17:18:09 +0200

On Aug 24, 2009, at 4:59 PM, Grover Blue wrote:

> From my understanding of the spec, you need to have an object that
> has a construct which accepts a single string.
>
> Try the following:
> @Embeddable
> public class PK {
>
> public PK(String initString){
> // do something here
> }
>
> @Override
> public String toString(){
> // Stringify your PK if needed
> }
> }
>

There are a number of rules, see here:

   https://jersey.dev.java.net/documentation/1.1.1-ea/user-
guide.html#d4e147

Jersey also allows extensions to the rules using StringReader/Provider:

   https://jersey.dev.java.net/nonav/apidocs/1.1.1-ea/jersey/com/sun/jersey/spi/StringReader.html
   https://jersey.dev.java.net/nonav/apidocs/1.1.1-ea/jersey/com/sun/jersey/spi/StringReaderProvider.html

What Felipe really wants is Jersey to resolve a type variable, T say,
to the concrete type, String say, declared by an extending class.

Currently Jersey only resolves type variables for request entities. I
need to modify the underlying class model that Jersey utilizes so that
it resolves all type variables for parameters of constructors/methods
and fields (and in addition log warnings or errors if a type variable
cannot be resolved).

Paul.


> On Mon, Aug 24, 2009 at 2:14 AM, Paul Sandoz <Paul.Sandoz_at_sun.com>
> wrote:
> * trying
>
> public T select(@PathParam("id") Object login) {
>
> also doesn't work ...
>
> Right, because Object does not give enough information on what type
> to inject.
>
>
>
> On Aug 22, 2009, at 1:22 PM, Felipe Gaúcho wrote:
>
> I finally adopted "String" as generic type, and by luck it seems to
> work with the EntityManager :)
>
> but I would love to have it in generic format (supporting eventually
> JPA @Embeddable keys)
>
>
> Could you log an issue (when java.net is back up) ?
>
> This will require that type variables are resolved at the level of
> the abstract model to ensure injection will work in all cases.
>
> Paul.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
>
>
>
> --
> “If the American people ever allow private banks to control the
> issue of their currency, first by inflation, then by deflation, the
> banks...will deprive the people of all property until their children
> wake-up homeless on the continent their fathers conquered... The
> issuing power should be taken from the banks and restored to the
> people, to whom it properly belongs." -- Thomas Jefferson
>
> "Government big enough to supply everything...is big enough to take
> everything you have. The course of history shows that as a
> government grows, liberty decreases" --- Thomas Jefferson
>
> www.CampaignForLiberty.org