Main Page | Packages | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

org.objectweb.cjdbc.driver.DataSourceFactory Class Reference

List of all members.

Public Member Functions

Object getObjectInstance (Object objRef, Name name, Context nameCtx, Hashtable env) throws Exception

Protected Attributes

final String dataSourceClassName = "org.objectweb.cjdbc.driver.DataSource"
final String poolDataSourceName = "org.objectweb.cjdbc.driver.PoolDataSource"
final String xaDataSourceName = "org.objectweb.cjdbc.driver.XADataSource"

Detailed Description

DataSource factory for to implement Referenceable. The factory serves for the DataSource,PooledDataSource, and XADataSource classes.

Author:
Marek Prochazka
Version:
1.0

Definition at line 41 of file DataSourceFactory.java.


Member Function Documentation

Object org.objectweb.cjdbc.driver.DataSourceFactory.getObjectInstance Object  objRef,
Name  name,
Context  nameCtx,
Hashtable  env
throws Exception
 

Gets an instance of the requested DataSource object.

Parameters:
objRef object containing location or reference information that is used to create an object instance (could be null).
name name of this object relative to specified nameCtx (could be null).
nameCtx name context (could ne null if the default initial context is used).
env environment to use (could be null if default is used)
Returns:
a newly created instance of C-JDBC DataSource, null if an error occurred.
Exceptions:
Exception if an error occurs when creating the object instance.

Definition at line 62 of file DataSourceFactory.java.

References org.objectweb.cjdbc.driver.DataSourceFactory.dataSourceClassName, org.objectweb.cjdbc.driver.DataSource.setPassword(), org.objectweb.cjdbc.driver.DataSource.setUrl(), and org.objectweb.cjdbc.driver.DataSource.setUser().

00064   {
00065     // Check the requested object class
00066     Reference ref = (Reference) objRef;
00067     String className = ref.getClassName();
00068     if ((className == null)
00069         || !(className.equals(dataSourceClassName)
00070             | className.equals(poolDataSourceName) | className
00071             .equals(xaDataSourceName)))
00072     {
00073       // Wrong class
00074       return null;
00075     }
00076     DataSource ds = null;
00077     try
00078     {
00079       ds = (DataSource) Class.forName(className).newInstance();
00080     }
00081     catch (Exception e)
00082     {
00083       throw new RuntimeException("Error when creating C-JDBC" + className
00084           + " instance: " + e);
00085     }
00086 
00087     ds.setUrl((String) ref.get(DataSource.URL_PROPERTY).getContent());
00088     ds.setUser((String) ref.get(DataSource.USER_PROPERTY).getContent());
00089     ds.setPassword((String) ref.get(DataSource.PASSWORD_PROPERTY).getContent());
00090     return ds;
00091   }


Member Data Documentation

final String org.objectweb.cjdbc.driver.DataSourceFactory.dataSourceClassName = "org.objectweb.cjdbc.driver.DataSource" [protected]
 

DataSource classnames.

Definition at line 44 of file DataSourceFactory.java.

Referenced by org.objectweb.cjdbc.driver.DataSourceFactory.getObjectInstance().


The documentation for this class was generated from the following file:
Generated on Mon Apr 11 22:04:58 2005 for C-JDBC by  doxygen 1.3.9.1