users@jersey.java.net

Re: [Jersey] Jersey's (experimental) approach to support hypermedia constraint

From: Jan Algermissen <algermissen1971_at_mac.com>
Date: Wed, 10 Feb 2010 12:34:08 +0100

Hi Paul,

On Feb 10, 2010, at 11:45 AM, Paul Sandoz wrote:

> [...]

> And one area of definite controversy is the client proxy will utilize WADL, dynamically via OPTIONS, to obtain additional meta-data e.g. to know if a name corresponds say to a query parameter or say a form parameter. As i said this is experimental :-)

I think WADL can maybe be a good tool for server side code generation but exposing WADL to the client violates the hypermedia constraint and should be discouraged. (Paraphrasing Roy) all of REST's descriptive effort should be spent in media type and link relation specifications.

Looking at

> Link: <http://localhost:9998/orders/1/refresh>;op=GET;rel=refresh
> Link: <http://localhost:9998/orders/1/review>;op=POST;rel=review


what worries me is this:

- there is no need for the op parameter because what method to use
  will just be part of the definition of 'refresh' or 'review'.
- the approach emphasizes a specific-API kind of thinking while
  in REST we should be thinking in terms of state transfer
  "op=POST;rel=review" really just means "tunnel review() through POST"
- "op=GET;rel=refresh" is not necessary because GET allways means 'refresh
  your current steady state"

I am having trouble to figure out, what the problem actually is that your
aretrying to solve? I just don't see why all this is necessary or helpful.

Jan



