pt.jcodeutil.core.ejb
Class DataSourceFactory

java.lang.Object
  |
  +--pt.jcodeutil.core.ejb.DataSourceFactory

public class DataSourceFactory
extends java.lang.Object

Title: Data Source Factory Description: Singleton that performs lookup and caches DataSources for reuse and performance purposes.

Version:
1.0
Author:
Marco Samuel (samuelbb@sapo.pt)

Method Summary
 javax.sql.DataSource getDataSource(java.lang.String dataSourceName)
          Looks up the data source in cache by its JNDI / DataSource-Ref name, if it doesn't exist looks it up.
static DataSourceFactory getInstance()
          Gets the singleton instance
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static DataSourceFactory getInstance()
                                     throws javax.naming.NamingException
Gets the singleton instance
Returns:
the singleton instance
Throws:
javax.naming.NamingException - from InitialContext creation

getDataSource

public javax.sql.DataSource getDataSource(java.lang.String dataSourceName)
                                   throws javax.naming.NamingException
Looks up the data source in cache by its JNDI / DataSource-Ref name, if it doesn't exist looks it up.
Parameters:
dataSourceName - the JNDI / DataSource-Ref name where the data source is binded to.
Returns:
the pretended data source object
Throws:
javax.naming.NamingException - from JNDI lookup