users@jersey.java.net

Re: [Jersey] Suites of Transactions

From: Marc Hadley <Marc.Hadley_at_Sun.COM>
Date: Wed, 01 Oct 2008 09:39:34 -0400

Another possibility is to route requests through one or more root
resource classes that initialize a bean with the required information
and then dispatch the requests to the real resource classes via sub-
resource locators. The sub-resource locators can either pass the bean
to the sub-resources directly or the sub-resources can lookup the root
resource via UriInfo.getMatchedResources and then get the bean as a
root resource property.

Marc.

On Oct 1, 2008, at 5:57 AM, Paul Sandoz wrote:

> Hi Greg,
>
> On Sep 30, 2008, at 11:18 PM, Giacovelli, Greg wrote:
>
>> Hi,
>> After using Jersey for a few months, I have hit some stumbling
>> blocks. Let’s say there is a web application with N resources. Each
>> resource adheres to a common format. I.e. Each txn must have a
>> version identifier. From what I can understand from the
>> specification, the 2 ways to achieve this is to make sure you list
>> out the required attributes in every method signature, or to create
>> an abstract Resource that has a constructor that takes the required
>> attributes that all the resources inherit from. This is
>> essentially using inheritance to enforce a constraint (If I am
>> missing something, please stop me now J ).
>
> Yes, that is one way, with limitation you describe below.
>
>
>>
>> This gets tricky as you add more suites. If two or more suites have
>> to cross, you are halted.
>> I was wondering if there was a way to define a suite and annotate a
>> resource as being part of a particular suite or suites. Then
>> through use of a Context annotation, a bean can be made available
>> with the data desired (some interface that the suite definition
>> defines). I know this seems like more of a gripe with the jsr than
>> Jersey but was wondering if it at least is a sound concern.
>
> If i understand you correctly what you want is an IoC framework.
> Your gripe is a valid one we hope to address in a standard way for
> Java EE 6 by using WebBeans.
>
> There are two ways you can do this today using Jersey:
>
> 1) Register an InjectableProvider; or
>
> 2) Use Spring.
>
> Jersey has good Spring integration, see the simple example here:
>
> http://download.java.net/maven/2/com/sun/jersey/samples/spring-annotations/1.0-ea-SNAPSHOT/spring-annotations-1.0-ea-SNAPSHOT-project.zip
> .
>
> If you do not want to use Spring, want a lighter weight but simpler
> approach, and you want to reuse say @Context, you can use
> InjectableProvider. This is the framework by which all injection
> works in Jersey. Let me know if you want more details on that.
>
> Paul.
>
>>
>> Please let me know if I am unclear or just talking non-sense.
>>
>> Thanks,
>> -Greg
>>
>

---
Marc Hadley <marc.hadley at sun.com>
CTO Office, Sun Microsystems.