J1RestSupportUseCaseDocument

REST Support Use Cases

The following use cases are applicable to any Web Service enable project types. For !JavaOne demo, we scope these use cases to Web project type only.

UC1: Generate entity resources from database

In a web project, user already created a set of entity classes from a set of tables from a data source. Now user wants to create a resource for each entity. User also might want to have a container resource for each entity resource. The resources are to be used directly in a database front-end web application, or to be composed into large-grained web service.

Following is the flow:

  1. User invokes the New 'Persistence Entity REST Service' wizard by right click on project node or source node or package nodes.
  2. On the first screen user can specify source project, source package, and destination package of generated REST service classes.  By default the destination package path would be derived from source package plus "rest".
  3. The table show rows of entity classes to generate REST beans.  The table has columns with check box for control whether to generate resource methods:  'Create', 'Retrieve', 'Update', 'Delete'.  There is also a column for create 'Container' resource class.  By default, all check boxes are selected.
  4. User could select only generate all read-only resources.
   <img src="%ATTACHURLPATH%/restwizard-panel2a.jpg"/>
  • After the wizard 'Finish' button is click, each selected entities would be have a JAXB class and a REST bean class with selected operation methods. The JAXB class is just the Entity class with proper JAXB annotations.
  • If 'Container' is selected, a container entity class and container resource bean are also generated. This container resource will have GET method returns a <verbatim>JAXBRepresentation</verbatim> with list of elements with the URI contained resource as text value.
  • For details see default entity-jaxb-resource mapping.

UC2: Generate container resources

In a web project, user have a REST bean and would like to create a container resource with specific semantic, for example some specific listing or some result of some query. A container resource would return <verbatim>JAXBRepresentation</verbatim> with URI of each contained resource.

Here is the flow to achieve this:

  1. User invokes the New Resource Container REST Service wizard by right click on project node or source node or package nodes.
  2. The first screen named 'Resource Container' show table of REST classes to generate container for.  The second column show resource URI.  The third column user can specify container resource URI.  The last column user can specify container class name.
   <img src="%ATTACHURLPATH%/restwizard-panel2b.jpg"/>

After the wizard 'Finish' button is clicked, a container JAXB class will be generated for XML content that list resource URL of the contained resources. User can implement the get method on the JAXB class to populate the container according to business rule.

UC3: Test REST service

In a web project, user want to test a resource. User right click on REST service node in the project view and do context menu action 'Run Test'. The REST test facility will generate a generic web page in the unit test build area and show it a browsing facility (maybe IDE internal).

There are 2 possible ways to generate the test client.

1. Directly from the wadl. 2. Generating a wadl and using it to generate the test client.

See mockup below.

   <img src="%ATTACHURLPATH%/restClient2.PNG"/>

Questions:

  • What is the granularity of test invocation? On a single REst service node or for the whole web project? The mockup signifies for the whole project. I was thinking it to be more on a per-service node.
  • What is a service node? Is it just one Rest bean impl java file? Is it true that the /orders/{customer-id}" and "/customer/{id}/orders" will infact be two different java classes or will they be part of the same java class?
  • What does it mean to have 4 GETS on a resource? or these for the various content type returned?
  • If the content type is XML, is there a ref to the schema so a sample instance of the content snippet can be pre-generated for testing? Does WADL have that info?
  • How did u derive fred/barney sample data? is that pulled from WADL? Basically is there a way for WADL to have the defaulted sample data that the test client can use?
  • Can we look at how to capture a simple CRUD op and store that as a unit test which can be invoked from the IDE itself bypassing HTTP?? more like a jnuit test or so? Benefit of this would be to capture regressions quickly on the business logic itself in some automated fashion.

-- Main.NamNguyen - 10 Mar 2007

==================================================================

UC4: Partner Service Registration

See Support registration of partner services in the REST component palette

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo