KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > lutris > appserver > server > sql > DBTransactionFactoryCreator


1 /*
2  * Created on May 24, 2004
3  *
4  */

5 package com.lutris.appserver.server.sql;
6
7 import org.enhydra.dods.DODS;
8
9 import com.lutris.logging.Logger;
10
11 /**
12  * @version 0.2
13  */

14 public class DBTransactionFactoryCreator {
15
16     public static AbstractDBTransactionFactory getDBTransactionFactory(String JavaDoc dbTransFactoryClassName, LogicalDatabase ldb){
17         Class JavaDoc transFactoryClass = null;
18         AbstractDBTransactionFactory transFactory = null;
19         if (dbTransFactoryClassName != null) {
20             try {
21                 transFactoryClass = Class.forName(dbTransFactoryClassName);
22                 transFactory = (AbstractDBTransactionFactory) transFactoryClass.newInstance();
23             } catch (Exception JavaDoc e) {
24                 DODS.getLogChannel()
25                     .write(Logger.ERROR,
26                     "Failed to make DBTransactionFactory :"
27                     + dbTransFactoryClassName
28                     + " creating StandardDBTransactionFactory instead");
29                 transFactory = null;
30             }
31         }
32         if (dbTransFactoryClassName == null || transFactory == null) {
33             try {
34                 transFactoryClass = Class.forName("com.lutris.appserver.server.sql.standard.StandardDBTransactionFactory");
35                 transFactory = (AbstractDBTransactionFactory) transFactoryClass.newInstance();
36             } catch (Exception JavaDoc e) {
37                 String JavaDoc str = "Failed to make StandardTransactionFactory : com.lutris.appserver.server.sql.standard.StandardDBTransactionFactory";
38                 DODS.getLogChannel().write(Logger.CRITICAL, str);
39                 throw new Error JavaDoc(str);
40             }
41         }
42         transFactory.setLogicalDb(ldb);
43         return transFactory;
44     }
45 }
Popular Tags