KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > transaction > support > SimpleTransactionStatus


1 /*
2  * Copyright 2002-2006 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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     /**
44      * Creates a new instance of the {@link SimpleTransactionStatus} class,
45      * indicating a new transaction.
46      */

47     public SimpleTransactionStatus() {
48         this(true);
49     }
50
51     /**
52      * Creates a new instance of the {@link SimpleTransactionStatus} class.
53      * @param newTransaction whether to indicate a new transaction
54      */

55     public SimpleTransactionStatus(boolean newTransaction) {
56         this.newTransaction = newTransaction;
57     }
58
59
60     public boolean isNewTransaction() {
61         return newTransaction;
62     }
63
64 }
65
Popular Tags