KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > impl > store > raw > data > DropOnCommit


1 /*
2
3    Derby - Class org.apache.derby.impl.store.raw.data.DropOnCommit
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.data;
23
24
25 import org.apache.derby.iapi.store.raw.ContainerHandle;
26 import org.apache.derby.iapi.store.raw.ContainerLock;
27 import org.apache.derby.iapi.store.raw.Page;
28 import org.apache.derby.iapi.store.raw.LockingPolicy;
29 import org.apache.derby.iapi.store.raw.RecordHandle;
30
31 import org.apache.derby.iapi.store.raw.data.RawContainerHandle;
32 import org.apache.derby.iapi.store.raw.log.LogInstant;
33 import org.apache.derby.iapi.store.raw.xact.RawTransaction;
34
35 import org.apache.derby.iapi.services.locks.Lockable;
36
37 import org.apache.derby.catalog.UUID;
38
39 import org.apache.derby.iapi.error.StandardException;
40
41 import org.apache.derby.iapi.services.sanity.SanityManager;
42 import org.apache.derby.iapi.store.raw.ContainerKey;
43
44 import java.util.Observable JavaDoc;
45
46 /**
47     Drop a table on a commit or abort
48 */

49
50 public class DropOnCommit extends ContainerActionOnCommit {
51
52     protected boolean isStreamContainer = false;
53
54     /*
55     ** Methods of Observer
56     */

57
58     public DropOnCommit(ContainerKey identity) {
59
60         super(identity);
61     }
62
63     public DropOnCommit(ContainerKey identity, boolean isStreamContainer) {
64
65         super(identity);
66         this.isStreamContainer = isStreamContainer;
67     }
68
69     /**
70         Called when the transaction is about to complete.
71
72         @see java.util.Observer#update
73     */

74     public void update(Observable JavaDoc obj, Object JavaDoc arg) {
75         if (SanityManager.DEBUG) {
76             if (arg == null)
77                 SanityManager.THROWASSERT("still on observr list " + this);
78         }
79
80         if (arg.equals(RawTransaction.COMMIT) || arg.equals(RawTransaction.ABORT)) {
81
82             RawTransaction xact = (RawTransaction) obj;
83
84             try {
85                 if (this.isStreamContainer)
86                     xact.dropStreamContainer(identity.getSegmentId(), identity.getContainerId());
87                 else
88                     xact.dropContainer(identity);
89             } catch (StandardException se) {
90                 xact.setObserverException(se);
91             }
92
93             obj.deleteObserver(this);
94         }
95     }
96 }
97
Popular Tags