Adding JMCR-Stable version
[Benchmarks_CSolver.git] / JMCR-Stable / real-world application / derby-10.3.2.1 / java / engine / org / apache / derby / impl / store / raw / data / DropOnCommit.java
diff --git a/JMCR-Stable/real-world application/derby-10.3.2.1/java/engine/org/apache/derby/impl/store/raw/data/DropOnCommit.java b/JMCR-Stable/real-world application/derby-10.3.2.1/java/engine/org/apache/derby/impl/store/raw/data/DropOnCommit.java
new file mode 100644 (file)
index 0000000..1dad948
--- /dev/null
@@ -0,0 +1,96 @@
+/*\r
+\r
+   Derby - Class org.apache.derby.impl.store.raw.data.DropOnCommit\r
+\r
+   Licensed to the Apache Software Foundation (ASF) under one or more\r
+   contributor license agreements.  See the NOTICE file distributed with\r
+   this work for additional information regarding copyright ownership.\r
+   The ASF licenses this file to you under the Apache License, Version 2.0\r
+   (the "License"); you may not use this file except in compliance with\r
+   the License.  You may obtain a copy of the License at\r
+\r
+      http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+   Unless required by applicable law or agreed to in writing, software\r
+   distributed under the License is distributed on an "AS IS" BASIS,\r
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+   See the License for the specific language governing permissions and\r
+   limitations under the License.\r
+\r
+ */\r
+\r
+package org.apache.derby.impl.store.raw.data;\r
+\r
+\r
+import org.apache.derby.iapi.store.raw.ContainerHandle;\r
+import org.apache.derby.iapi.store.raw.ContainerLock;\r
+import org.apache.derby.iapi.store.raw.Page;\r
+import org.apache.derby.iapi.store.raw.LockingPolicy;\r
+import org.apache.derby.iapi.store.raw.RecordHandle;\r
+\r
+import org.apache.derby.iapi.store.raw.data.RawContainerHandle;\r
+import org.apache.derby.iapi.store.raw.log.LogInstant;\r
+import org.apache.derby.iapi.store.raw.xact.RawTransaction;\r
+\r
+import org.apache.derby.iapi.services.locks.Lockable;\r
+\r
+import org.apache.derby.catalog.UUID;\r
+\r
+import org.apache.derby.iapi.error.StandardException;\r
+\r
+import org.apache.derby.iapi.services.sanity.SanityManager;\r
+import org.apache.derby.iapi.store.raw.ContainerKey;\r
+\r
+import java.util.Observable;\r
+\r
+/**\r
+       Drop a table on a commit or abort\r
+*/\r
+\r
+public class DropOnCommit extends ContainerActionOnCommit {\r
+\r
+       protected boolean isStreamContainer = false;\r
+\r
+       /*\r
+       **      Methods of Observer\r
+       */\r
+\r
+       public DropOnCommit(ContainerKey identity) {\r
+\r
+               super(identity);\r
+       }\r
+\r
+       public DropOnCommit(ContainerKey identity, boolean isStreamContainer) {\r
+\r
+               super(identity);\r
+               this.isStreamContainer = isStreamContainer;\r
+       }\r
+\r
+       /**\r
+               Called when the transaction is about to complete.\r
+\r
+               @see java.util.Observer#update\r
+       */\r
+       public void update(Observable obj, Object arg) {\r
+               if (SanityManager.DEBUG) {\r
+                       if (arg == null)\r
+                               SanityManager.THROWASSERT("still on observr list " + this);\r
+               }\r
+\r
+               if (arg.equals(RawTransaction.COMMIT) || arg.equals(RawTransaction.ABORT)) {\r
+\r
+                       RawTransaction xact = (RawTransaction) obj;\r
+\r
+                       try {\r
+                               if (this.isStreamContainer)\r
+                                       xact.dropStreamContainer(identity.getSegmentId(), identity.getContainerId());\r
+                               else\r
+                                       xact.dropContainer(identity);\r
+                       } catch (StandardException se) {\r
+                               xact.setObserverException(se);\r
+                       }\r
+\r
+                       obj.deleteObserver(this);\r
+               }\r
+       }\r
+}\r