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.transaction;
18:
19: import org.compass.core.Compass;
20: import org.compass.core.CompassException;
21: import org.compass.core.CompassSession;
22: import org.compass.core.CompassTransaction;
23: import org.compass.core.CompassTransaction.TransactionIsolation;
24: import org.compass.core.config.CompassSettings;
25: import org.compass.core.spi.InternalCompassSession;
26:
27: /**
28: *
29: * @author kimchy
30: *
31: */
32:
33: public interface TransactionFactory {
34:
35: void configure(Compass compass, CompassSettings settings)
36: throws CompassException;
37:
38: CompassTransaction beginTransaction(InternalCompassSession session,
39: TransactionIsolation transactionIsolation)
40: throws CompassException;
41:
42: /**
43: * Retuns a transaction bound session, or <code>null</code> if none is found.
44: */
45: CompassSession getTransactionBoundSession() throws CompassException;
46:
47: /**
48: * If there is an outer running existing transaction, try and join it. This method
49: * is called when opening a session and will ease the usage of Compass since there
50: * won't be a need to begin a transaction explicitly.
51: * <p/>
52: * Note, this might end up working as if {@link org.compass.core.CompassSession#beginTransaction()}
53: * was called, commit/rollback will not be called afterwards. Actually, beginTransaction might be
54: * called again for the same session.
55: */
56: boolean tryJoinExistingTransaction(InternalCompassSession session)
57: throws CompassException;
58: }
|