[javaee-spec users] Re: ​Re: [jsr366-experts] global resources

From: Bill Shannon <>
Date: Fri, 20 Feb 2015 17:07:37 -0800

arjan tijms wrote on 02/18/15 14:48:
> Hi,
> On Wed, Feb 18, 2015 at 10:13 PM, Anatole Tresch <> wrote:
>> I strongly would recommend A, since it is the only concise behaviour. All
>> other variants can have unexpected side effects, especially when the shared
>> resource is capable of holding references to things, it can get very ugly.
> That's indeed a pretty good point. It's easy to think of resources in
> terms of the well known ones like a stateless data source that can be
> easily shared and reference counted. However, a resource can of course
> be anything and even a data source can contain anything. Not every
> data source is just a driver for an external DB, some actually
> represent the DB itself (common for embedded DBs).

Just in case anyone's confused, the spec already requires that each lookup
(or equivalently injection) of a JNDI resource returns a new instance of
the object (unless the object is known to be immutable). So even a global
"shared" resource will not result in shared object instances. Of course,
if the object is really a reference to another resource (e.g., a database
server), sharing might still occur even with multiple references.