View Javadoc

1   /***
2    *  Copyright 2003-2010 Terracotta, Inc.
3    *
4    *  Licensed under the Apache License, Version 2.0 (the "License");
5    *  you may not use this file except in compliance with the License.
6    *  You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *  Unless required by applicable law or agreed to in writing, software
11   *  distributed under the License is distributed on an "AS IS" BASIS,
12   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *  See the License for the specific language governing permissions and
14   *  limitations under the License.
15   */
16  package net.sf.ehcache.hibernate;
17  
18  import net.sf.ehcache.transaction.manager.DefaultTransactionManagerLookup;
19  import org.hibernate.HibernateException;
20  import org.hibernate.transaction.TransactionManagerLookup;
21  
22  import javax.transaction.Transaction;
23  import javax.transaction.TransactionManager;
24  import java.util.Properties;
25  
26  /***
27   * Hibernate TransactionManagerLookup which also is a Ehcache transaction manager lookup.
28   *
29   * @author Ludovic Orban
30   */
31  public class EhcacheJtaTransactionManagerLookup extends DefaultTransactionManagerLookup implements TransactionManagerLookup {
32  
33      /***
34       * Construct a new transaction manager lookup.
35       */
36      public EhcacheJtaTransactionManagerLookup() {
37          // no-op
38      }
39  
40      /***
41       * {@inheritDoc}
42       */
43      public TransactionManager getTransactionManager(Properties properties) throws HibernateException {
44          return getTransactionManager();
45      }
46  
47      /***
48       * {@inheritDoc}
49       */
50      public String getUserTransactionName() {
51          return null;
52      }
53  
54      /***
55       * {@inheritDoc}
56       */
57      public Object getTransactionIdentifier(Transaction transaction) {
58          return transaction;
59      }
60  }