KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > service > transaction > TransactionService


1 /*
2  * Copyright (C) 2005 Alfresco, Inc.
3  *
4  * Licensed under the Mozilla Public License version 1.1
5  * with a permitted attribution clause. You may obtain a
6  * copy of the License at
7  *
8  * http://www.alfresco.org/legal/license.txt
9  *
10  * Unless required by applicable law or agreed to in writing,
11  * software distributed under the License is distributed on an
12  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13  * either express or implied. See the License for the specific
14  * language governing permissions and limitations under the
15  * License.
16  */

17 package org.alfresco.service.transaction;
18
19 import javax.transaction.UserTransaction JavaDoc;
20
21 /**
22  * Contract for retrieving access to a user transaction.
23  * <p>
24  * Note that the implementation of the {@link javax.transaction.UserTransaction}
25  * is not able to provide the full set of status codes available on the
26  * {@link javax.transaction.Status} class.
27  *
28  * @author David Caruana
29  */

30 public interface TransactionService
31 {
32     /**
33      * Determine if ALL user transactions will be read-only.
34      *
35      * @return Returns true if all transactions are read-only.
36      */

37     public boolean isReadOnly();
38     
39     /**
40      * Gets a user transaction that supports transaction propagation.
41      * This is like the EJB <b>REQUIRED</b> transaction attribute.
42      *
43      * @return the user transaction
44      */

45     UserTransaction JavaDoc getUserTransaction();
46     
47     /**
48      * Gets a user transaction that supports transaction propagation.
49      * This is like the EJB <b>REQUIRED</b> transaction attribute.
50      *
51      * @param readOnly Set true for a READONLY transaction instance, false otherwise.
52      * Note that it is not <i>always</i> possible to force a write transaction if the
53      * system is in read-only mode.
54      * @return the user transaction
55      */

56     UserTransaction JavaDoc getUserTransaction(boolean readOnly);
57     
58     /**
59      * Gets a user transaction that ensures a new transaction is created.
60      * Any enclosing transaction is not propagated.
61      * This is like the EJB <b>REQUIRES_NEW</b> transaction attribute -
62      * when the transaction is started, the current transaction will be
63      * suspended and a new one started.
64      *
65      * @return Returns a non-propagating user transaction
66      */

67     UserTransaction JavaDoc getNonPropagatingUserTransaction();
68     
69     /**
70      * Gets a user transaction that ensures a new transaction is created.
71      * Any enclosing transaction is not propagated.
72      * This is like the EJB <b>REQUIRES_NEW</b> transaction attribute -
73      * when the transaction is started, the current transaction will be
74      * suspended and a new one started.
75      *
76      * @param readOnly Set true for a READONLY transaction instance, false otherwise.
77      * Note that it is not <i>always</i> possible to force a write transaction if the
78      * system is in read-only mode.
79      * @return Returns a non-gating user transaction
80      */

81     UserTransaction JavaDoc getNonPropagatingUserTransaction(boolean readOnly);
82 }
83
Popular Tags