>
> Paul.
>
> Starting grizzly...
> Feb 10, 2010 11:01:19 AM com.sun.jersey.api.client.filter.LoggingFilter log
> INFO: 1 * Client out-bound request
> 1 > GET http://localhost:9998/orders/1
> 1 >
>
> Feb 10, 2010 11:01:19 AM com.sun.jersey.api.core.PackagesResourceConfig init
> INFO: Scanning for root resource and provider classes in the packages:
> com.sun.jersey.samples.hypermedia.server.controller
> Feb 10, 2010 11:01:19 AM com.sun.jersey.api.core.ScanningResourceConfig logClasses
> INFO: Root resource classes found:
> class com.sun.jersey.samples.hypermedia.server.controller.ProductResource
> class com.sun.jersey.samples.hypermedia.server.controller.CustomersResource
> class com.sun.jersey.samples.hypermedia.server.controller.CustomerResource
> class com.sun.jersey.samples.hypermedia.server.controller.ProductsResource
> class com.sun.jersey.samples.hypermedia.server.controller.OrdersResource
> class com.sun.jersey.samples.hypermedia.server.controller.OrderResource
> Feb 10, 2010 11:01:19 AM com.sun.jersey.api.core.ScanningResourceConfig init
> INFO: No provider classes found.
> Feb 10, 2010 11:01:19 AM com.sun.jersey.server.impl.application.WebApplicationImpl initiate
> INFO: Initiating Jersey application, version 'Jersey: 1.2-SNAPSHOT 02/09/2010 05:29 PM'
> Feb 10, 2010 11:01:20 AM com.sun.jersey.api.client.filter.LoggingFilter log
> INFO: 1 * Client in-bound response
> 1 < 200
> 1 < Link: <http://localhost:9998/orders/1/refresh>;op=GET;rel=refresh
> 1 < Link: <http://localhost:9998/orders/1/review>;op=POST;rel=review
> 1 < Link: <http://localhost:9998/orders/1/cancel>;op=POST;rel=cancel
> 1 < Link: <http://localhost:9998/orders/1/update>;op=PUT;rel=update
> 1 < Content-Length: 391
> 1 < Date: Wed, 10 Feb 2010 10:01:20 GMT
> 1 < Content-Type: application/xml
> 1 < server: grizzly/1.9.8
> 1 <
> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
> <order>
> <id>1</id>
> <customer>http://localhost:9998/customers/21</customer>
> <shippingAddress>http://localhost:9998/customers/21/address/1</shippingAddress>
> <orderItems>
> <product>http://localhost:9998/products/3345</product>
> <quantity>1</quantity>
> </orderItems>
> <status>RECEIVED</status>
> </order>
>
>
> Feb 10, 2010 11:01:20 AM com.sun.jersey.api.client.filter.LoggingFilter log
> INFO: 2 * Client out-bound request
> 2 > OPTIONS http://localhost:9998/orders/1/review
> 2 >
>
> Feb 10, 2010 11:01:20 AM com.sun.jersey.api.client.filter.LoggingFilter log
> INFO: 2 * Client in-bound response
> 2 < 200
> 2 < Content-Length: 605
> 2 < Allow: OPTIONS,POST
> 2 < Date: Wed, 10 Feb 2010 10:01:20 GMT
> 2 < Content-Type: application/vnd.sun.wadl+xml
> 2 < server: grizzly/1.9.8
> 2 <
> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
> <application xmlns="http://wadl.dev.java.net/2009/02">
> <doc xmlns:jersey="http://jersey.dev.java.net/" jersey:generatedBy="Jersey: 1.2-SNAPSHOT 02/09/2010 05:29 PM"/>
> <resources base="http://localhost:9998/">
> <resource path="orders/1/review">
> <method name="POST" id="review">
> <request>
> <param xmlns:xs="http://www.w3.org/2001/XMLSchema" type="xs:string" style="header" name="notes"/>
> </request>
> </method>
> </resource>
> </resources>
> </application>
>
>
> Feb 10, 2010 11:01:20 AM com.sun.jersey.api.client.filter.LoggingFilter log
> INFO: 3 * Client out-bound request
> 3 > POST http://localhost:9998/orders/1/review
> 3 > notes: approve
> 3 >
>
> Feb 10, 2010 11:01:20 AM com.sun.jersey.api.client.filter.LoggingFilter log
> INFO: 3 * Client in-bound response
> 3 < 204
> 3 < Link: <http://localhost:9998/orders/1/refresh>;op=GET;rel=refresh
> 3 < Link: <http://localhost:9998/orders/1/cancel>;op=POST;rel=cancel
> 3 < Link: <http://localhost:9998/orders/1/update>;op=PUT;rel=update
> 3 < Link: <http://localhost:9998/orders/1/pay>;op=POST;rel=pay
> 3 < Date: Wed, 10 Feb 2010 10:01:20 GMT
> 3 < server: grizzly/1.9.8
> 3 <
>
> Feb 10, 2010 11:01:20 AM com.sun.jersey.api.client.filter.LoggingFilter log
> INFO: 4 * Client out-bound request
> 4 > GET http://localhost:9998/orders/1/refresh
> 4 > Accept: application/xml
> 4 >
>
> Feb 10, 2010 11:01:20 AM com.sun.jersey.api.client.filter.LoggingFilter log
> INFO: 4 * Client in-bound response
> 4 < 200
> 4 < Link: <http://localhost:9998/orders/1/refresh>;op=GET;rel=refresh
> 4 < Link: <http://localhost:9998/orders/1/cancel>;op=POST;rel=cancel
> 4 < Link: <http://localhost:9998/orders/1/update>;op=PUT;rel=update
> 4 < Link: <http://localhost:9998/orders/1/pay>;op=POST;rel=pay
> 4 < Content-Length: 391
> 4 < Date: Wed, 10 Feb 2010 10:01:20 GMT
> 4 < Content-Type: application/xml
> 4 < server: grizzly/1.9.8
> 4 <
> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
> <order>
> <id>1</id>
> <customer>http://localhost:9998/customers/21</customer>
> <shippingAddress>http://localhost:9998/customers/21/address/1</shippingAddress>
> <orderItems>
> <product>http://localhost:9998/products/3345</product>
> <quantity>1</quantity>
> </orderItems>
> <status>REVIEWED</status>
> </order>
>
>
> Feb 10, 2010 11:01:20 AM com.sun.jersey.api.client.filter.LoggingFilter log
> INFO: 5 * Client out-bound request
> 5 > GET http://localhost:9998/customers/21
> 5 >
>
> Feb 10, 2010 11:01:20 AM com.sun.jersey.api.client.filter.LoggingFilter log
> INFO: 5 * Client in-bound response
> 5 < 200
> 5 < Link: <http://localhost:9998/customers/21/refresh>;op=GET;rel=refresh
> 5 < Link: <http://localhost:9998/customers/21/update>;op=PUT;rel=update
> 5 < Link: <http://localhost:9998/customers/21/activate>;op=POST;rel=activate
> 5 < Content-Length: 258
> 5 < Date: Wed, 10 Feb 2010 10:01:20 GMT
> 5 < Content-Type: application/xml
> 5 < server: grizzly/1.9.8
> 5 <
> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
> <customer>
> <id>21</id>
> <name>John</name>
> <addresses>http://localhost:9998/customers/21/address/1</addresses>
> <cardNumber>12345678</cardNumber>
> <status>SUSPENDED</status>
> </customer>
>
>
> Feb 10, 2010 11:01:20 AM com.sun.jersey.api.client.filter.LoggingFilter log
> INFO: 6 * Client out-bound request
> 6 > POST http://localhost:9998/customers/21/activate
> 6 >
>
> Feb 10, 2010 11:01:20 AM com.sun.jersey.api.client.filter.LoggingFilter log
> INFO: 6 * Client in-bound response
> 6 < 204
> 6 < Link: <http://localhost:9998/customers/21/refresh>;op=GET;rel=refresh
> 6 < Link: <http://localhost:9998/customers/21/update>;op=PUT;rel=update
> 6 < Link: <http://localhost:9998/customers/21/suspend>;op=POST;rel=suspend
> 6 < Date: Wed, 10 Feb 2010 10:01:20 GMT
> 6 < server: grizzly/1.9.8
> 6 <
>
> Feb 10, 2010 11:01:20 AM com.sun.jersey.api.client.filter.LoggingFilter log
> INFO: 7 * Client out-bound request
> 7 > POST http://localhost:9998/orders/1/pay?newCardNumber=123456789
> 7 >
>
> Feb 10, 2010 11:01:20 AM com.sun.jersey.api.client.filter.LoggingFilter log
> INFO: 7 * Client in-bound response
> 7 < 204
> 7 < Link: <http://localhost:9998/orders/1/refresh>;op=GET;rel=refresh
> 7 < Link: <http://localhost:9998/orders/1/ship>;op=PUT;rel=ship
> 7 < Link: <http://localhost:9998/orders/1/update>;op=PUT;rel=update
> 7 < Date: Wed, 10 Feb 2010 10:01:20 GMT
> 7 < server: grizzly/1.9.8
> 7 <
>
> Feb 10, 2010 11:01:20 AM com.sun.jersey.api.client.filter.LoggingFilter log
> INFO: 8 * Client out-bound request
> 8 > OPTIONS http://localhost:9998/orders/1/ship
> 8 >
>
> Feb 10, 2010 11:01:20 AM com.sun.jersey.api.client.filter.LoggingFilter log
> INFO: 8 * Client in-bound response
> 8 < 200
> 8 < Content-Length: 669
> 8 < Allow: OPTIONS,PUT
> 8 < Date: Wed, 10 Feb 2010 10:01:20 GMT
> 8 < Content-Type: application/vnd.sun.wadl+xml
> 8 < server: grizzly/1.9.8
> 8 <
> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
> <application xmlns="http://wadl.dev.java.net/2009/02">
> <doc xmlns:jersey="http://jersey.dev.java.net/" jersey:generatedBy="Jersey: 1.2-SNAPSHOT 02/09/2010 05:29 PM"/>
> <resources base="http://localhost:9998/">
> <resource path="orders/1/ship">
> <method name="PUT" id="ship">
> <request>
> <representation mediaType="application/xml"/>
> </request>
> <response>
> <representation mediaType="application/xml"/>
> </response>
> </method>
> </resource>
> </resources>
> </application>
>
>
> Feb 10, 2010 11:01:20 AM com.sun.jersey.api.client.filter.LoggingFilter log
> INFO: 9 * Client out-bound request
> 9 > PUT http://localhost:9998/orders/1/ship
> 9 > Content-Type: application/xml
> 9 >
> <?xml version="1.0" encoding="UTF-8" standalone="yes"?><address><street>Main</street><city>Springfield</city></address>
>
> Feb 10, 2010 11:01:20 AM com.sun.jersey.api.client.filter.LoggingFilter log
> INFO: 9 * Client in-bound response
> 9 < 200
> 9 < Link: <http://localhost:9998/orders/1/refresh>;op=GET;rel=refresh
> 9 < Content-Length: 390
> 9 < Date: Wed, 10 Feb 2010 10:01:20 GMT
> 9 < Content-Type: application/xml
> 9 < server: grizzly/1.9.8
> 9 <
> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
> <order>
> <id>1</id>
> <customer>http://localhost:9998/customers/21</customer>
> <shippingAddress>http://localhost:9998/customers/21/address/1</shippingAddress>
> <orderItems>
> <product>http://localhost:9998/products/3345</product>
> <quantity>1</quantity>
> </orderItems>
> <status>SHIPPED</status>
> </order>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>

-----------------------------------
 Jan Algermissen, Consultant
 NORD Software Consulting

 Mail: algermissen_at_acm.org
 Blog: http://www.nordsc.com/blog/
 Work: http://www.nordsc.com/
-----------------------------------