cxf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sergey Beryozkin <sberyoz...@gmail.com>
Subject Re: Questions regarding the implementation of a 2-endpoint Customer and CustomerService CXF JAX-RS web application
Date Fri, 13 May 2011 10:28:04 GMT
Hi

On Fri, May 13, 2011 at 10:54 AM, Ryan Zoerner <ryanzoerner@gmail.com> wrote:
> Hi Sergey,
>
> You mentioned that Customer should display a single customer. Does
> CustomerService instantiate that Customer?

I'm presuming we are talking about the 2nd endpoint ?
No, as I said in the previous email, it is the custom resource
provider which will do it.

>By what mechanism? I created this
> class to try and get around that problem. In the old demo, Customers were
> instantiated in CustomerService, however, if you have CustomerService being
> called by Customer to get its Customer to display, does that make sense to
> you?

I agree it does not. Customer root resource will be instantiated by
your custom resource provider
and will return its own hardcoded state...

> The server would call getCustomer and the createCustomer method would
> act like init() on an individual call basis.
>
> I may have questions about your response that I just read, but I am too
> tired right now to develop them.

Please take a break :-). Check the CXF JAX-RS docs about subresources
too, it's very simple, you'll do it in few mins after you get a break.
I guess I could've just typed the code right here but it's about you
managing this GSOC project and you've progressed a lot so I'll just
let you do it :-). If you prefer you could start focusing on EJB
integration right now, but I think that without feeling how JAX-RS
works you'll just find it difficult to get the integration working
>  ----------------------------------------------------------------
> public Customer()
>  {
>    @Path("/name/none/id/none/")
>    public Customer getCustomer()
>
>    @Path("/name/{name: [a-zA-Z]+}/id/none}")
>    public Customer getCustomer(@PathParam("name") String name)
>
>    @Path("/name/none/id/{id: [0-9]+)")
>    public Customer getCustomer(@PathParam("id") long id)
>
>    @Path("/name/{name: [a-zA-Z]+}/id/{id: [0-9]+)")
>    public Customer getCustomer(@PathParam("name") String name,
>        @PathParam("id") long id)
>
>    @GET
>    private Customer createCustomer()
>
>    @GET
>    private Customer createCustomer(String name)
>
>    @GET
>    private Customer createCustomer(long id)
>
>    @GET
>    private Customer createCustomer(String name, long id)
> }
>  -----------------------------------------------------------------------------------------------------------
>
A hint:

Just have two methods: one is subresource locator, another one is the
final resource method which will return the state. Subresurce locator
effectively delegates to the final resource method. You'll be
surprised how easy it is but I do appreciate it can be tricky without
having a prior experience

Same for CustomeService: have some basic map/list of Customers, few
resource methods, etc. It's not about writing a quality
CustomerService - it's about you moving to the next stage with the
full confidence

Thanks, Sergey

> Thank you,
> Ryan
>



-- 
Sergey Beryozkin

Application Integration Division of Talend
http://sberyozkin.blogspot.com

Mime
View raw message