users@jersey.java.net

Re: [Jersey] Re: resources inheritance

From: Martin Probst <mail_at_martin-probst.com>
Date: Wed, 12 Aug 2009 00:15:23 +0200

I think the issue with generic collections is that at runtime, the
type information is lost - that is, in Java you cannot find out if
something is an instance of Collection<String> or Collection<Integer>.
To fix the issue, you need to use a GenericEntity.

Also, why on earth do you use Vector? :-)

Martin

2009/8/11 Felipe Gaścho <fgaucho_at_gmail.com>:
> got it !!!
>
> using Arrays, everything works....... very nice.............
>
> 2009/8/11 Felipe Gaścho <fgaucho_at_gmail.com>:
>> wow, it worked :)... but:
>>
>> for generic collections I got a problem:
>>
>> A message body writer for Java type, class java.util.Vector, and MIME
>> media type, application/xml, was not found
>>
>> the code:
>>
>> public abstract class PujGenericResource<T extends AbstractArenaEntity> {
>>        @GET
>>        @Produces( { MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
>>        @Path("/{offset}/{limit}")
>>        public Collection<T> selectAll(@PathParam("offset") int offset,
>>                        @PathParam("limit") int limit) {
>>                return getFacade().readAll(offset, limit);
>>        }
>>
>>
>> perhaps converting that for arrays..
>>
>> 2009/8/11 Felipe Gaścho <fgaucho_at_gmail.com>:
>>> I guess I asked this before, but: may I create:
>>>
>>> public abstract class PujGenericResource<T extends AbstractArenaEntity> {
>>>        protected abstract PujEntityFacade<T> getFacade();
>>>
>>>        @PUT
>>>        @Consumes( { MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
>>>        @Produces( { MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
>>>        public T insert(T entity) {
>>>                return getFacade().create(entity);
>>>        }
>>>
>>> and then create a concrete subclass .. and it will work with jersey ?
>>>
>>> --
>>> Looking for a client application for this service:
>>> http://fgaucho.dyndns.org:8080/footprint-service/wadl
>>>
>>
>>
>>
>> --
>> Looking for a client application for this service:
>> http://fgaucho.dyndns.org:8080/footprint-service/wadl
>>
>
>
>
> --
> Looking for a client application for this service:
> http://fgaucho.dyndns.org:8080/footprint-service/wadl
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
>