Hi Jonathan,
Is the class of the object that is returned from the
ManagedComponentProvider a proxy that overrides the methods in the
original class but does not retain the method parameter annotations in
the overridden methods?
The warnings you are observing are consistent with Jersey not seeing
any @PathParam annotation i.e. it is equivalent to:
@Path("users/{username}")
public class MyResource {
@GET
@Produces(TEXT_PLAIN)
public String hello(String userName) {
return "Salut " + userName + " !";
}
}
Or say:
@Path("users/{username}")
public class MyResource {
@GET
@Produces(TEXT_PLAIN)
public String hello(@PathParam("username") String userName) {
return "Salut " + userName + " !";
}
}
@Path("users/{username}")
public ProxyOfMyResource extends MyResource {
@GET
@Produces(TEXT_PLAIN)
public String hello(String userName) {
super.hello(userName);
}
}
Paul.
On Oct 6, 2010, at 4:21 PM, jonathan wrote:
> Hi,
>
> I am working on a small project which aims to get OSGi services
> exposed as REST resources thanks to jersey. The publication of
> services as resources works fine, but I have some problems with
> bindings the value of the URI to methods parameters. For example,
> with the following resource:
>
> ====
> @Path("users/{username}")
> public class MyResource {
>
> @GET
> @Produces(TEXT_PLAIN)
> public String hello(@PathParam("username") String userName) {
> return "Salut " + userName + " !";
> }
> }
> ====
>
> Jersey failed to bind the @PathParam, I got the following warning:
>
> WARNING: The following warnings have been detected with resource
> and/or provider classes:
> WARNING: A HTTP GET method, public java.lang.String
> org.ow2.chameleon.test.rest.MyRessource.hello(java.lang.String),
> should not consume any entity.
>
> and if I try to access /users/toto, the userName is empty:
>
> ====
> Salut !
> ====
>
> Since the instance of the resource is retrieve from the OSGi service
> broker, I have a simple IoCManagedComponentProvider which looks like
> that:
>
> ====
> public class ManagedComponentProvider implements
> IoCManagedComponentProvider {
> private final Object instance;
>
> public ManagedComponentProvider(Object pInstance) {
> instance = pInstance;
> }
>
> /**
> * Since the instance is an OSGi service, this is a singleton
> pattern !
> */
> public ComponentScope getScope() {
> return Singleton;
> }
>
> public Object getInjectableInstance(Object o) {
> //TODO Injectable ?
> return o;
> }
>
> public Object getInstance() {
> return instance;
> }
> }
> ====
>
> Have you any idea why I get this warning ?
>
> Thanks,
>
> Jonathan