KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > transaction > JNDITransactionManagerLookup


1 //$Id: JNDITransactionManagerLookup.java,v 1.1 2004/06/03 16:31:29 steveebersole Exp $
2
package org.hibernate.transaction;
3
4 import java.util.Properties JavaDoc;
5
6 import javax.naming.NamingException JavaDoc;
7 import javax.transaction.TransactionManager JavaDoc;
8
9 import org.hibernate.HibernateException;
10 import org.hibernate.util.NamingHelper;
11
12 /**
13  * Locates a <tt>TransactionManager</tt> in JNDI.
14  * @author Gavin King
15  */

16 public abstract class JNDITransactionManagerLookup implements TransactionManagerLookup {
17
18     /**
19      * @see org.hibernate.transaction.TransactionManagerLookup#getTransactionManager(java.util.Properties)
20      */

21     public TransactionManager JavaDoc getTransactionManager(Properties JavaDoc props) throws HibernateException {
22         try {
23             return (TransactionManager JavaDoc) NamingHelper.getInitialContext(props).lookup( getName() );
24         }
25         catch (NamingException JavaDoc ne) {
26             throw new HibernateException( "Could not locate TransactionManager", ne );
27         }
28     }
29
30     protected abstract String JavaDoc getName();
31
32 }
33
34
35
36
37
38
39
Popular Tags