users@jersey.java.net

WADL with implicit views

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Tue, 17 Mar 2009 10:54:17 +0100

Hi James,

I have spent some time yesterday looking at the WADL with implicit
views and I am struggling to come up a clean solution for providing
base support for WADL resources that can be extended to say support
explicit views.

Say we have the following:

   @Produces({"application/vnd.sun.wadl+xml", "application/xml"})
   @Singleton
   public class WadlApplicationResource { // this was WadlResource

     protected WadlResourceResource createWadlResource(Resource
resource) {
         return new WadlResourceResource(this, resource);
     }

   }

   @Produces({"application/vnd.sun.wadl+xml", "application/xml"})
   public class WadlResource { // this was WadlResourceResource

     protected WadlResourceResource createWadlResource(Resource
resource) {
         return new WadlResourceResource(this, resource);
     }

     protected PartialResource createPartialResource(String path) {
         return new PartialResource(this, path);
     }

   }

   public class WadlPartialResource extends WadlResource { // this was
PartialResource
   }


If one wants to override it requires one to consistently extend from
three classes WadlApplicationResource, WadlResource and
WadlPartialResource in addition to overriding three protected methods
(1 on WadlApplicationResource, and 2 on WadlResource).


Perhaps the best solution is to cleanly separate the two areas of
functionality:

1) Basic WADL support provided by default.

2) Implicit WADL support that may be enabled by overriding one class
with the
      @Path you require for the root.

What do you think?

Paul.