db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krist...@apache.org
Subject svn commit: r642707 - in /db/derby/code/trunk/java: drda/org/apache/derby/impl/drda/ engine/org/apache/derby/iapi/jdbc/ engine/org/apache/derby/impl/jdbc/
Date Sun, 30 Mar 2008 11:09:06 GMT
Author: kristwaa
Date: Sun Mar 30 04:09:05 2008
New Revision: 642707

URL: http://svn.apache.org/viewvc?rev=642707&view=rev
Log:
DERBY-3576: Merge EngineBlob and EngineClob into a single interface.
Merged the two interfaces and added the method 'free'. There was no need to sepearate between
a Blob and a Clob where the interface was used. If such a need arises, one should consider
adding new interfaces extending EngineLOB.
Patch file: derby-3576-1b-enginelob_interface.diff 

Added:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/EngineLOB.java   (with props)
Removed:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/EngineBlob.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/EngineClob.java
Modified:
    db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedBlob.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedClob.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/LOBStoredProcedure.java

Modified: db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java?rev=642707&r1=642706&r2=642707&view=diff
==============================================================================
--- db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java (original)
+++ db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java Sun Mar 30
04:09:05 2008
@@ -57,8 +57,7 @@
 import org.apache.derby.iapi.services.stream.HeaderPrintWriter;
 import org.apache.derby.iapi.tools.i18n.LocalizedResource;
 import org.apache.derby.iapi.jdbc.AuthenticationService;
-import org.apache.derby.iapi.jdbc.EngineBlob;
-import org.apache.derby.iapi.jdbc.EngineClob;
+import org.apache.derby.iapi.jdbc.EngineLOB;
 import org.apache.derby.iapi.jdbc.EngineResultSet;
 import org.apache.derby.impl.jdbc.EmbedSQLException;
 import org.apache.derby.impl.jdbc.Util;
@@ -7574,10 +7573,8 @@
 						writer.writeLDBytes((byte[]) val, index);
 					break;
 				case DRDAConstants.DRDA_TYPE_NLOBLOC:
-					writer.writeInt(((EngineBlob) val).getLocator());
-					break;
 				case DRDAConstants.DRDA_TYPE_NCLOBLOC:
-					writer.writeInt(((EngineClob) val).getLocator());
+					writer.writeInt(((EngineLOB)val).getLocator());
 					break;
 				default:
 					if (SanityManager.DEBUG) 

Added: db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/EngineLOB.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/EngineLOB.java?rev=642707&view=auto
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/EngineLOB.java (added)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/EngineLOB.java Sun Mar 30 04:09:05
2008
@@ -0,0 +1,54 @@
+/*
+
+   Derby - Class org.apache.derby.iapi.jdbc.EngineLOB
+
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to you under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
+ */
+
+package org.apache.derby.iapi.jdbc;
+
+import java.sql.SQLException;
+
+/**
+ * Additional methods the embedded engine exposes on all of its large object
+ * (LOB) implementations.
+ * <p>
+ * An internal API only, mainly for the network server.
+ * <p>
+ * <b>Implementation note</b>: If a new method is needed, that only applies to
+ * one specific large object type (for instance a Blob), one should consider
+ * creating a new interface that extends from this one.
+ */
+public interface EngineLOB {
+
+    /**
+     * Returns LOB locator key.
+     * <p>
+     * The key can be used with {@link EmbedConnection#getLobMapping} to
+     * retrieve this LOB at a later time.
+     *
+     * @return Locator key for this LOB
+     */
+    public int getLocator();
+
+    /**
+     * Frees all resources assoicated with this LOB.
+     *
+     * @throws SQLException if an error occurs during cleanup
+     */
+    public void free() throws SQLException;
+}

Propchange: db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/EngineLOB.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedBlob.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedBlob.java?rev=642707&r1=642706&r2=642707&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedBlob.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedBlob.java Sun Mar 30 04:09:05
2008
@@ -24,7 +24,7 @@
 
 import org.apache.derby.iapi.reference.SQLState;
 import org.apache.derby.iapi.error.StandardException;
