KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > impl > store > raw > xact > InternalXact


1 /*
2
3    Derby - Class org.apache.derby.impl.store.raw.xact.InternalXact
4
5    Licensed to the Apache Software Foundation (ASF) under one or more
6    contributor license agreements. See the NOTICE file distributed with
7    this work for additional information regarding copyright ownership.
8    The ASF licenses this file to you under the Apache License, Version 2.0
9    (the "License"); you may not use this file except in compliance with
10    the License. You may obtain a copy of the License at
11
12       http://www.apache.org/licenses/LICENSE-2.0
13
14    Unless required by applicable law or agreed to in writing, software
15    distributed under the License is distributed on an "AS IS" BASIS,
16    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17    See the License for the specific language governing permissions and
18    limitations under the License.
19
20  */

21
22 package org.apache.derby.impl.store.raw.xact;
23
24 import org.apache.derby.iapi.reference.SQLState;
25
26 import org.apache.derby.iapi.store.raw.Transaction;
27
28 import org.apache.derby.iapi.store.raw.log.LogFactory;
29
30 import org.apache.derby.iapi.store.raw.data.DataFactory;
31
32 import org.apache.derby.iapi.error.StandardException;
33
34 import org.apache.derby.iapi.services.sanity.SanityManager;
35
36 import java.io.ObjectInput JavaDoc;
37
38 /**
39
40     @see Xact
41
42 */

43 public class InternalXact extends Xact
44 {
45
46     /*
47     ** Constructor
48     */

49
50     protected InternalXact(
51     XactFactory xactFactory,
52     LogFactory logFactory,
53     DataFactory dataFactory)
54     {
55         super(xactFactory, logFactory, dataFactory, false, null);
56
57         // always want to hold latches & containers open past the commit/abort
58
setPostComplete();
59     }
60
61     /*
62     ** Methods of Transaction
63     */

64
65   
66     /**
67         Savepoints are not supported in internal transactions.
68
69         @exception StandardException A transaction exception is thrown to
70                                       disallow savepoints.
71
72         @see Transaction#setSavePoint
73     */

74     public int setSavePoint(String JavaDoc name, Object JavaDoc kindOfSavepoint)
75         throws StandardException
76     {
77         throw StandardException.newException(
78                 SQLState.XACT_NOT_SUPPORTED_IN_INTERNAL_XACT);
79     }
80
81
82     /*
83     ** Methods of RawTransaction
84     */

85     /**
86         Internal transactions don't allow logical operations.
87
88         @exception StandardException A transaction exception is thrown to
89                                      disallow logical operations.
90
91         @see org.apache.derby.iapi.store.raw.xact.RawTransaction#recoveryRollbackFirst
92     */

93     
94      public void checkLogicalOperationOK()
95          throws StandardException
96      {
97         throw StandardException.newException(
98                 SQLState.XACT_NOT_SUPPORTED_IN_INTERNAL_XACT);
99      }
100
101     /**
102         Yes, we do want to be rolled back first in recovery.
103
104         @see org.apache.derby.iapi.store.raw.xact.RawTransaction#recoveryRollbackFirst
105     */

106     public boolean recoveryRollbackFirst()
107     {
108         return true;
109     }
110
111     /*
112     ** Implementation specific methods
113     */

114
115     /**
116      * @param commitOrAbort to commit or abort
117      *
118      * @exception StandardException on error
119      */

120     protected void doComplete(Integer JavaDoc commitOrAbort)
121         throws StandardException
122     {
123
124         // release our latches on an abort
125
// keep everything on a commit
126
if (commitOrAbort.equals(ABORT))
127             super.doComplete(commitOrAbort);
128     }
129
130     protected void setIdleState()
131     {
132
133         super.setIdleState();
134
135         // Quiesce mode never denies an internal transaction from going active, don't
136
// have to worry about that
137
if (countObservers() != 0)
138         {
139             try
140             {
141                 super.setActiveState();
142             }
143             catch (StandardException se)
144             {
145                 if (SanityManager.DEBUG)
146                     SanityManager.THROWASSERT("unexpected exception: " + se);
147             }
148         }
149     }
150 }
151
Popular Tags