> >David,
> > That clears up quite a bit for me. So if I have a Resource setup in my
> >container (Tomcat 4.1.24) I can use that resource in any class using JNDI
> >and don't have to worry about specifying it inside my
> >struts-configuration.xml file. Am I understanding you correct.
>
> That's exactly right. You probably want to look it up from JNDI once and
> cache it somewhere because JNDI calls are potentially expensive.
>


For long running apps on a high quality enterprise server, you might
actually want to think twice about doing the JNDI lookup only one time and
then caching it.  If you do the lookup every time, you give the container
an opportunity to transparently deal with things like databases that went
down and back up -- perhaps by giving you a different connection pool the
second time than you got the first time.

On most containers (including Tomcat), a JNDI lookup for resources
provided by the container is only slightly more expensive than a HashMap
lookup -- the difference being mostly in the processing of the object
name.  It's all a set of in-memory resource instances and factories.

That's good to know. Not having looked at the Tomcat source, nor having access to other containers' sources I assumed the worst about JNDI performance. I have just proved how bad programmers are at optimizing performance :-).


David

Craig

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


_________________________________________________________________
Add photos to your e-mail with MSN 8. Get 2 months FREE*. http://join.msn.com/?page=features/featuredemail



--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to