-import org.apache.derby.iapi.jdbc.EngineBlob;
+import org.apache.derby.iapi.jdbc.EngineLOB;
 import org.apache.derby.iapi.services.monitor.Monitor;
 import org.apache.derby.iapi.services.sanity.SanityManager;
 import org.apache.derby.iapi.types.DataValueDescriptor;
@@ -68,7 +68,7 @@
 
  */
 
-final class EmbedBlob extends ConnectionChild implements Blob, EngineBlob
+final class EmbedBlob extends ConnectionChild implements Blob, EngineLOB
 {
     // blob is either materialized or still in stream
     private boolean         materialized;

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedClob.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedClob.java?rev=642707&r1=642706&r2=642707&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedClob.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedClob.java Sun Mar 30 04:09:05
2008
@@ -24,7 +24,7 @@
 
 import org.apache.derby.iapi.reference.SQLState;
 import org.apache.derby.iapi.error.StandardException;
-import org.apache.derby.iapi.jdbc.EngineClob;
+import org.apache.derby.iapi.jdbc.EngineLOB;
 import org.apache.derby.iapi.services.sanity.SanityManager;
 import org.apache.derby.iapi.types.DataValueDescriptor;
 import org.apache.derby.iapi.types.Resetable;
@@ -67,7 +67,7 @@
         new update methods can safely be added into implementation.
    </UL>
  */
-final class EmbedClob extends ConnectionChild implements Clob, EngineClob
+final class EmbedClob extends ConnectionChild implements Clob, EngineLOB
 {
 
     /**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java?rev=642707&r1=642706&r2=642707&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection.java Sun Mar
30 04:09:05 2008
@@ -69,6 +69,7 @@
 import java.util.Properties;
 import java.util.Iterator;
 
+import org.apache.derby.iapi.jdbc.EngineLOB;
 import org.apache.derby.impl.jdbc.authentication.NoneAuthenticationServiceImpl;
 
 /**
@@ -2902,15 +2903,9 @@
 		//the hash table object to null.
 		HashMap map = rootConnection.lobHashMap;
 		if (map != null) {
-			for (Iterator it = map.values().iterator(); it.hasNext(); ) {
-				Object obj = it.next();
-				if (obj instanceof EmbedClob) {
-					((EmbedClob) obj).free();
-				} else if (obj instanceof EmbedBlob) {
-					((EmbedBlob) obj).free();
-				} else if (SanityManager.DEBUG) {
-					SanityManager.THROWASSERT("Unexpected value: " + obj);
-				}
+            Iterator it = map.values().iterator();
+            while (it.hasNext()) {
+                ((EngineLOB)it.next()).free();
 			}
 			map.clear();
 		}

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/LOBStoredProcedure.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/LOBStoredProcedure.java?rev=642707&r1=642706&r2=642707&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/LOBStoredProcedure.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/LOBStoredProcedure.java Sun
Mar 30 04:09:05 2008
@@ -26,8 +26,7 @@
 import java.sql.DriverManager;
 import java.sql.SQLException;
 
-import org.apache.derby.iapi.jdbc.EngineBlob;
-import org.apache.derby.iapi.jdbc.EngineClob;
+import org.apache.derby.iapi.jdbc.EngineLOB;
 import org.apache.derby.iapi.reference.SQLState;
 
 /**
@@ -43,7 +42,7 @@
      * @throws SQLException
      */
     public static int CLOBCREATELOCATOR() throws SQLException {
-        EngineClob clob = (EngineClob) getEmbedConnection().createClob();
+        EngineLOB clob = (EngineLOB)getEmbedConnection().createClob();
         return clob.getLocator();
     }
 
@@ -203,7 +202,7 @@
      * @throws SQLException
      */
     public static int BLOBCREATELOCATOR() throws SQLException {
-        EngineBlob blob = (EngineBlob) getEmbedConnection().createBlob();
+        EngineLOB blob = (EngineLOB)getEmbedConnection().createBlob();
         return blob.getLocator();
     }
 



Mime
View raw message