KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > shark > utilities > hibernate > HibernateUtilityTransactionFactory


1 /*
2  * Shark Hibernate HibernateUtilityTransactionFactory - Open Wide
3  */

4
5 package org.enhydra.shark.utilities.hibernate;
6
7 import org.enhydra.shark.api.RootException;
8 import org.enhydra.shark.api.SharkTransaction;
9 import org.enhydra.shark.api.TransactionException;
10 import org.enhydra.shark.api.internal.transaction.TransactionFactory;
11 import org.enhydra.shark.api.internal.working.CallbackUtilities;
12
13 /**
14  * Implementation of UserTransactionFactory interface that creates Hibernate transaction.
15  * @author Vladislav Pernin
16  *
17  */

18 public class HibernateUtilityTransactionFactory implements TransactionFactory {
19    static boolean _debug_ = false;
20
21    private static final String JavaDoc DBG_PARAM_NAME = "HibernateUtilityTransactionFactory.debug";
22    public void configure (CallbackUtilities cus) throws RootException {
23       if (null == cus)
24          throw new RootException("Cannot configure without call back impl.");
25       _debug_ = Boolean
26          .valueOf(cus.getProperty(DBG_PARAM_NAME, "false"))
27          .booleanValue();
28    }
29
30    public SharkTransaction createTransaction () throws TransactionException {
31       try {
32          return new SharkHibernateUtilityTransaction(ThreadLocalSession.currentSession().beginTransaction());
33       } catch (Exception JavaDoc ex) {
34          throw new TransactionException(ex);
35       }
36    }
37    
38 }
39
40
Popular Tags