KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > shark > usertransaction > HibernateUserTransactionFactory


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

4
5 package org.enhydra.shark.usertransaction;
6
7 import org.enhydra.shark.api.RootException;
8 import org.enhydra.shark.api.TransactionException;
9 import org.enhydra.shark.api.UserTransaction;
10 import org.enhydra.shark.api.internal.usertransaction.UserTransactionFactory;
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 HibernateUserTransactionFactory implements UserTransactionFactory {
19    static boolean _debug_ = false;
20
21    private static final String JavaDoc DBG_PARAM_NAME = "HibernateUserTransactionFactory.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 UserTransaction createTransaction () throws TransactionException {
31       try {
32          return new SharkHibernateUserTransaction(ThreadLocalSession.currentSession().beginTransaction());
33       } catch (Exception JavaDoc ex) {
34          throw new TransactionException(ex);
35       }
36    }
37    
38 }
39
40
Popular Tags