1 | /* |
2 | |
3 | Derby - Class org.apache.derby.impl.store.raw.xact.InternalXact |
4 | |
5 | Copyright 1997, 2004 The Apache Software Foundation or its licensors, as applicable. |
6 | |
7 | Licensed under the Apache License, Version 2.0 (the "License"); |
8 | you may not use this file except in compliance with the License. |
9 | You may obtain a copy of the License at |
10 | |
11 | http://www.apache.org/licenses/LICENSE-2.0 |
12 | |
13 | Unless required by applicable law or agreed to in writing, software |
14 | distributed under the License is distributed on an "AS IS" BASIS, |
15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
16 | See the License for the specific language governing permissions and |
17 | limitations under the License. |
18 | |
19 | */ |
20 | |
21 | package org.apache.derby.impl.store.raw.xact; |
22 | |
23 | import org.apache.derby.iapi.reference.SQLState; |
24 | |
25 | import org.apache.derby.iapi.store.raw.Transaction; |
26 | |
27 | import org.apache.derby.iapi.store.raw.log.LogFactory; |
28 | |
29 | import org.apache.derby.iapi.store.raw.data.DataFactory; |
30 | |
31 | import org.apache.derby.iapi.error.StandardException; |
32 | |
33 | import org.apache.derby.iapi.services.sanity.SanityManager; |
34 | |
35 | import java.io.ObjectInput; |
36 | |
37 | /** |
38 | |
39 | @see Xact |
40 | |
41 | */ |
42 | public class InternalXact extends Xact |
43 | { |
44 | |
45 | /* |
46 | ** Constructor |
47 | */ |
48 | |
49 | protected InternalXact( |
50 | XactFactory xactFactory, |
51 | LogFactory logFactory, |
52 | DataFactory dataFactory) |
53 | { |
54 | super(xactFactory, logFactory, dataFactory, false, null); |
55 | |
56 | // always want to hold latches & containers open past the commit/abort |
57 | setPostComplete(); |
58 | } |
59 | |
60 | /* |
61 | ** Methods of Transaction |
62 | */ |
63 | |
64 | |
65 | /** |
66 | Savepoints are not supported in internal transactions. |
67 | |
68 | @exception StandardException A transaction exception is thrown to |
69 | disallow savepoints. |
70 | |
71 | @see Transaction#setSavePoint |
72 | */ |
73 | public int setSavePoint(String name, Object kindOfSavepoint) |
74 | throws StandardException |
75 | { |
76 | throw StandardException.newException( |
77 | SQLState.XACT_NOT_SUPPORTED_IN_INTERNAL_XACT); |
78 | } |
79 | |
80 | |
81 | /* |
82 | ** Methods of RawTransaction |
83 | */ |
84 | /** |
85 | Internal transactions don't allow logical operations. |
86 | |
87 | @exception StandardException A transaction exception is thrown to |
88 | disallow logical operations. |
89 | |
90 | @see org.apache.derby.iapi.store.raw.xact.RawTransaction#recoveryRollbackFirst |
91 | */ |
92 | |
93 | public void checkLogicalOperationOK() |
94 | throws StandardException |
95 | { |
96 | throw StandardException.newException( |
97 | SQLState.XACT_NOT_SUPPORTED_IN_INTERNAL_XACT); |
98 | } |
99 | |
100 | /** |
101 | Yes, we do want to be rolled back first in recovery. |
102 | |
103 | @see org.apache.derby.iapi.store.raw.xact.RawTransaction#recoveryRollbackFirst |
104 | */ |
105 | public boolean recoveryRollbackFirst() |
106 | { |
107 | return true; |
108 | } |
109 | |
110 | /* |
111 | ** Implementation specific methods |
112 | */ |
113 | |
114 | /** |
115 | * @param commitOrAbort to commit or abort |
116 | * |
117 | * @exception StandardException on error |
118 | */ |
119 | protected void doComplete(Integer commitOrAbort) |
120 | throws StandardException |
121 | { |
122 | |
123 | // release our latches on an abort |
124 | // keep everything on a commit |
125 | if (commitOrAbort.equals(ABORT)) |
126 | super.doComplete(commitOrAbort); |
127 | } |
128 | |
129 | protected void setIdleState() |
130 | { |
131 | |
132 | super.setIdleState(); |
133 | |
134 | // Quiesce mode never denies an internal transaction from going active, don't |
135 | // have to worry about that |
136 | if (countObservers() != 0) |
137 | { |
138 | try |
139 | { |
140 | super.setActiveState(); |
141 | } |
142 | catch (StandardException se) |
143 | { |
144 | if (SanityManager.DEBUG) |
145 | SanityManager.THROWASSERT("unexpected exception: " + se); |
146 | } |
147 | } |
148 | } |
149 | } |