01: /*
02:
03: Derby - Class org.apache.derby.impl.store.raw.data.DropOnCommit
04:
05: Licensed to the Apache Software Foundation (ASF) under one or more
06: contributor license agreements. See the NOTICE file distributed with
07: this work for additional information regarding copyright ownership.
08: The ASF licenses this file to you under the Apache License, Version 2.0
09: (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.data;
23:
24: import org.apache.derby.iapi.store.raw.ContainerHandle;
25: import org.apache.derby.iapi.store.raw.ContainerLock;
26: import org.apache.derby.iapi.store.raw.Page;
27: import org.apache.derby.iapi.store.raw.LockingPolicy;
28: import org.apache.derby.iapi.store.raw.RecordHandle;
29:
30: import org.apache.derby.iapi.store.raw.data.RawContainerHandle;
31: import org.apache.derby.iapi.store.raw.log.LogInstant;
32: import org.apache.derby.iapi.store.raw.xact.RawTransaction;
33:
34: import org.apache.derby.iapi.services.locks.Lockable;
35:
36: import org.apache.derby.catalog.UUID;
37:
38: import org.apache.derby.iapi.error.StandardException;
39:
40: import org.apache.derby.iapi.services.sanity.SanityManager;
41: import org.apache.derby.iapi.store.raw.ContainerKey;
42:
43: import java.util.Observable;
44:
45: /**
46: Drop a table on a commit or abort
47: */
48:
49: public class DropOnCommit extends ContainerActionOnCommit {
50:
51: protected boolean isStreamContainer = false;
52:
53: /*
54: ** Methods of Observer
55: */
56:
57: public DropOnCommit(ContainerKey identity) {
58:
59: super (identity);
60: }
61:
62: public DropOnCommit(ContainerKey identity, boolean isStreamContainer) {
63:
64: super (identity);
65: this .isStreamContainer = isStreamContainer;
66: }
67:
68: /**
69: Called when the transaction is about to complete.
70:
71: @see java.util.Observer#update
72: */
73: public void update(Observable obj, Object arg) {
74: if (SanityManager.DEBUG) {
75: if (arg == null)
76: SanityManager.THROWASSERT("still on observr list "
77: + this );
78: }
79:
80: if (arg.equals(RawTransaction.COMMIT)
81: || arg.equals(RawTransaction.ABORT)) {
82:
83: RawTransaction xact = (RawTransaction) obj;
84:
85: try {
86: if (this .isStreamContainer)
87: xact.dropStreamContainer(identity.getSegmentId(),
88: identity.getContainerId());
89: else
90: xact.dropContainer(identity);
91: } catch (StandardException se) {
92: xact.setObserverException(se);
93: }
94:
95: obj.deleteObserver(this);
96: }
97: }
98: }
|