KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > jdo > api > persistence > support > Transaction


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 /*
25  * Transaction.java
26  *
27  * Created on February 25, 2000
28  */

29  
30 package com.sun.jdo.api.persistence.support;
31 import javax.transaction.*;
32
33 /** The JDO Transaction interface is a sub-interface of the PersistenceManager
34  * that deals with options and completion of transactions under user control.
35  *
36  * <P>Transaction options include whether optimistic concurrency
37  * control should be used for the current transaction, and whether values
38  * should be retained in JDO instances after transaction completion.
39  *
40  * <P>Transaction completion methods have the same semantics as javax.transaction
41  * UserTransaction, and are valid only in the non-managed, non-distributed
42  * transaction environment.
43  * @author Craig Russell
44  * @version 0.1
45  */

46
47 public interface Transaction
48 {
49     /** Begin a transaction. The type of transaction is determined by the
50    * setting of the Optimistic flag.
51    * @see #setOptimistic
52    * @see #getOptimistic
53    * @throws JDOUserException if a distributed transaction XAResource
54    * is assigned to this Transaction
55    */

56     void begin();
57     
58     /** Commit the current transaction.
59      */

60     void commit();
61     
62     /** Roll back the current transaction.
63      */

64     void rollback();
65
66     /** Returns whether there is a transaction currently active.
67      * @return boolean
68      */

69     boolean isActive();
70     
71     /** If true, at commit instances retain their values and the instances
72      * transition to persistent-nontransactional.
73      * <P>Setting this flag also sets the NontransactionalRead flag.
74      * @param retainValues the value of the retainValues property
75      */

76     void setRetainValues(boolean retainValues);
77     
78     /** If true, at commit time instances retain their field values.
79      * @return the value of the retainValues property
80      */

81     boolean getRetainValues();
82     
83     /** If true, at rollback instances restore their values and the instances
84      * transition to persistent-nontransactional.
85      * @param restoreValues the value of the restoreValues property
86      */

87     void setRestoreValues(boolean restoreValues);
88     
89     /** If true, at rollback time instances restore their field values.
90      * @return the value of the restoreValues property
91      */

92     boolean getRestoreValues();
93     
94     /** Optimistic transactions do not hold data store locks until commit time.
95      * @param optimistic the value of the Optimistic flag.
96      */

97     void setOptimistic(boolean optimistic);
98     
99     /** Optimistic transactions do not hold data store locks until commit time.
100      * @return the value of the Optimistic property.
101      */

102     boolean getOptimistic();
103
104     /** If this flag is set to true, then queries and navigation are allowed
105      * without an active transaction
106      * @param flag the value of the nontransactionalRead property.
107      */

108     void setNontransactionalRead (boolean flag);
109     
110     /** If this flag is set to true, then queries and navigation are allowed
111      * without an active transaction
112      * @return the value of the nontransactionalRead property.
113      */

114     boolean getNontransactionalRead ();
115
116     /** The user can specify a Synchronization instance to be notified on
117      * transaction completions. The beforeCompletion method is called prior
118      * to flushing instances to the data store.
119      *
120      * <P>The afterCompletion method is called after performing the data store
121      * commit operation.
122      * @param sync the Synchronization instance to be notified; null for none
123      */

124     void setSynchronization(Synchronization sync);
125     
126     /** The user-specified Synchronization instance for this Transaction instance.
127      * @return the user-specified Synchronization instance.
128      */

129     Synchronization getSynchronization();
130
131    /**
132     * Sets the number of seconds to wait for a query statement
133     * to execute in the datastore associated with this Transaction instance
134     * @param timeout new timout value in seconds; zero means unlimited
135     */

136    void setQueryTimeout (int timeout);
137
138    /**
139     * Gets the number of seconds to wait for a query statement
140     * to execute in the datastore associated with this Transaction instance
141     * @return timout value in seconds; zero means unlimited
142     */

143    int getQueryTimeout ();
144    
145    /**
146     * Sets the number of seconds to wait for an update statement
147     * to execute in the datastore associated with this Transaction instance
148     * @param timeout new timout value in seconds; zero means unlimited
149     */

150    void setUpdateTimeout (int timeout);
151    
152    /**
153     * Gets the number of seconds to wait for an update statement
154     * to execute in the datastore associated with this Transaction instance
155     * @return timout value in seconds; zero means unlimited
156     */

157    int getUpdateTimeout();
158
159     /** The Tranansaction instance is always associated with exactly one
160      * PersistenceManager.
161      *
162      * @return the PersistenceManager for this Transaction instance
163      */

164     PersistenceManager getPersistenceManager();
165 }
166
Popular Tags