On 10 Nov 2002, John McNally wrote:

> >
> > 5. Not sure why we need to keep a static map of all pools by datasource. J2EE 
>environment will call jndi environment getObjectInstance() only once to create a pool 
>and then the environment will keep the reference and will not call factory method on 
>each object lookup but return previously created instance
> >
>
> Tomcat may do this, I do not know.  But I do not think a jndi service is
> required to return the same instance to every lookup.  Is there a
> specification that says J2EE containers will cache instances?  The jdbc
> spec mentions use of static fields as a way to code around the fact that
> there might be multiple instances which should be referring to the same
> pool of connections.
>

The situation with regard to caching instances (and related concerns about
the immutability of the instances being returned) was ambiguous in the
J2EE 1.2 and 1.3 specs, but has been clarified in J2EE 1.4 (Proposed Final
Draft), section 5.2:

    In general, lookups of objects in the JNDI "java:" namespace
    are required to return a new instance of the requested object
    every time.

There are some listed exceptions to this rule (primarily for things that
are known to be immutable (such as a java.lang.String) or designed to be
singletons (at the JVM level), but these exceptions don't apply to things
like JDBC data sources.  Looks like we'll have to change things in Tomcat
5.

Section 5.4 talks in more detail about the container's responsibilities
related to resource manager connection factories in a J2EE app server
environment.

You can grab the J2EE 1.4 PFD platform spec at:

  http://java.sun.com/j2ee/download.html


> john mcnally
>

Craig


--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@;jakarta.apache.org>

Reply via email to