users@jersey.java.net

[Jersey] Re: Holder Objects

From: John Yeary <johnyeary_at_gmail.com>
Date: Tue, 13 Mar 2012 08:23:57 -0400

Hello Meeraj,

There are a couple of value holder objects which are used in Jersey;
GenericEntity<T> and GenericType<T>. Please see the API documents below to
see if these meet your needs.

http://jersey.java.net/nonav/apidocs/latest/jersey/javax/ws/rs/core/GenericEntity.html
http://jersey.java.net/nonav/apidocs/latest/jersey/com/sun/jersey/api/client/GenericType.html

____________________________

John Yeary
____________________________
*NetBeans Dream Team*
*President Greenville Java Users Group
Java Users Groups Community Leader
Java Enterprise Community Leader*

____________________________

<http://javaevangelist.blogspot.com/> <https://twitter.com/jyeary>
<http://www.youtube.com/johnyeary>
  <http://www.linkedin.com/in/jyeary>
<https://plus.google.com/112146428878473069965>
  <http://www.facebook.com/jyeary>
<http://feeds.feedburner.com/JavaEvangelistJohnYearysBlog>
  <http://netbeans.org/people/84414-jyeary>

"Far better it is to dare mighty things, to win glorious triumphs, even
though checkered by failure, than to take rank with those poor spirits who
neither enjoy much nor suffer much, because they live in the gray twilight
that knows not victory nor defeat."
-- Theodore Roosevelt



On Tue, Mar 13, 2012 at 7:52 AM, Meeraj Kunnumpurath <
mkunnumpurath_at_googlemail.com> wrote:

> 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
>
>