tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shapira, Yoav" <>
Subject RE: Accessing resource in WEB-INF outside servlet
Date Mon, 08 Nov 2004 15:15:58 GMT

>So the intialization of this sington datasource provider occurs the
>first time the class is called? and from then on out there's only one
>instance of the class, owing to its singleton nature? would that look
>like this:
>public class AppDBConnector {
>	private static final INSTANCE = new AppDBConector();
>	private static DataSource ds;
>	private AppDBConnector() {
>		// set static ds abov using JNDI lookup or resource
>	}
>	public AppDBConnector getInstance() {
>		return INSTANCE;
>	}
>	public Connection getConnection() {
>		return ds.getConnection();
>	}

Close enough.  There's no need for ds to be static.  And some people
prefer to not construct INSTANCE until the first getInstance call.  But
those are smaller details.


This e-mail, including any attachments, is a confidential business communication, and may
contain information that is confidential, proprietary and/or privileged.  This e-mail is intended
only for the individual(s) to whom it is addressed, and may not be saved, copied, printed,
disclosed or used by anyone else.  If you are not the(an) intended recipient, please immediately
delete this e-mail from your computer system and notify the sender.  Thank you.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message