Hi Ryan On Fri, May 13, 2011 at 2:25 AM, Ryan Zoerner <ryanzoer...@gmail.com> wrote: > Sergey, > > I have the following question regarding the project. > > --------------------------------------------------------------------- > --------------------------------------------------------------------- > Customer: > --------------------------------------------------------------------- > Per-request resource: Does Customer store Customers? > By what mechanism does Customer return Customers? > Constructor (overloaded)? > FactoryMethod? > Constructor w/necessary calls to setName and setID? > > What methods should I expose?: > Overloaded or non-overloaded constructor? > Manipulate name and id, or do not manipulate name and id? (Get and Set) > Should I keep a list of Customers, perhaps in class > CustomerStorage? > Do you want a CustomerFactory and a Customer object? > ---------------------------------------------------------------------
Let CustomerService manage individual Customer instances, for the 2nd endpoint lets have a Customer root resource with the hardcoded state (name, whatever) which is created on every request. This Customer root resource needs to return its own state. Suppose a client uses this URI to get this state: http://localhost:8080/customers/customer/state, Customer root resource needs to handle this request in two steps: - use subresource locator to return the subresource instance which will handle the request and - have a resource method with @GET annotation which will basically return "this" and this has to work because Customer happens to have @XmlRootElement annotation. > --------------------------------------------------------------------- > CustomerService: > > Does it store the customers or does Customer store the > customers, (or both)? Does anything store the customers? > > Does customerService call Customer to retrieve Customers > from storage? > > Does it call Customer to generate Customers fresh each time? > > Does it store Customers that it retrieves? > > For how long does it store the complete list of Customers > that it retrieves. > > Is there anything such as a 'request-set' of Customers, > s.t. (such that), you can display a list of Customers > retrieved in one request session? > There are all good questions one needs to address when building a CustomerService but this is not what you are after after all, what you are trying to do is get up to speed with JAX-RS mechanics asap. Have some primitive CustomerService implementation but make sure you see how various methods are invoked and how request parameters and response objects are handled, etc, and whatever else we agreed re the 1st endpoint > By what means does CustomerService instantiate xml? > > Does it instantiate the xml? > CustomerService does not deal with it directly, it could, but not in this case. CXF JAX-RS MessageBodyReader and MessageBodyWriter supporting the JAXB databindiing will do it. > With JAX-WS, there is WSDL and WS-import. If I create a > Customer Interface; if I store it on the Customer Endpoint > by what mechanism can I obtain a method-stub representation > of the class, on this Endpoint, s.t. I can instantiate the > class and use getters and setters? > > --------------------------------------------------------------------- Your custom per-request provider only needs to create a new instance when requested. > --------------------------------------------------------------------- > > Because I thought that Customer must store Customers, > what I created was: > > +customerService.customer.classes+ > -CustomerFactoryImpl.java > -CustomerImpl.java > -CustomerStorageImpl.java > > +customerService.customer.interfaces+ > -Customer.java { generateNewCustomerInstance() } > -CustomerFactory.java { overloaded constructor,set[...],get[...] } > -CustomerStorage.java { add, get, update, delete } > > +customerService.jaxrs.client > -Client.java { sends commands to endpoints and receives responses } > > +customerService.jaxrs.client.xmlResources > -add_customer.xml > -customer_list.xml { list of Customers } > -update_customer.xml > > +customerService.jaxrs.customerGenerationAndStorage > -CustomerService.java { uses add, get, update, and delete to manage > CustomerStorage.java } > -Server.java { consumes messages and produces responses } > > +customerService.jaxrs.customersListingService > -CustomersService.java { makes calls to CustomerService, to instantiate > or retrieve Customer instances, in the form of > xml. I was envisioning being able to instantiate > a CustomerFactory from within this code, and in > such a way that it can be treated as though it > were contained in code that is in another package > > in my workspace, in eclipse, with this package. > > Somehow to create code s.t., > CustomerFactory c = new ... > /** > * I want this to return a new instantiated > * Customer that has come in from the other > * service, by means of an xml transmission. > * > * Presumably, you could import the FactoryImpl > and > * extend it by adding some helper class to the > * constructor which would transform an xml > * representation to an Object representation. > * Presumably, that class would be a part of cxf. > > * > * I would like, also, for the environment to be > * able to locate the URI of the resource as > though > * it were simply another package in a packaged > * web archive. This, because you want the > * FactoryImpl to not implement any web methods > * what-so-ever. I guess, ideally, you would say > * > * @InjectWebMethod("/URI-of-method") > * private CustomerFactory c; > * > * and this would be instantiated in the > constructor, > * but declared from within class-scope. And the > * annotation. Wait, this is better: the > annotation > * would take care of locating the method, > * web communication, receiving the xml and auto- > * converting it to the Object, and this, by > linking > * the Factory to other code which automatically > * processes the stuff differently by means of > the > * compiler, or the virtual machine. > * > * Did I just describe JAXB and JAX-WS? I may > have, > * but I don't really know. However, what I have > * just described sounds, to me, like the most > * sensible thing because you can treat code on > * a distant machine, just as though it is on > your > * machine, in coding with it. > * > * Is it currently possible to obtain from > * customerService.java the full representation > * of the class? Or just the method stubs? > * > * Is it currently possible to obtain the full > * representation from wsimport? Or through some > * other means? Or does the implementation > * traditionally remain secure within the > * webservice, in jax-ws? > */ > c.getNewCustomerInstance( [name], [id] ); > -Server.java { consumes messages and produces responses } Please make things simpler, follow the basic/jax-rs demo and focus on the JAX-RS mechanics. Use JAXRSServerFactorybean to create both endpoints, or jaxrs:server Spring declarations if you prefer Thanks, Sergey > > Thanks, > Ryan > -- Sergey Beryozkin Application Integration Division of Talend http://sberyozkin.blogspot.com