users@jersey.java.net

Multiple UriTemplate Annotations for Generic 'Handler' Classes?

From: <stewart.welbourne_at_bt.com>
Date: Thu, 10 Jan 2008 17:47:47 -0000

Hi
I originally posted some thoughts
(http://thestewscope.wordpress.com/2008/01/10/rubyrails-uri-patterns-and
-jsr311/) as I was getting up to speed on JSR311 and Jersey. It relates
to a specific need I have to manage the formation of resource
representations dynamically, where a single class/handler may underpin 2
or more discrete UriTemplates. In this case I was unclear how to pin a
range of templates to a single generic class:

//So this is the basic mechanism for exposing a simple data set through
a single URI
@UriTemplate("/concreteresource)
Public class MyConcreteResource {
        //Relying on O/R mapping to an atomic datasource
}

But where the assembly of (lets call them virtual) resource
representations relies on more complex back-end interactions I want to
centralise the processing as follows:

@UriTemplate("/virtualresourcetype1)
@UriTemplate("/virtualresourcetype2)
@UriTemplate("/virtualresourcetype3)
Public class MyVirtualResourceHandler{
        //Here I do some meta-data driven back-end integration to
resolve the representations
}

I'd appreciate views on whether JSR311/Jersey annotations support this
kind of overloading, or alternatively what the optimal class arrangement
would be if there's a pattern to support this.

Thanks
Stew

Stewart Welbourne
stewart.welbourne_at_bt.com