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