users@jersey.java.net

[Jersey] Holder Objects

From: Meeraj Kunnumpurath <mkunnumpurath_at_googlemail.com>
Date: Tue, 13 Mar 2012 11:52:04 +0000

Hi,

Does Jersey support holder objects, which can be used as out parameters.
What I am trying to achieve is something along the lines ...

public class Holder<T> {
    private T held;
    public T getHeld(T held) { return held; }
    public void setHeld(T held) { this.held = held; }
}

@XmlRootElement
public class MyRequest {
}

@XmlRootElement
public class MyResponse {
}

@Resource
public class MyResource {

    @POST
    public void myMethod(MyRequest myRequest, Holder<MyResponse> holder) {
        holder.setHeld(new MyResponse());
    }

}

If there is no holder API out of the box, is there an SPI I can use to
plugin this behavior?

Kind regards
Meeraj