Well I have seen that in this way is better to avoid misleading users and setting incorrect urls.
Thanks anyway. 2014-10-30 11:18 GMT+01:00 Romain Manni-Bucau <[email protected]>: > Why not @GET Customer identity() { return this; } ? > Romain Manni-Bucau > Twitter: @rmannibucau > Blog: http://rmannibucau.wordpress.com/ > LinkedIn: http://fr.linkedin.com/in/rmannibucau > Github: https://github.com/rmannibucau > > > > 2014-10-30 8:52 GMT+01:00 Alex Soto <[email protected]>: > > Ok then subresources are not as magical as I thought. I mean I would like > > to be able to do something like. /customer/12 and return whole customer, > > but for example using /customer/12/address and returns the address only. > > But the key point here is that I would be able to use the same > ShoppingCard > > endpoint. But if I cannot add a @GET on shoppingcart, then this won't > work. > > > > Ok thanks for the clarification. > > > > 2014-10-29 16:38 GMT+01:00 Romain Manni-Bucau <[email protected] > >: > > > >> you have @GET on shoppingcart so Customer is not a sub resource > >> > >> Side note: some help can be accessed using logs at fine level of > >> org.apache.cxf.jaxrs.utils.JAXRSUtils logger > >> Romain Manni-Bucau > >> Twitter: @rmannibucau > >> Blog: http://rmannibucau.wordpress.com/ > >> LinkedIn: http://fr.linkedin.com/in/rmannibucau > >> Github: https://github.com/rmannibucau > >> > >> > >> > >> 2014-10-29 16:23 GMT+01:00 Alex Soto <[email protected]>: > >> > https://github.com/maggandalf/jaxrssubresource > >> > > >> > 2014-10-29 16:15 GMT+01:00 Alex Soto <[email protected]>: > >> > > >> >> Yes it is there only in one of my test trying to see if setting a > known > >> >> content type make things better, > >> >> > >> >> 2014-10-29 16:11 GMT+01:00 Romain Manni-Bucau < > >> [email protected]>: > >> >> > >> >>> why @XmlRootElement? IMHO Customer shouldn't be a jaxb object > >> >>> > >> >>> if you manage to share a project @github we could dig into it > >> >>> Romain Manni-Bucau > >> >>> Twitter: @rmannibucau > >> >>> Blog: http://rmannibucau.wordpress.com/ > >> >>> LinkedIn: http://fr.linkedin.com/in/rmannibucau > >> >>> Github: https://github.com/rmannibucau > >> >>> > >> >>> > >> >>> > >> >>> 2014-10-29 16:06 GMT+01:00 Alex Soto <[email protected]>: > >> >>> > Hi again I am trying really simple example and it don't work. I am > >> not > >> >>> sure > >> >>> > if it is because of something related in cxf or something that I > am > >> >>> doing > >> >>> > wrong (but currently I am copying the example from oracle > >> >>> documentation). > >> >>> > Let me paste the classes: > >> >>> > > >> >>> > @Path("/") > >> >>> > public class ShoppingCart { > >> >>> > > >> >>> > @Path("/customers/{id}") > >> >>> > @GET > >> >>> > @Produces(MediaType.APPLICATION_XML) > >> >>> > public Customer get(@PathParam("id") String id) { > >> >>> > Customer customer = new Customer(); > >> >>> > customer.setAddress("a"); > >> >>> > customer.setId(id); > >> >>> > return customer; > >> >>> > } > >> >>> > } > >> >>> > > >> >>> > and > >> >>> > > >> >>> > @XmlRootElement > >> >>> > public class Customer { > >> >>> > > >> >>> > private String id; > >> >>> > private String address; > >> >>> > public String getId() { > >> >>> > return id; > >> >>> > } > >> >>> > @Path("/address") > >> >>> > @Produces(MediaType.TEXT_PLAIN) > >> >>> > public String getAddress() { > >> >>> > return address; > >> >>> > } > >> >>> > public void setId(String id) { > >> >>> > this.id = id; > >> >>> > } > >> >>> > public void setAddress(String address) { > >> >>> > this.address = address; > >> >>> > } > >> >>> > } > >> >>> > > >> >>> > If I navigate to /customers/12/address it didn't work, an > exception > >> is > >> >>> > thrown that endpoint is not found: > >> >>> > > >> >>> > WARNING: No operation matching request path > >> >>> > "/javaeemv3/customers/1/address" is found, Relative Path: > >> >>> > /customers/1/address, HTTP Method: GET, ContentType: */*, Accept: > >> >>> > > >> >>> > >> > text/html,application/xhtml+xml,image/webp,application/xml;q=0.9,*/*;q=0.8,. > >> >>> > Please enable FINE/TRACE log level for more details. > >> >>> > Oct 29, 2014 4:00:11 PM > >> >>> > org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper toResponse > >> >>> > WARNING: javax.ws.rs.WebApplicationException > >> >>> > at > >> >>> > > >> >>> > >> > org.apache.cxf.jaxrs.utils.JAXRSUtils.findTargetMethod(JAXRSUtils.java:415) > >> >>> > > >> >>> > Don't know exactly if I am doing something wrong (but at least it > >> seems > >> >>> > that reading the specification it should work. > >> >>> > > >> >>> > Alex. > >> >>> > > >> >>> > 2014-10-29 15:08 GMT+01:00 Alex Soto <[email protected]>: > >> >>> > > >> >>> >> Ok so providing an Applicatiom makes that scanning process do not > >> scan > >> >>> >> resources and subresources. Cool. Thanks. > >> >>> >> > >> >>> >> 2014-10-29 15:04 GMT+01:00 Romain Manni-Bucau < > >> >>> [email protected]>: > >> >>> >> > >> >>> >>> normally you don't let sub resources to be deployed providing an > >> >>> >>> Application. > >> >>> >>> Romain Manni-Bucau > >> >>> >>> Twitter: @rmannibucau > >> >>> >>> Blog: http://rmannibucau.wordpress.com/ > >> >>> >>> LinkedIn: http://fr.linkedin.com/in/rmannibucau > >> >>> >>> Github: https://github.com/rmannibucau > >> >>> >>> > >> >>> >>> > >> >>> >>> > >> >>> >>> 2014-10-29 15:00 GMT+01:00 Alex Soto <[email protected]>: > >> >>> >>> > so how can I create a real subresource then? Ok just using > @Path > >> >>> without > >> >>> >>> > Http method, but then how to differentiate if subresource > should > >> be > >> >>> for > >> >>> >>> a > >> >>> >>> > post or for a get? > >> >>> >>> > > >> >>> >>> > 2014-10-29 14:22 GMT+01:00 Romain Manni-Bucau < > >> >>> >>> [email protected]>: > >> >>> >>> > > >> >>> >>> >> Hi > >> >>> >>> >> > >> >>> >>> >> yes but no :p > >> >>> >>> >> > >> >>> >>> >> in details: we deploy classes with only method @Path (no > class > >> >>> @path) > >> >>> >>> >> as endpoint by default (ie you use scanning) cause users do > it > >> >>> (comes > >> >>> >>> >> from spring I think). > >> >>> >>> >> Romain Manni-Bucau > >> >>> >>> >> Twitter: @rmannibucau > >> >>> >>> >> Blog: http://rmannibucau.wordpress.com/ > >> >>> >>> >> LinkedIn: http://fr.linkedin.com/in/rmannibucau > >> >>> >>> >> Github: https://github.com/rmannibucau > >> >>> >>> >> > >> >>> >>> >> > >> >>> >>> >> > >> >>> >>> >> 2014-10-29 14:09 GMT+01:00 Alex Soto <[email protected]>: > >> >>> >>> >> > Hi guys, > >> >>> >>> >> > Currently I am developing some jax-rs endpoints with Apache > >> TomEE > >> >>> >>> 1.7.1. > >> >>> >>> >> I > >> >>> >>> >> > am trying to develop some subresources, but there is > something > >> >>> that > >> >>> >>> >> > confuses me: > >> >>> >>> >> > > >> >>> >>> >> > Reading some documentation in summary says that your > >> subresource > >> >>> >>> should > >> >>> >>> >> not > >> >>> >>> >> > be annotated with @Path annotation and they gives you next > >> >>> example: > >> >>> >>> >> > > >> >>> >>> >> > // Subresource class > >> >>> >>> >> > public class Employee { > >> >>> >>> >> > > >> >>> >>> >> > // Subresource method: returns the employee's last name > >> >>> >>> >> > @GET > >> >>> >>> >> > @Path("/lastname") > >> >>> >>> >> > public String getEmployeeLastName() { > >> >>> >>> >> > ... > >> >>> >>> >> > return lastName > >> >>> >>> >> > } > >> >>> >>> >> > } > >> >>> >>> >> > > >> >>> >>> >> > In theory it should be a subresource, but when I deploy > this > >> in > >> >>> >>> TomEE I > >> >>> >>> >> can > >> >>> >>> >> > access to this subresource directly from path provided in > each > >> >>> >>> method (in > >> >>> >>> >> > previous case localhost:8080/app/lastname), but my > question is > >> >>> that > >> >>> >>> if it > >> >>> >>> >> > is a subresource, it should not be accessed directly from > >> >>> browser but > >> >>> >>> >> from > >> >>> >>> >> > another resource right? So for example it should be valid > >> >>> accessing > >> >>> >>> from > >> >>> >>> >> > localhost:8080/app/employee/lastname > >> >>> >>> >> > > >> >>> >>> >> > You can see the example here > >> >>> >>> >> > http://docs.oracle.com/javaee/6/tutorial/doc/gknav.html > >> >>> >>> >> > > >> >>> >>> >> > Alex. > >> >>> >>> >> > > >> >>> >>> >> > > >> >>> >>> >> > > >> >>> >>> >> > -- > >> >>> >>> >> > > +----------------------------------------------------------+ > >> >>> >>> >> > Alex Soto Bueno > >> >>> >>> >> > www.lordofthejars.com > >> >>> >>> >> > > +----------------------------------------------------------+ > >> >>> >>> >> > >> >>> >>> > > >> >>> >>> > > >> >>> >>> > > >> >>> >>> > -- > >> >>> >>> > +----------------------------------------------------------+ > >> >>> >>> > Alex Soto Bueno - Computer Engineer > >> >>> >>> > www.lordofthejars.com > >> >>> >>> > +----------------------------------------------------------+ > >> >>> >>> > >> >>> >> > >> >>> >> > >> >>> >> > >> >>> >> -- > >> >>> >> +----------------------------------------------------------+ > >> >>> >> Alex Soto Bueno - Computer Engineer > >> >>> >> www.lordofthejars.com > >> >>> >> +----------------------------------------------------------+ > >> >>> >> > >> >>> > > >> >>> > > >> >>> > > >> >>> > -- > >> >>> > +----------------------------------------------------------+ > >> >>> > Alex Soto Bueno - Computer Engineer > >> >>> > www.lordofthejars.com > >> >>> > +----------------------------------------------------------+ > >> >>> > >> >> > >> >> > >> >> > >> >> -- > >> >> +----------------------------------------------------------+ > >> >> Alex Soto Bueno - Computer Engineer > >> >> www.lordofthejars.com > >> >> +----------------------------------------------------------+ > >> >> > >> > > >> > > >> > > >> > -- > >> > +----------------------------------------------------------+ > >> > Alex Soto Bueno - Computer Engineer > >> > www.lordofthejars.com > >> > +----------------------------------------------------------+ > >> > > > > > > > > -- > > +----------------------------------------------------------+ > > Alex Soto Bueno - Computer Engineer > > www.lordofthejars.com > > +----------------------------------------------------------+ > -- +----------------------------------------------------------+ Alex Soto Bueno - Computer Engineer www.lordofthejars.com +----------------------------------------------------------+
