01: /*
02: * Copyright 2002-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.springframework.transaction.support;
18:
19: /**
20: * A simple {@link org.springframework.transaction.TransactionStatus}
21: * implementation.
22: *
23: * <p>Derives from {@link AbstractTransactionStatus} and adds an explicit
24: * {@link #isNewTransaction() "newTransaction"} flag.
25: *
26: * <p>This class is not used by any of Spring's pre-built
27: * {@link org.springframework.transaction.PlatformTransactionManager}
28: * implementations. It is mainly provided as a start for custom transaction
29: * manager implementations and as a static mock for testing transactional
30: * code (either as part of a mock <code>PlatformTransactionManager</code> or
31: * as argument passed into a {@link TransactionCallback} to be tested).
32: *
33: * @author Juergen Hoeller
34: * @since 1.2.3
35: * @see #SimpleTransactionStatus(boolean)
36: * @see TransactionCallback
37: */
38: public class SimpleTransactionStatus extends AbstractTransactionStatus {
39:
40: private final boolean newTransaction;
41:
42: /**
43: * Creates a new instance of the {@link SimpleTransactionStatus} class,
44: * indicating a new transaction.
45: */
46: public SimpleTransactionStatus() {
47: this (true);
48: }
49:
50: /**
51: * Creates a new instance of the {@link SimpleTransactionStatus} class.
52: * @param newTransaction whether to indicate a new transaction
53: */
54: public SimpleTransactionStatus(boolean newTransaction) {
55: this .newTransaction = newTransaction;
56: }
57:
58: public boolean isNewTransaction() {
59: return newTransaction;
60: }
61:
62: }
|