users@jersey.java.net

Re: [Jersey] _at_PathParam("id") Serializable login ??

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Fri, 14 Aug 2009 21:01:45 +0200

Hi,

See here for the standard rules:

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

To add your own types use StringReaderProvider:

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

For example:

   @Provider
   public SerializableStringProvider implements
StringReaderProvider<Serializable> {
     public StringReader<T> getStringReader(Class<?> type, Type
genericType, Annotation[] annotations) {
       if (type != Serializable.class) return null;

       return new StringReader<Serializable>() {
         public Serializable fromString(String value) {
           ...
         }
       }
     }
   }

Paul.

On Aug 14, 2009, at 7:40 PM, Felipe Gaúcho wrote:

> I tried to use Serializable as PathParam type, but the Glassfish
> thrown:
>
> com.sun.jersey.api.container.ContainerException: Method, public
> com.kenai.puj.arena.model.entity.VersionedEntity
> net
> .java
> .dev
> .footprint
> .service.http.PujGenericResource.select(java.io.Serializable),
> annotated with GET of resource, class
> net.java.dev.footprint.service.http.PujGenericResource, is not
> recognized as valid Java method annotated with @HttpMethod.
>
>
> @GET
> @Produces( { MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
> @Path("{id}")
> public T select(@PathParam("id") Serializable login) {
> return getFacade().read(login);
> }
>
>
> * if I change it to integer or String, it works normally...... but
> since Serializable is the JPA interface I was looking for using that
> type :)
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>