Re: JSR311: _at_Singleton

From: Bill Burke <>
Date: Mon, 09 Jun 2008 16:19:49 -0400

Marc Hadley wrote:
> On Jun 9, 2008, at 12:47 PM, Bill Burke wrote:
>>>> I noticed jersey has an @Singleton annotation. Can we just add this
>>>> to the spec? Its something I want in my implementation as well.
>>> Seems to me that component lifecycle annotations really belong
>>> elsewhere and if we add them in this JSR then we'd be getting into
>>> the IoC framework space.
>> Yeah, you're right. Kinda contradicts my arguments against
>> ContextResolver too.
>> Can we get some support for singletons in ApplicationConfig then?
>> List<Object> getResourceInstances();
>> List<Object> getProviderInstances();
>> I've already run into the need of having portable singletons.
> You don't think that is also getting into the IoC framework space ?

I'll answer this question with a question. With the current APIs/SPIs,
how would you plug in Spring in a portable manner?

> If
> you are using Spring or WebBeans you'd want those to be in charge of the
> lifecycle, not the application directly...

With the above additions, you could write an ApplicationConfig class
that loads a Spring/Guice context which does all the configuration of
the resources and providers.

For an EE 6 app-server, IMO, we should really figure out and define how
Web Beans and EJBs *must* interact with JAX-RS in 1) a single vendor
solution and 2) a thirdparty JAX-RS implementation plugged into an EE

In all the above cases, users are going to struggle with portability
unless something is defined by the specification.


Bill Burke
JBoss, a division of Red Hat