View Javadoc

1   /*
2    * $Id: Transaction.java 19191 2010-08-25 21:05:23Z tcarlson $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.api.transaction;
12  
13  public interface Transaction
14  {
15  
16      int STATUS_ACTIVE = 0;
17      int STATUS_MARKED_ROLLBACK = 1;
18      int STATUS_PREPARED = 2;
19      int STATUS_COMMITTED = 3;
20      int STATUS_ROLLEDBACK = 4;
21      int STATUS_UNKNOWN = 5;
22      int STATUS_NO_TRANSACTION = 6;
23      int STATUS_PREPARING = 7;
24      int STATUS_COMMITTING = 8;
25      int STATUS_ROLLING_BACK = 9;
26  
27      /**
28       * Begin the transaction.
29       * 
30       * @throws TransactionException
31       */
32      void begin() throws TransactionException;
33  
34      /**
35       * Commit the transaction
36       * 
37       * @throws TransactionException
38       */
39      void commit() throws TransactionException;
40  
41      /**
42       * Rollback the transaction
43       * 
44       * @throws TransactionException
45       */
46      void rollback() throws TransactionException;
47  
48      int getStatus() throws TransactionException;
49  
50      boolean isBegun() throws TransactionException;
51  
52      boolean isRolledBack() throws TransactionException;
53  
54      boolean isCommitted() throws TransactionException;
55  
56      Object getResource(Object key);
57  
58      boolean hasResource(Object key);
59  
60      void bindResource(Object key, Object resource) throws TransactionException;
61  
62      void setRollbackOnly() throws TransactionException;
63  
64      boolean isRollbackOnly() throws TransactionException;
65  
66      boolean isXA();
67  
68      /**
69       * Resume the XA transaction
70       *
71       * @throws TransactionException if any error
72       */
73      void resume() throws TransactionException;
74  
75      /**
76       * Suspend the XA transaction
77       *
78       * @throws TransactionException if any error
79       */
80      javax.transaction.Transaction suspend() throws TransactionException;
81  
82      /**
83       * @return TX identification.
84       */
85      String getId();
86  }