View Javadoc

1   //----------------------------------------------------------------------
2   // 
3   // PerfectJPattern: "Design patterns are good but components are better!" 
4   // ITransaction.java Copyright (c) 2009 Giovanni Azua Garcia
5   // bravegag@hotmail.com
6   //  
7   // This program is free software; you can redistribute it and/or
8   // modify it under the terms of the GNU General Public License
9   // as published by the Free Software Foundation; either version 3
10  // of the License, or (at your option) any later version.
11  //
12  // This program is distributed in the hope that it will be useful,
13  // but WITHOUT ANY WARRANTY; without even the implied warranty of
14  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  // GNU General Public License for more details.
16  //
17  // You should have received a copy of the GNU General Public License
18  // along with this program; if not, see <http://www.gnu.org/licenses/>.
19  //
20  //----------------------------------------------------------------------
21  package org.perfectjpattern.jee.api.integration.dao;
22  
23  import org.perfectjpattern.core.api.structural.adapter.*;
24  
25  /**
26   * Abstract definition of Transaction available for the DAO implementation.
27   * The DAO API exposes this interface but it will be automatically adapted
28   * from the underlying JPA-specific implementation (see {@link IAdapter}).
29   * <br/><br/> 
30   * JPA and specific implementations define similar abstractions e.g.
31   * Transaction but despite their similarities, their types actually 
32   * mismatch making it difficult to provide a generic unified DAO 
33   * solution.
34   * <br/><br/> 
35   * Note that this is a subset of the functionality that the underlying 
36   * implementation offers. This is the subset required to make the DAO 
37   * portable. If required, it is possible to get the underlying 
38   * implementation using {@link ISession#getDelegate()}
39   * 
40   * @author <a href="mailto:bravegag@hotmail.com">Giovanni Azua</a>
41   * @version $Revision: 1.0 $Date: Feb 10, 2009 5:56:17 PM $
42   */
43  public 
44  interface ITransaction
45  {
46      //------------------------------------------------------------------------
47      // public    
48      //------------------------------------------------------------------------
49      /**
50       * Demarcates the beginning of a Transaction
51       * 
52       * @throws DaoException
53       * @throws UnsupportedOperationException Transactions are not supported by 
54       *         the underlying persistent store. 
55       * @see #isSupported()
56       */
57      public void
58      begin()
59      throws DaoException, UnsupportedOperationException;    
60  
61      //------------------------------------------------------------------------
62      /**
63       * Commits the current Transaction
64       * 
65       * @throws DaoException
66       * @throws UnsupportedOperationException Transactions are not supported 
67       *         by the underlying persistent store.
68       * @see #isSupported()
69       */
70      public void
71      commit()
72      throws DaoException, UnsupportedOperationException;    
73      
74      //------------------------------------------------------------------------
75      /**
76       * Rolls back the current Transaction
77       * 
78       * @throws DaoException
79       * @throws UnsupportedOperationException Transactions are not supported by 
80       *         the underlying persistent store.
81       * @see #isSupported()
82       */
83      public void
84      rollback()
85      throws DaoException, UnsupportedOperationException;  
86      
87      //------------------------------------------------------------------------
88      /**
89       * Returns true if the transaction currently Active, false otherwise
90       * 
91       * @return true if the transaction currently Active, false otherwise
92       */
93      public boolean
94      isActive();
95  }