vendredi 12 juin 2015

How to specify concrete type for abstract method param in Jersey

I am using Jersey and have exposed a resource Resource which implements an Interface. One of the methods from Interface has a parameter a of type A which is an abstract class. In Resource I want to make Jersey/Jackson aware that it can use the concrete implementation of A which is AImpl. How can I do that? Here is some code for explanation:

//Interface.java
public interface Interface {
    public void setA(A a);
}
//Resource.java
@Path("/hello")
public class Resource implements Interface {
    @POST
    public void setA(A a){ //Here I want to specify AImpl instead of A
        //Code that uses AImpl
    }
}
//A.java
public abstract class A{
    //Some abstract stuff
}
//AImpl.java
public class AImpl extends A{
    //Some concrete stuff
}

Aucun commentaire:

Enregistrer un commentaire