01: /*
02: * Copyright 2004-2006 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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:
17: package org.compass.core;
18:
19: import org.compass.core.util.Parameter;
20:
21: /**
22: * Allows the application to define units of work, while maintaining abstraction
23: * from the underlying transaction implementation (eg. JTA, Local).
24: *
25: * @see org.compass.core.CompassSession#beginTransaction()
26: * @see org.compass.core.transaction.TransactionFactory
27: *
28: * @author kimchy
29: */
30: public interface CompassTransaction {
31:
32: public static final class TransactionIsolation extends Parameter {
33:
34: private static final long serialVersionUID = -1263760938029345643L;
35:
36: private TransactionIsolation(String name) {
37: super (name);
38: }
39:
40: public static final TransactionIsolation READ_COMMITTED = new TransactionIsolation(
41: "READ_COMMITTED");
42:
43: public static final TransactionIsolation READ_ONLY_READ_COMMITTED = new TransactionIsolation(
44: "READ_ONLY_READ_COMMITTED");
45:
46: public static final TransactionIsolation SERIALIZABLE = new TransactionIsolation(
47: "SERIALIZABLE");
48:
49: /**
50: * @deprecated use lucene transaction instead
51: */
52: public static final TransactionIsolation BATCH_INSERT = new TransactionIsolation(
53: "BATCH_INSERT");
54:
55: public static final TransactionIsolation LUCENE = new TransactionIsolation(
56: "LUCENE");
57: }
58:
59: /**
60: * Ends the current unit of work. The transaction will be commited only if
61: * it was initiated by the current transcation.
62: *
63: * @throws CompassException
64: */
65: void commit() throws CompassException;
66:
67: /**
68: * Force the underlying transaction to roll back.
69: *
70: * @throws CompassException
71: */
72: void rollback() throws CompassException;
73:
74: /**
75: * Was this transaction rolled back or set to rollback only?
76: *
77: * @return If the transaction was rolled backed
78: * @throws CompassException
79: */
80: boolean wasRolledBack() throws CompassException;
81:
82: /**
83: * Check if this transaction was successfully committed. This method could
84: * return <code>false</code> even after successful invocation of
85: * <code>commit()</code>.
86: *
87: * @return If the transaction was committed
88: * @throws CompassException
89: */
90: boolean wasCommitted() throws CompassException;
91:
92: /**
93: * Returns the current Compass transaction associated with this transaction.
94: */
95: CompassSession getSession();
96: }
|