Hi Simon thanks for the confirmation. I did have some exposure to EMF awhile back, it took me awhile to understand how advanced and sophisticated that technogy was, but one thing I did remember was that it was using proxies a lot :-) Exposing EMF models over plain HTTP is an interesting and promising idea
Cheers, Sergey On Wed, Apr 13, 2011 at 5:15 PM, Simon Chen <[email protected]> wrote: > It's finally working, all thanks to Sergey :-) > > Basically, the problem comes from the proxification of EMF, which > prevents CXF from finding the fields to play with. Sergey's solution, > which works nicely on my project, is as follows: > 1) define an interface: > public interface IContext { > @Context > public void setUriInfo(UriInfo ui); > } > > 2) let the base resource class implement this interface, for me I have: > > class WebStore implements IContext { > protected UriInfo uriInfo; > public void setUriInfo(UriInfo ui) { > this.uriInfo = ui; > } > } > > 3) Enjoy! > > Thanks. > -Simon > > > On Tue, Apr 12, 2011 at 4:58 PM, Sergey Beryozkin <[email protected]> > wrote: > > Hi Simon > > > > On Tue, Apr 12, 2011 at 9:01 PM, Simon Chen <[email protected]> > wrote: > >> > >> Hi Sergey, > >> > >> I tried adding "@context UriInfo uriInfo;" into my class definition, > >> however, when I try to get uri information from the uriInfo object, I > >> always get a NullPointerException. Do I need to initialize the uriInfo > >> in any way? > >> > > > > Is it the root resource that you add the Context fields to ? Do you mean > the > > context field is simply not initialized and this causes NPE ? How do you > > register this resource. do you have Spring AOP involved ? > > > > Cheers. Sergey > > > >> > >> I don't think this example here did anything special: > >> > http://download.oracle.com/docs/cd/E19776-01/820-4867/6nga7f5og/index.html > >> > >> Just to give some context, I am trying to embed some URI information > >> into the XML serialization. I am doing @XmlIDREF and @XmlElement > >> markup for any non-containment references. I thought that in addition > >> to print out a name (marked by @XmlID), it might be useful to give the > >> associated URI as well. > >> > >> Thanks. > >> -Simon > >> > >> On Mon, Apr 11, 2011 at 5:08 PM, Sergey Beryozkin <[email protected] > > > >> wrote: > >> > Hi > >> > > >> > On Mon, Apr 11, 2011 at 9:27 PM, Simon Chen <[email protected]> > >> > wrote: > >> >> > >> >> Hi all, > >> >> > >> >> I'm wondering if there is a way for an object in the web service to > >> >> somehow self-report where it is, in term of uri path? > >> >> > >> >> For example, we have: > >> >> > >> >> @path("/webstore/") > >> >> class WebStore { > >> >> @path("/customers/") > >> >> List<Customer> customers; > >> >> } > >> >> > >> >> Given a link "cl" to a Customer object, can we somehow figure out > that > >> >> it is under "/webstore/customers"? I understand that we can probably > >> >> easily hard-code this, but I want to do it more automatically... > >> >> > >> > Have JAX-RS UriInfo injected: > >> > > >> > @path("/webstore/") > >> > class WebStore { > >> > @Context > >> > private UriInfo uriInfo; > >> > } > >> > > >> > then you can do: > >> > > >> > uriInfo.getBaseUri() > >> > > >> > or > >> > > >> > UriBuilder builder = uriInfo.getBaseUriBuilder(); > >> > > >> > Cheers, Sergey > >> > > >> >> Thanks. > >> >> -SImon > >> > > >> > > >> > > >> > -- > >> > Sergey Beryozkin > >> > > >> > Application Integration Division of Talend > >> > http://sberyozkin.blogspot.com > >> > > > > > > > > > -- > > Sergey Beryozkin > > > > Application Integration Division of Talend > > http://sberyozkin.blogspot.com > > > -- Sergey Beryozkin Application Integration Division of Talend <http://www.talend.com/> http://sberyozkin.blogspot.com
