KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > transaction > annotation > Propagation


1 /*
2  * Copyright 2002-2005 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.annotation;
18
19 import org.springframework.transaction.TransactionDefinition;
20
21 /**
22  * Enumeration that represents transaction propagation behaviors
23  * for use with the JDK 1.5+ transaction annotation, corresponding
24  * to the TransactionDefinition interface.
25  *
26  * @author Colin Sampaleanu
27  * @author Juergen Hoeller
28  * @since 1.2
29  * @see org.springframework.transaction.annotation.Transactional
30  * @see org.springframework.transaction.TransactionDefinition
31  */

32 public enum Propagation {
33     
34     /**
35      * Support a current transaction, create a new one if none exists.
36      * Analogous to EJB transaction attribute of the same name.
37      * <p>This is the default setting of a transaction annotation.
38      */

39     REQUIRED(TransactionDefinition.PROPAGATION_REQUIRED),
40
41     /**
42      * Support a current transaction, execute non-transactionally if none exists.
43      * Analogous to EJB transaction attribute of the same name.
44      * <p>Note: For transaction managers with transaction synchronization,
45      * PROPAGATION_SUPPORTS is slightly different from no transaction at all,
46      * as it defines a transaction scopp that synchronization will apply for.
47      * As a consequence, the same resources (JDBC Connection, Hibernate Session, etc)
48      * will be shared for the entire specified scope. Note that this depends on
49      * the actual synchronization configuration of the transaction manager.
50      * @see org.springframework.transaction.support.AbstractPlatformTransactionManager#setTransactionSynchronization
51      */

52     SUPPORTS(TransactionDefinition.PROPAGATION_SUPPORTS),
53
54     /**
55      * Support a current transaction, throw an exception if none exists.
56      * Analogous to EJB transaction attribute of the same name.
57      */

58     MANDATORY(TransactionDefinition.PROPAGATION_MANDATORY),
59
60     /**
61      * Create a new transaction, suspend the current transaction if one exists.
62      * Analogous to EJB transaction attribute of the same name.
63      * <p>Note: Actual transaction suspension will not work on out-of-the-box
64      * on all transaction managers. This in particular applies to JtaTransactionManager,
65      * which requires the <code>javax.transaction.TransactionManager</code> to be
66      * made available it to it (which is server-specific in standard J2EE).
67      * @see org.springframework.transaction.jta.JtaTransactionManager#setTransactionManager
68      */

69     REQUIRES_NEW(TransactionDefinition.PROPAGATION_REQUIRES_NEW),
70
71     /**
72      * Execute non-transactionally, suspend the current transaction if one exists.
73      * Analogous to EJB transaction attribute of the same name.
74      * <p>Note: Actual transaction suspension will not work on out-of-the-box
75      * on all transaction managers. This in particular applies to JtaTransactionManager,
76      * which requires the <code>javax.transaction.TransactionManager</code> to be
77      * made available it to it (which is server-specific in standard J2EE).
78      * @see org.springframework.transaction.jta.JtaTransactionManager#setTransactionManager
79      */

80     NOT_SUPPORTED(TransactionDefinition.PROPAGATION_NOT_SUPPORTED),
81
82     /**
83      * Execute non-transactionally, throw an exception if a transaction exists.
84      * Analogous to EJB transaction attribute of the same name.
85      */

86     NEVER(TransactionDefinition.PROPAGATION_NEVER),
87
88     /**
89      * Execute within a nested transaction if a current transaction exists,
90      * behave like PROPAGATION_REQUIRED else. There is no analogous feature in EJB.
91      * <p>Note: Actual creation of a nested transaction will only work on specific
92      * transaction managers. Out of the box, this only applies to the JDBC
93      * DataSourceTransactionManager when working on a JDBC 3.0 driver.
94      * Some JTA providers might support nested transactions as well.
95      * @see org.springframework.jdbc.datasource.DataSourceTransactionManager
96      */

97     NESTED(TransactionDefinition.PROPAGATION_NESTED);
98
99
100     private final int value;
101
102
103     Propagation(int value) { this.value = value; }
104     
105     public int value() { return value; }
106     
107 }
108
Popular Tags