@John: GenericEntity is not abstract ;)

Personally I use the public constructor to avoid to need to extend it in
several places and ensure the dyncamic type is the one I expect whatever
impl I use but it needs a Type implementation matching a generic type:

https://github.com/rmannibucau/rblog/blob/f23ec03261b5a6f42de50a9f3f7f083bcf85fc33/src/main/java/com/github/rmannibucau/rblog/jaxrs/reflect/CollectionType.java
(side note: johnzon provide one implementatio as well which is built in in
tomee) is a generic on then you can define the type you need as a constant (
https://github.com/rmannibucau/rblog/blob/f23ec03261b5a6f42de50a9f3f7f083bcf85fc33/src/main/java/com/github/rmannibucau/rblog/jaxrs/CategoryResource.java#L39)
and finally use the GenericType directly (
https://github.com/rmannibucau/rblog/blob/f23ec03261b5a6f42de50a9f3f7f083bcf85fc33/src/main/java/com/github/rmannibucau/rblog/jaxrs/CategoryResource.java#L55)
client or server side without extending it.



Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<https://blog-rmannibucau.rhcloud.com> | Old Wordpress Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com> | JavaEE Factory
<https://javaeefactory-rmannibucau.rhcloud.com>

2016-08-02 9:18 GMT+02:00 Andy Gumbrecht <[email protected]>:

> Off the top of my head, something like:
>
> @Path("apath")
> @GET
> @Produces(MediaType.APPLICATION_JSON)
> public List<Workshop> getWorkshops() {...return a list...}
>
> ...client side WebTarget...
>
> List<Workshop> workshops =
> webTarget.request(MediaType.APPLICATION_JSON).get().readEntity(new
> GenericType<List<Workshop>>() {});
>
> Andy.
>
>
>
> On 2 August 2016 at 07:27, mauro2java2011 <[email protected]>
> wrote:
>
> > Esvuse but for instantiation the operator is new () not {}
> > Il 02/ago/2016 02:11, "John D. Ament-2 [via TomEE & OpenEJB]" <
> > [email protected]> ha scritto:
> >
> > > GenericEntity is an abstract class.  You're instantiating an anonymous
> > > instance of it.
> > >
> > > On Mon, Aug 1, 2016 at 8:06 PM mauro2java2011 <[hidden email]
> > > <http:///user/SendEmail.jtp?type=node&node=4679567&i=0>>
> > > wrote:
> > >
> > > > I try to understand how return a collection of object as response
> with
> > > rest
> > > >
> > > >
> > > >
> > > >
> > > > import javax.ws.rs.core.GenericEntity;
> > > > //...
> > > >   @GET
> > > >     public Response workshops() {
> > > >         List<Workshop> workshops = ...//a list of entities
> > > >         GenericEntity<List&lt;Workshop>> l
> > > >         ist = new GenericEntity<List&lt;Workshop>>(workshops) *{}*;
> > > >         return Response.ok(list).build();
> > > >     }
> > > >
> > > >
> > > >
> > > > --
> > > > View this message in context:
> > > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/signify-of-when-i-create-a-rest-Response-with-a-List-tp4679566.html
> > > > Sent from the TomEE Users mailing list archive at Nabble.com.
> > > >
> > >
> > >
> > > ------------------------------
> > > If you reply to this email, your message will be added to the
> discussion
> > > below:
> > >
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/signify-of-when-i-create-a-rest-Response-with-a-List-tp4679566p4679567.html
> > > To unsubscribe from signify of {} when i create a rest Response with a
> > > List, click here
> > > <
> >
> http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4679566&code=bWF1cm8yamF2YTIwMTFAZ21haWwuY29tfDQ2Nzk1NjZ8LTExMTcxODc2MjU=
> > >
> > > .
> > > NAML
> > > <
> >
> http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
> > >
> > >
> >
> >
> >
> >
> > --
> > View this message in context:
> >
> http://tomee-openejb.979440.n4.nabble.com/signify-of-when-i-create-a-rest-Response-with-a-List-tp4679566p4679568.html
> > Sent from the TomEE Users mailing list archive at Nabble.com.
> >
>
>
>
> --
>   Andy Gumbrecht
>   https://twitter.com/AndyGeeDe
>   http://www.tomitribe.com
>

Reply via email to