01: /*
02: * $Id: Transaction.java 10590 2008-01-29 01:39:47Z tcarlson $
03: * --------------------------------------------------------------------------------------
04: * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com
05: *
06: * The software in this package is published under the terms of the CPAL v1.0
07: * license, a copy of which has been included with this distribution in the
08: * LICENSE.txt file.
09: */
10:
11: package org.mule.api.transaction;
12:
13: public interface Transaction {
14:
15: int STATUS_ACTIVE = 0;
16: int STATUS_MARKED_ROLLBACK = 1;
17: int STATUS_PREPARED = 2;
18: int STATUS_COMMITTED = 3;
19: int STATUS_ROLLEDBACK = 4;
20: int STATUS_UNKNOWN = 5;
21: int STATUS_NO_TRANSACTION = 6;
22: int STATUS_PREPARING = 7;
23: int STATUS_COMMITTING = 8;
24: int STATUS_ROLLING_BACK = 9;
25:
26: /**
27: * Begin the transaction.
28: *
29: * @throws TransactionException
30: */
31: void begin() throws TransactionException;
32:
33: /**
34: * Commit the transaction
35: *
36: * @throws TransactionException
37: */
38: void commit() throws TransactionException;
39:
40: /**
41: * Rollback the transaction
42: *
43: * @throws TransactionException
44: */
45: void rollback() throws TransactionException;
46:
47: int getStatus() throws TransactionException;
48:
49: boolean isBegun() throws TransactionException;
50:
51: boolean isRolledBack() throws TransactionException;
52:
53: boolean isCommitted() throws TransactionException;
54:
55: Object getResource(Object key);
56:
57: boolean hasResource(Object key);
58:
59: void bindResource(Object key, Object resource)
60: 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: * @return
79: * @throws TransactionException if any error
80: */
81: javax.transaction.Transaction suspend() throws TransactionException;
82: }
|