| 1 | // Copyright 2004-2007 Jean-Francois Poilpret |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | package net.sourceforge.hivetranse.transaction; |
| 16 | |
| 17 | /** |
| 18 | * Defines the transaction demarcation for an executable scope (method of a |
| 19 | * service). |
| 20 | * This class is not intended for use by application developers, but is used |
| 21 | * by the Transaction Interceptors (read from their configuration) to notify |
| 22 | * the <code>TransactionService</code> of scope enter or leave. |
| 23 | * <p> |
| 24 | * The existing demarcations are copied from EJB declarative demarcation for |
| 25 | * Container-Managed Transactions. |
| 26 | * |
| 27 | * @author Jean-Francois Poilpret |
| 28 | */ |
| 29 | public enum TransactionDemarcation |
| 30 | { |
| 31 | /** |
| 32 | * Indicates that the scope does not support transaction, ie, if one |
| 33 | * transaction currently exists, it is suspended until the end of that scope. |
| 34 | */ |
| 35 | NotSupported, |
| 36 | |
| 37 | /** |
| 38 | * Indicates that the scope requires a transaction, ie, if one |
| 39 | * transaction currently exists, it is used, else a new transaction is created. |
| 40 | */ |
| 41 | Required, |
| 42 | |
| 43 | /** |
| 44 | * Indicates that the scope supports a transaction, ie, if one |
| 45 | * transaction currently exists, it may be used, if none exists, this will |
| 46 | * not be a problem for the code in this scope. |
| 47 | * <p> |
| 48 | * This demarcation should be avoided, because we wonder how a piece of code |
| 49 | * can one time live without transaction, and other time live with one. |
| 50 | */ |
| 51 | Supports, |
| 52 | |
| 53 | /** |
| 54 | * Indicates that the scope requires a new transaction, ie, if there is one |
| 55 | * current transaction or not, anyway, a new transaction will be created |
| 56 | * specifically for this scope. |
| 57 | * <p> |
| 58 | * Please note that the behavior here is different from the EJB world, where |
| 59 | * an exception would be thrown if there is no current transaction. |
| 60 | */ |
| 61 | RequiresNew, |
| 62 | |
| 63 | /** |
| 64 | * Indicates that the scope requires that a transaction already exists, ie, |
| 65 | * if no transaction exists, an exception will be thrown at scope entry. |
| 66 | */ |
| 67 | Mandatory, |
| 68 | |
| 69 | /** |
| 70 | * Indicates that the scope refuses to work if a transaction already exists, |
| 71 | * ie, if one transaction exists, an exception will be thrown at scope entry. |
| 72 | */ |
| 73 | Never |
| 74 | } |