You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openjpa.apache.org by pc...@apache.org on 2006/06/28 21:34:40 UTC

svn commit: r417856 [7/22] - in /incubator/openjpa/trunk/openjpa-lib: java/ main/ main/java/ main/java/org/apache/openjpa/lib/ant/ main/java/org/apache/openjpa/lib/conf/ main/java/org/apache/openjpa/lib/jdbc/ main/java/org/apache/openjpa/lib/log/ main/...

Modified: incubator/openjpa/trunk/openjpa-lib/main/java/org/apache/openjpa/lib/jdbc/DelegatingResultSet.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/main/java/org/apache/openjpa/lib/jdbc/DelegatingResultSet.java?rev=417856&r1=415364&r2=417856&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/main/java/org/apache/openjpa/lib/jdbc/DelegatingResultSet.java (original)
+++ incubator/openjpa/trunk/openjpa-lib/main/java/org/apache/openjpa/lib/jdbc/DelegatingResultSet.java Wed Jun 28 12:34:33 2006
@@ -15,1070 +15,660 @@
  */
 package org.apache.openjpa.lib.jdbc;
 
+import org.apache.openjpa.lib.util.*;
+import org.apache.openjpa.lib.util.Closeable;
 
 import java.io.*;
+
 import java.math.*;
+
 import java.net.*;
+
 import java.sql.*;
 import java.sql.Date;
-import java.util.*;
 
-import org.apache.openjpa.lib.util.Closeable;
+import java.util.*;
 
 
 /**
- *	<p>Wrapper around an existing result set.  Subclasses can override the
- *	methods whose behavior they mean to change.  The <code>equals</code> and 
- *	<code>hashCode</code> methods pass through to the base underlying data 
- *	store statement.</p>
+ *  <p>Wrapper around an existing result set.  Subclasses can override the
+ *  methods whose behavior they mean to change.  The <code>equals</code> and
+ *  <code>hashCode</code> methods pass through to the base underlying data
+ *  store statement.</p>
  *
- *	@author 	Marc Prud'hommeaux
+ *  @author Marc Prud'hommeaux
  */
-public class DelegatingResultSet
-	implements ResultSet, Closeable
-{
-	private final ResultSet 			_rs;
-	private final DelegatingResultSet	_del;
-	private final Statement 			_stmnt;
-
-
-	public DelegatingResultSet (ResultSet rs, Statement stmnt)
-	{
-		if (rs == null)
-			throw new IllegalArgumentException ();
-
-		_stmnt = stmnt;
-		_rs = rs;
-		if (_rs instanceof DelegatingResultSet)
-			_del = (DelegatingResultSet) _rs;
-		else
-			_del = null;
-	}
-
-
-	/**
-	 *	Return the wrapped result set.
-	 */
-	public ResultSet getDelegate ()
-	{
-		return _rs;
-	}
-
-
-	/**
-	 *	Return the inner-most wrapped delegate.
-	 */
-	public ResultSet getInnermostDelegate ()
-	{
-		return (_del == null) ? _rs : _del.getInnermostDelegate ();
-	}
-
-
-	public int hashCode ()
-	{
-		return _rs.hashCode ();
-	}
-
-
-	public boolean equals (Object other)
-	{
-		if (other == this)
-			return true;
-		if (other instanceof DelegatingResultSet)
-			other = ((DelegatingResultSet) other).getInnermostDelegate ();
-		return getInnermostDelegate ().equals (other);
-	}
-
-
-	public String toString ()
-	{
-		StringBuffer buf = new StringBuffer ("resultset ").append (hashCode ());
-		appendInfo (buf);
-		return buf.toString ();
-	}
-
-
-	protected void appendInfo (StringBuffer buf)
-	{
-		if (_del != null)
-			_del.appendInfo (buf);
-	}
-
-
-    public boolean next ()
-		throws SQLException
-	{
-		return _rs.next ();
-	}
-
-
-    public void close ()
-		throws SQLException
-	{
-		_rs.close ();
-	}
-
-
-    public boolean wasNull ()
-		throws SQLException
-	{
-		return _rs.wasNull ();
-	}
-
-
-    public String getString (int a)
-		throws SQLException
-	{
-		return _rs.getString (a);
-	}
-
-
-    public boolean getBoolean (int a)
-		throws SQLException
-	{
-		return _rs.getBoolean (a);
-	}
-
-
-    public byte getByte (int a)
-		throws SQLException
-	{
-		return _rs.getByte (a);
-	}
-
-
-    public short getShort (int a)
-		throws SQLException
-	{
-		return _rs.getShort (a);
-	}
-
-
-    public int getInt (int a)
-		throws SQLException
-	{
-		return _rs.getInt (a);
-	}
-
-
-    public long getLong (int a)
-		throws SQLException
-	{
-		return _rs.getLong (a);
-	}
-
-
-    public float getFloat (int a)
-		throws SQLException
-	{
-		return _rs.getFloat (a);
-	}
-
-
-    public double getDouble (int a)
-		throws SQLException
-	{
-		return _rs.getDouble (a);
-	}
-
-
-    public BigDecimal getBigDecimal (int a, int b)
-		throws SQLException
-	{
-		return _rs.getBigDecimal (a, b);
-	}
-
-
-    public byte[] getBytes (int a)
-		throws SQLException
-	{
-		return _rs.getBytes (a);
-	}
-
-
-    public Date getDate (int a)
-		throws SQLException
-	{
-		return _rs.getDate (a);
-	}
-
-
-    public Time getTime (int a)
-		throws SQLException
-	{
-		return _rs.getTime (a);
-	}
-
-
-    public Timestamp getTimestamp (int a)
-		throws SQLException
-	{
-		return _rs.getTimestamp (a);
-	}
-
-
-    public InputStream getAsciiStream (int a)
-		throws SQLException
-	{
-		return _rs.getAsciiStream (a);
-	}
-
-
-    public InputStream getUnicodeStream (int a)
-		throws SQLException
-	{
-		return _rs.getUnicodeStream (a);
-	}
-
-
-    public InputStream getBinaryStream (int a)
-		throws SQLException
-	{
-		return _rs.getBinaryStream (a);
-	}
-
-
-    public String getString (String a)
-		throws SQLException
-	{
-		return _rs.getString (a);
-	}
-
-
-    public boolean getBoolean (String a)
-		throws SQLException
-	{
-		return _rs.getBoolean (a);
-	}
-
-
-    public byte getByte (String a)
-		throws SQLException
-	{
-		return _rs.getByte (a);
-	}
-
-
-    public short getShort (String a)
-		throws SQLException
-	{
-		return _rs.getShort (a);
-	}
-
-
-    public int getInt (String a)
-		throws SQLException
-	{
-		return _rs.getInt (a);
-	}
-
-
-    public long getLong (String a)
-		throws SQLException
-	{
-		return _rs.getLong (a);
-	}
-
-
-    public float getFloat (String a)
-		throws SQLException
-	{
-		return _rs.getFloat (a);
-	}
-
-
-    public double getDouble (String a)
-		throws SQLException
-	{
-		return _rs.getDouble (a);
-	}
-
-
-    public BigDecimal getBigDecimal (String a, int b)
-		throws SQLException
-	{
-		return _rs.getBigDecimal (a, b);
-	}
-
-
-    public byte[] getBytes (String a)
-		throws SQLException
-	{
-		return _rs.getBytes (a);
-	}
-
-
-    public Date getDate (String a)
-		throws SQLException
-	{
-		return _rs.getDate (a);
-	}
-
-
-    public Time getTime (String a)
-		throws SQLException
-	{
-		return _rs.getTime (a);
-	}
-
-
-    public Timestamp getTimestamp (String a)
-		throws SQLException
-	{
-		return _rs.getTimestamp (a);
-	}
-
-
-    public InputStream getAsciiStream (String a)
-		throws SQLException
-	{
-		return _rs.getAsciiStream (a);
-	}
-
-
-    public InputStream getUnicodeStream (String a)
-		throws SQLException
-	{
-		return _rs.getUnicodeStream (a);
-	}
-
-
-    public InputStream getBinaryStream (String a)
-		throws SQLException
-	{
-		return _rs.getBinaryStream (a);
-	}
-
-
-    public SQLWarning getWarnings ()
-		throws SQLException
-	{
-		return _rs.getWarnings ();
-	}
-
-
-    public void clearWarnings ()
-		throws SQLException
-	{
-		_rs.clearWarnings ();
-	}
-
-
-    public String getCursorName ()
-		throws SQLException
-	{
-		return _rs.getCursorName ();
-	}
-
-
-    public ResultSetMetaData getMetaData ()
-		throws SQLException
-	{
-		return _rs.getMetaData ();
-	}
-
-
-    public Object getObject (int a)
-		throws SQLException
-	{
-		return _rs.getObject (a);
-	}
-
-
-    public Object getObject (String a)
-		throws SQLException
-	{
-		return _rs.getObject (a);
-	}
-
-
-    public int findColumn (String a)
-		throws SQLException
-	{
-		return _rs.findColumn (a);
-	}
-
-
-    public Reader getCharacterStream (int a)
-		throws SQLException
-	{
-		return _rs.getCharacterStream (a);
-	}
-
-
-    public Reader getCharacterStream (String a)
-		throws SQLException
-	{
-		return _rs.getCharacterStream (a);
-	}
-
-
-    public BigDecimal getBigDecimal (int a)
-		throws SQLException
-	{
-		return _rs.getBigDecimal (a);
-	}
-
-
-    public BigDecimal getBigDecimal (String a)
-		throws SQLException
-	{
-		return _rs.getBigDecimal (a);
-	}
-
-
-    public boolean isBeforeFirst ()
-		throws SQLException
-	{
-		return _rs.isBeforeFirst ();
-	}
-
-
-    public boolean isAfterLast ()
-		throws SQLException
-	{
-		return _rs.isAfterLast ();
-	}
-
-
-    public boolean isFirst ()
-		throws SQLException
-	{
-		return _rs.isFirst ();
-	}
-
-
-    public boolean isLast ()
-		throws SQLException
-	{
-		return _rs.isLast ();
-	}
-
-
-    public void beforeFirst ()
-		throws SQLException
-	{
-		_rs.beforeFirst ();
-	}
-
-
-    public void afterLast ()
-		throws SQLException
-	{
-		_rs.afterLast ();
-	}
-
-
-    public boolean first ()
-		throws SQLException
-	{
-		return _rs.first ();
-	}
-
-
-    public boolean last ()
-		throws SQLException
-	{
-		return _rs.last ();
-	}
-
-
-    public int getRow ()
-		throws SQLException
-	{
-		return _rs.getRow ();
-	}
-
-
-    public boolean absolute (int a)
-		throws SQLException
-	{
-		return _rs.absolute (a);
-	}
-
-
-    public boolean relative (int a)
-		throws SQLException
-	{
-		return _rs.relative (a);
-	}
-
-
-    public boolean previous ()
-		throws SQLException
-	{
-		return _rs.previous ();
-	}
-
-
-    public void setFetchDirection (int a)
-		throws SQLException
-	{
-		_rs.setFetchDirection (a);
-	}
-
-
-    public int getFetchDirection ()
-		throws SQLException
-	{
-		return _rs.getFetchDirection ();
-	}
-
-
-    public void setFetchSize (int a)
-		throws SQLException
-	{
-		_rs.setFetchSize (a);
-	}
-
-
-    public int getFetchSize ()
-		throws SQLException
-	{
-		return _rs.getFetchSize ();
-	}
-
-
-    public int getType ()
-		throws SQLException
-	{
-		return _rs.getType ();
-	}
-
-
-    public int getConcurrency ()
-		throws SQLException
-	{
-		return _rs.getConcurrency ();
-	}
-
-
-    public boolean rowUpdated ()
-		throws SQLException
-	{
-		return _rs.rowUpdated ();
-	}
-
-
-    public boolean rowInserted ()
-		throws SQLException
-	{
-		return _rs.rowInserted ();
-	}
-
-
-    public boolean rowDeleted ()
-		throws SQLException
-	{
-		return _rs.rowDeleted ();
-	}
-
-
-    public void updateNull (int a)
-		throws SQLException
-	{
-		_rs.updateNull (a);
-	}
-
-
-    public void updateBoolean (int a, boolean b)
-		throws SQLException
-	{
-		_rs.updateBoolean (a, b);
-	}
-
-
-    public void updateByte (int a, byte b)
-		throws SQLException
-	{
-		_rs.updateByte (a, b);
-	}
-
-
-    public void updateShort (int a, short b)
-		throws SQLException
-	{
-		_rs.updateShort (a, b);
-	}
-
-
-    public void updateInt (int a, int b)
-		throws SQLException
-	{
-		_rs.updateInt (a, b);
-	}
-
-
-    public void updateLong (int a, long b)
-		throws SQLException
-	{
-		_rs.updateLong (a, b);
-	}
-
-
-    public void updateFloat (int a, float b)
-		throws SQLException
-	{
-		_rs.updateFloat (a, b);
-	}
-
-
-    public void updateDouble (int a, double b)
-		throws SQLException
-	{
-		_rs.updateDouble (a, b);
-	}
-
-
-    public void updateBigDecimal (int a, BigDecimal b)
-		throws SQLException
-	{
-		_rs.updateBigDecimal (a, b);
-	}
-
-
-    public void updateString (int a, String b)
-		throws SQLException
-	{
-		_rs.updateString (a, b);
-	}
-
-
-    public void updateBytes (int a, byte[] b)
-		throws SQLException
-	{
-		_rs.updateBytes (a, b);
-	}
-
-
-    public void updateDate (int a, Date b)
-		throws SQLException
-	{
-		_rs.updateDate (a, b);
-	}
-
-
-    public void updateTime (int a, Time b)
-		throws SQLException
-	{
-		_rs.updateTime (a, b);
-	}
-
-
-    public void updateTimestamp (int a, Timestamp b)
-		throws SQLException
-	{
-		_rs.updateTimestamp (a, b);
-	}
-
-
-    public void updateAsciiStream (int a, InputStream in, int b)
-		throws SQLException
-	{
-		_rs.updateAsciiStream (a, in, b);
-	}
-
-
-    public void updateBinaryStream (int a, InputStream in, int b)
-		throws SQLException
-	{
-		_rs.updateBinaryStream (a, in, b);
-	}
-
-
-    public void updateCharacterStream (int a, Reader reader, int b)
-		throws SQLException
-	{
-		_rs.updateCharacterStream (a, reader, b);
-	}
-
-
-    public void updateObject (int a, Object ob, int b)
-		throws SQLException
-	{
-		_rs.updateObject (a, ob, b);
-	}
-
-
-    public void updateObject (int a, Object ob)
-		throws SQLException
-	{
-		_rs.updateObject (a, ob);
-	}
-
-
-    public void updateNull (String a)
-		throws SQLException
-	{
-		_rs.updateNull (a);
-	}
-
-
-    public void updateBoolean (String a, boolean b)
-		throws SQLException
-	{
-		_rs.updateBoolean (a, b);
-	}
-
-
-    public void updateByte (String a, byte b)
-		throws SQLException
-	{
-		_rs.updateByte (a, b);
-	}
-
-
-    public void updateShort (String a, short b)
-		throws SQLException
-	{
-		_rs.updateShort (a, b);
-	}
-
-
-    public void updateInt (String a, int b)
-		throws SQLException
-	{
-		_rs.updateInt (a, b);
-	}
-
-
-    public void updateLong (String a, long b)
-		throws SQLException
-	{
-		_rs.updateLong (a, b);
-	}
-
-
-    public void updateFloat (String a, float b)
-		throws SQLException
-	{
-		_rs.updateFloat (a, b);
-	}
-
-
-    public void updateDouble (String a, double b)
-		throws SQLException
-	{
-		_rs.updateDouble (a, b);
-	}
-
-
-    public void updateBigDecimal (String a, BigDecimal b)
-		throws SQLException
-	{
-		_rs.updateBigDecimal (a, b);
-	}
-
-
-    public void updateString (String a, String b)
-		throws SQLException
-	{
-		_rs.updateString (a, b);
-	}
-
-
-    public void updateBytes (String a, byte[] b)
-		throws SQLException
-	{
-		_rs.updateBytes (a, b);
-	}
-
-
-    public void updateDate (String a, Date b)
-		throws SQLException
-	{
-		_rs.updateDate (a, b);
-	}
-
-
-    public void updateTime (String a, Time b)
-		throws SQLException
-	{
-		_rs.updateTime (a, b);
-	}
-
-
-    public void updateTimestamp (String a, Timestamp b)
-		throws SQLException
-	{
-		_rs.updateTimestamp (a, b);
-	}
-
-
-    public void updateAsciiStream (String a, InputStream in, int b)
-		throws SQLException
-	{
-		_rs.updateAsciiStream (a, in, b);
-	}
-
-
-    public void updateBinaryStream (String a, InputStream in, int b)
-		throws SQLException
-	{
-		_rs.updateBinaryStream (a, in, b);
-	}
-
-
-    public void updateCharacterStream (String a, Reader reader, int b)
-		throws SQLException
-	{
-		_rs.updateCharacterStream (a, reader, b);
-	}
-
-
-    public void updateObject (String a, Object ob, int b)
-		throws SQLException
-	{
-		_rs.updateObject (a, ob, b);
-	}
-
-
-    public void updateObject (String a, Object b)
-		throws SQLException
-	{
-		_rs.updateObject (a, b);
-	}
-
-
-    public void insertRow ()
-		throws SQLException
-	{
-		_rs.insertRow ();
-	}
-
-
-    public void updateRow ()
-		throws SQLException
-	{
-		_rs.updateRow ();
-	}
-
-
-    public void deleteRow ()
-		throws SQLException
-	{
-		_rs.deleteRow ();
-	}
-
-
-    public void refreshRow ()
-		throws SQLException
-	{
-		_rs.refreshRow ();
-	}
-
-
-    public void cancelRowUpdates ()
-		throws SQLException
-	{
-		_rs.cancelRowUpdates ();
-	}
-
-
-    public void moveToInsertRow ()
-		throws SQLException
-	{
-		_rs.moveToInsertRow ();
-	}
-
-
-    public void moveToCurrentRow ()
-		throws SQLException
-	{
-		_rs.moveToCurrentRow ();
-	}
-
-
-    public Statement getStatement ()
-		throws SQLException
-	{
-		return _stmnt;
-	}
-
-
-    public Object getObject (int a, Map b)
-		throws SQLException
-	{
-		return _rs.getObject (a, b);
-	}
-
-
-    public Ref getRef (int a)
-		throws SQLException
-	{
-		return _rs.getRef (a);
-	}
-
-
-    public Blob getBlob (int a)
-		throws SQLException
-	{
-		return _rs.getBlob (a);
-	}
-
-
-    public Clob getClob (int a)
-		throws SQLException
-	{
-		return _rs.getClob (a);
-	}
-
-
-    public Array getArray (int a)
-		throws SQLException
-	{
-		return _rs.getArray (a);
-	}
-
-
-    public Object getObject (String a, Map b)
-		throws SQLException
-	{
-		return _rs.getObject (a, b);
-	}
-
-
-    public Ref getRef (String a)
-		throws SQLException
-	{
-		return _rs.getRef (a);
-	}
-
-
-    public Blob getBlob (String a)
-		throws SQLException
-	{
-		return _rs.getBlob (a);
-	}
-
-
-    public Clob getClob (String a)
-		throws SQLException
-	{
-		return _rs.getClob (a);
-	}
-
-
-    public Array getArray (String a)
-		throws SQLException
-	{
-		return _rs.getArray (a);
-	}
-
-
-    public Date getDate (int a, Calendar b)
-		throws SQLException
-	{
-		return _rs.getDate (a, b);
-	}
-
-
-    public Date getDate (String a, Calendar b)
-		throws SQLException
-	{
-		return _rs.getDate (a, b);
-	}
-
-
-    public Time getTime (int a, Calendar b)
-		throws SQLException
-	{
-		return _rs.getTime (a, b);
-	}
-
-
-    public Time getTime (String a, Calendar b)
-		throws SQLException
-	{
-		return _rs.getTime (a, b);
-	}
-
-
-    public Timestamp getTimestamp (int a, Calendar b)
-		throws SQLException
-	{
-		return _rs.getTimestamp (a, b);
-	}
-
-
-    public Timestamp getTimestamp (String a, Calendar b)
-		throws SQLException
-	{
-		return _rs.getTimestamp (a, b);
-	}
-
-
-	// JDBC 3.0 (unsupported) method follow; these are required to be able 
-	// to compile against JDK 1.4
-
-
-	public URL getURL (int column)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public URL getURL (String columnName)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public void updateRef (int column, Ref ref)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public void updateRef (String columnName, Ref ref)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public void updateBlob (int column, Blob blob)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public void updateBlob (String columnName, Blob blob)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public void updateClob (int column, Clob clob)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public void updateClob (String columnName, Clob clob)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public void updateArray (int column, Array array)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public void updateArray (String columnName, Array array)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
+public class DelegatingResultSet implements ResultSet, Closeable {
+    private final ResultSet _rs;
+    private final DelegatingResultSet _del;
+    private final Statement _stmnt;
+
+    public DelegatingResultSet(ResultSet rs, Statement stmnt) {
+        if (rs == null) {
+            throw new IllegalArgumentException();
+        }
+
+        _stmnt = stmnt;
+        _rs = rs;
+
+        if (_rs instanceof DelegatingResultSet) {
+            _del = (DelegatingResultSet) _rs;
+        } else {
+            _del = null;
+        }
+    }
+
+    /**
+     *  Return the wrapped result set.
+     */
+    public ResultSet getDelegate() {
+        return _rs;
+    }
+
+    /**
+     *  Return the inner-most wrapped delegate.
+     */
+    public ResultSet getInnermostDelegate() {
+        return (_del == null) ? _rs : _del.getInnermostDelegate();
+    }
+
+    public int hashCode() {
+        return _rs.hashCode();
+    }
+
+    public boolean equals(Object other) {
+        if (other == this) {
+            return true;
+        }
+
+        if (other instanceof DelegatingResultSet) {
+            other = ((DelegatingResultSet) other).getInnermostDelegate();
+        }
+
+        return getInnermostDelegate().equals(other);
+    }
+
+    public String toString() {
+        StringBuffer buf = new StringBuffer("resultset ").append(hashCode());
+        appendInfo(buf);
+
+        return buf.toString();
+    }
+
+    protected void appendInfo(StringBuffer buf) {
+        if (_del != null) {
+            _del.appendInfo(buf);
+        }
+    }
+
+    public boolean next() throws SQLException {
+        return _rs.next();
+    }
+
+    public void close() throws SQLException {
+        _rs.close();
+    }
+
+    public boolean wasNull() throws SQLException {
+        return _rs.wasNull();
+    }
+
+    public String getString(int a) throws SQLException {
+        return _rs.getString(a);
+    }
+
+    public boolean getBoolean(int a) throws SQLException {
+        return _rs.getBoolean(a);
+    }
+
+    public byte getByte(int a) throws SQLException {
+        return _rs.getByte(a);
+    }
+
+    public short getShort(int a) throws SQLException {
+        return _rs.getShort(a);
+    }
+
+    public int getInt(int a) throws SQLException {
+        return _rs.getInt(a);
+    }
+
+    public long getLong(int a) throws SQLException {
+        return _rs.getLong(a);
+    }
+
+    public float getFloat(int a) throws SQLException {
+        return _rs.getFloat(a);
+    }
+
+    public double getDouble(int a) throws SQLException {
+        return _rs.getDouble(a);
+    }
+
+    public BigDecimal getBigDecimal(int a, int b) throws SQLException {
+        return _rs.getBigDecimal(a, b);
+    }
+
+    public byte[] getBytes(int a) throws SQLException {
+        return _rs.getBytes(a);
+    }
+
+    public Date getDate(int a) throws SQLException {
+        return _rs.getDate(a);
+    }
+
+    public Time getTime(int a) throws SQLException {
+        return _rs.getTime(a);
+    }
+
+    public Timestamp getTimestamp(int a) throws SQLException {
+        return _rs.getTimestamp(a);
+    }
+
+    public InputStream getAsciiStream(int a) throws SQLException {
+        return _rs.getAsciiStream(a);
+    }
+
+    public InputStream getUnicodeStream(int a) throws SQLException {
+        return _rs.getUnicodeStream(a);
+    }
+
+    public InputStream getBinaryStream(int a) throws SQLException {
+        return _rs.getBinaryStream(a);
+    }
+
+    public String getString(String a) throws SQLException {
+        return _rs.getString(a);
+    }
+
+    public boolean getBoolean(String a) throws SQLException {
+        return _rs.getBoolean(a);
+    }
+
+    public byte getByte(String a) throws SQLException {
+        return _rs.getByte(a);
+    }
+
+    public short getShort(String a) throws SQLException {
+        return _rs.getShort(a);
+    }
+
+    public int getInt(String a) throws SQLException {
+        return _rs.getInt(a);
+    }
+
+    public long getLong(String a) throws SQLException {
+        return _rs.getLong(a);
+    }
+
+    public float getFloat(String a) throws SQLException {
+        return _rs.getFloat(a);
+    }
+
+    public double getDouble(String a) throws SQLException {
+        return _rs.getDouble(a);
+    }
+
+    public BigDecimal getBigDecimal(String a, int b) throws SQLException {
+        return _rs.getBigDecimal(a, b);
+    }
+
+    public byte[] getBytes(String a) throws SQLException {
+        return _rs.getBytes(a);
+    }
+
+    public Date getDate(String a) throws SQLException {
+        return _rs.getDate(a);
+    }
+
+    public Time getTime(String a) throws SQLException {
+        return _rs.getTime(a);
+    }
+
+    public Timestamp getTimestamp(String a) throws SQLException {
+        return _rs.getTimestamp(a);
+    }
+
+    public InputStream getAsciiStream(String a) throws SQLException {
+        return _rs.getAsciiStream(a);
+    }
+
+    public InputStream getUnicodeStream(String a) throws SQLException {
+        return _rs.getUnicodeStream(a);
+    }
+
+    public InputStream getBinaryStream(String a) throws SQLException {
+        return _rs.getBinaryStream(a);
+    }
+
+    public SQLWarning getWarnings() throws SQLException {
+        return _rs.getWarnings();
+    }
+
+    public void clearWarnings() throws SQLException {
+        _rs.clearWarnings();
+    }
+
+    public String getCursorName() throws SQLException {
+        return _rs.getCursorName();
+    }
+
+    public ResultSetMetaData getMetaData() throws SQLException {
+        return _rs.getMetaData();
+    }
+
+    public Object getObject(int a) throws SQLException {
+        return _rs.getObject(a);
+    }
+
+    public Object getObject(String a) throws SQLException {
+        return _rs.getObject(a);
+    }
+
+    public int findColumn(String a) throws SQLException {
+        return _rs.findColumn(a);
+    }
+
+    public Reader getCharacterStream(int a) throws SQLException {
+        return _rs.getCharacterStream(a);
+    }
+
+    public Reader getCharacterStream(String a) throws SQLException {
+        return _rs.getCharacterStream(a);
+    }
+
+    public BigDecimal getBigDecimal(int a) throws SQLException {
+        return _rs.getBigDecimal(a);
+    }
+
+    public BigDecimal getBigDecimal(String a) throws SQLException {
+        return _rs.getBigDecimal(a);
+    }
+
+    public boolean isBeforeFirst() throws SQLException {
+        return _rs.isBeforeFirst();
+    }
+
+    public boolean isAfterLast() throws SQLException {
+        return _rs.isAfterLast();
+    }
+
+    public boolean isFirst() throws SQLException {
+        return _rs.isFirst();
+    }
+
+    public boolean isLast() throws SQLException {
+        return _rs.isLast();
+    }
+
+    public void beforeFirst() throws SQLException {
+        _rs.beforeFirst();
+    }
+
+    public void afterLast() throws SQLException {
+        _rs.afterLast();
+    }
+
+    public boolean first() throws SQLException {
+        return _rs.first();
+    }
+
+    public boolean last() throws SQLException {
+        return _rs.last();
+    }
+
+    public int getRow() throws SQLException {
+        return _rs.getRow();
+    }
+
+    public boolean absolute(int a) throws SQLException {
+        return _rs.absolute(a);
+    }
+
+    public boolean relative(int a) throws SQLException {
+        return _rs.relative(a);
+    }
+
+    public boolean previous() throws SQLException {
+        return _rs.previous();
+    }
+
+    public void setFetchDirection(int a) throws SQLException {
+        _rs.setFetchDirection(a);
+    }
+
+    public int getFetchDirection() throws SQLException {
+        return _rs.getFetchDirection();
+    }
+
+    public void setFetchSize(int a) throws SQLException {
+        _rs.setFetchSize(a);
+    }
+
+    public int getFetchSize() throws SQLException {
+        return _rs.getFetchSize();
+    }
+
+    public int getType() throws SQLException {
+        return _rs.getType();
+    }
+
+    public int getConcurrency() throws SQLException {
+        return _rs.getConcurrency();
+    }
+
+    public boolean rowUpdated() throws SQLException {
+        return _rs.rowUpdated();
+    }
+
+    public boolean rowInserted() throws SQLException {
+        return _rs.rowInserted();
+    }
+
+    public boolean rowDeleted() throws SQLException {
+        return _rs.rowDeleted();
+    }
+
+    public void updateNull(int a) throws SQLException {
+        _rs.updateNull(a);
+    }
+
+    public void updateBoolean(int a, boolean b) throws SQLException {
+        _rs.updateBoolean(a, b);
+    }
+
+    public void updateByte(int a, byte b) throws SQLException {
+        _rs.updateByte(a, b);
+    }
+
+    public void updateShort(int a, short b) throws SQLException {
+        _rs.updateShort(a, b);
+    }
+
+    public void updateInt(int a, int b) throws SQLException {
+        _rs.updateInt(a, b);
+    }
+
+    public void updateLong(int a, long b) throws SQLException {
+        _rs.updateLong(a, b);
+    }
+
+    public void updateFloat(int a, float b) throws SQLException {
+        _rs.updateFloat(a, b);
+    }
+
+    public void updateDouble(int a, double b) throws SQLException {
+        _rs.updateDouble(a, b);
+    }
+
+    public void updateBigDecimal(int a, BigDecimal b) throws SQLException {
+        _rs.updateBigDecimal(a, b);
+    }
+
+    public void updateString(int a, String b) throws SQLException {
+        _rs.updateString(a, b);
+    }
+
+    public void updateBytes(int a, byte[] b) throws SQLException {
+        _rs.updateBytes(a, b);
+    }
+
+    public void updateDate(int a, Date b) throws SQLException {
+        _rs.updateDate(a, b);
+    }
+
+    public void updateTime(int a, Time b) throws SQLException {
+        _rs.updateTime(a, b);
+    }
+
+    public void updateTimestamp(int a, Timestamp b) throws SQLException {
+        _rs.updateTimestamp(a, b);
+    }
+
+    public void updateAsciiStream(int a, InputStream in, int b)
+        throws SQLException {
+        _rs.updateAsciiStream(a, in, b);
+    }
+
+    public void updateBinaryStream(int a, InputStream in, int b)
+        throws SQLException {
+        _rs.updateBinaryStream(a, in, b);
+    }
+
+    public void updateCharacterStream(int a, Reader reader, int b)
+        throws SQLException {
+        _rs.updateCharacterStream(a, reader, b);
+    }
+
+    public void updateObject(int a, Object ob, int b) throws SQLException {
+        _rs.updateObject(a, ob, b);
+    }
+
+    public void updateObject(int a, Object ob) throws SQLException {
+        _rs.updateObject(a, ob);
+    }
+
+    public void updateNull(String a) throws SQLException {
+        _rs.updateNull(a);
+    }
+
+    public void updateBoolean(String a, boolean b) throws SQLException {
+        _rs.updateBoolean(a, b);
+    }
+
+    public void updateByte(String a, byte b) throws SQLException {
+        _rs.updateByte(a, b);
+    }
+
+    public void updateShort(String a, short b) throws SQLException {
+        _rs.updateShort(a, b);
+    }
+
+    public void updateInt(String a, int b) throws SQLException {
+        _rs.updateInt(a, b);
+    }
+
+    public void updateLong(String a, long b) throws SQLException {
+        _rs.updateLong(a, b);
+    }
+
+    public void updateFloat(String a, float b) throws SQLException {
+        _rs.updateFloat(a, b);
+    }
+
+    public void updateDouble(String a, double b) throws SQLException {
+        _rs.updateDouble(a, b);
+    }
+
+    public void updateBigDecimal(String a, BigDecimal b)
+        throws SQLException {
+        _rs.updateBigDecimal(a, b);
+    }
+
+    public void updateString(String a, String b) throws SQLException {
+        _rs.updateString(a, b);
+    }
+
+    public void updateBytes(String a, byte[] b) throws SQLException {
+        _rs.updateBytes(a, b);
+    }
+
+    public void updateDate(String a, Date b) throws SQLException {
+        _rs.updateDate(a, b);
+    }
+
+    public void updateTime(String a, Time b) throws SQLException {
+        _rs.updateTime(a, b);
+    }
+
+    public void updateTimestamp(String a, Timestamp b)
+        throws SQLException {
+        _rs.updateTimestamp(a, b);
+    }
+
+    public void updateAsciiStream(String a, InputStream in, int b)
+        throws SQLException {
+        _rs.updateAsciiStream(a, in, b);
+    }
+
+    public void updateBinaryStream(String a, InputStream in, int b)
+        throws SQLException {
+        _rs.updateBinaryStream(a, in, b);
+    }
+
+    public void updateCharacterStream(String a, Reader reader, int b)
+        throws SQLException {
+        _rs.updateCharacterStream(a, reader, b);
+    }
+
+    public void updateObject(String a, Object ob, int b)
+        throws SQLException {
+        _rs.updateObject(a, ob, b);
+    }
+
+    public void updateObject(String a, Object b) throws SQLException {
+        _rs.updateObject(a, b);
+    }
+
+    public void insertRow() throws SQLException {
+        _rs.insertRow();
+    }
+
+    public void updateRow() throws SQLException {
+        _rs.updateRow();
+    }
+
+    public void deleteRow() throws SQLException {
+        _rs.deleteRow();
+    }
+
+    public void refreshRow() throws SQLException {
+        _rs.refreshRow();
+    }
+
+    public void cancelRowUpdates() throws SQLException {
+        _rs.cancelRowUpdates();
+    }
+
+    public void moveToInsertRow() throws SQLException {
+        _rs.moveToInsertRow();
+    }
+
+    public void moveToCurrentRow() throws SQLException {
+        _rs.moveToCurrentRow();
+    }
+
+    public Statement getStatement() throws SQLException {
+        return _stmnt;
+    }
+
+    public Object getObject(int a, Map b) throws SQLException {
+        return _rs.getObject(a, b);
+    }
+
+    public Ref getRef(int a) throws SQLException {
+        return _rs.getRef(a);
+    }
+
+    public Blob getBlob(int a) throws SQLException {
+        return _rs.getBlob(a);
+    }
+
+    public Clob getClob(int a) throws SQLException {
+        return _rs.getClob(a);
+    }
+
+    public Array getArray(int a) throws SQLException {
+        return _rs.getArray(a);
+    }
+
+    public Object getObject(String a, Map b) throws SQLException {
+        return _rs.getObject(a, b);
+    }
+
+    public Ref getRef(String a) throws SQLException {
+        return _rs.getRef(a);
+    }
+
+    public Blob getBlob(String a) throws SQLException {
+        return _rs.getBlob(a);
+    }
+
+    public Clob getClob(String a) throws SQLException {
+        return _rs.getClob(a);
+    }
+
+    public Array getArray(String a) throws SQLException {
+        return _rs.getArray(a);
+    }
+
+    public Date getDate(int a, Calendar b) throws SQLException {
+        return _rs.getDate(a, b);
+    }
+
+    public Date getDate(String a, Calendar b) throws SQLException {
+        return _rs.getDate(a, b);
+    }
+
+    public Time getTime(int a, Calendar b) throws SQLException {
+        return _rs.getTime(a, b);
+    }
+
+    public Time getTime(String a, Calendar b) throws SQLException {
+        return _rs.getTime(a, b);
+    }
+
+    public Timestamp getTimestamp(int a, Calendar b) throws SQLException {
+        return _rs.getTimestamp(a, b);
+    }
+
+    public Timestamp getTimestamp(String a, Calendar b)
+        throws SQLException {
+        return _rs.getTimestamp(a, b);
+    }
+
+    // JDBC 3.0 (unsupported) method follow; these are required to be able 
+    // to compile against JDK 1.4
+    public URL getURL(int column) throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public URL getURL(String columnName) throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public void updateRef(int column, Ref ref) throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public void updateRef(String columnName, Ref ref) throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public void updateBlob(int column, Blob blob) throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public void updateBlob(String columnName, Blob blob)
+        throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public void updateClob(int column, Clob clob) throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public void updateClob(String columnName, Clob clob)
+        throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public void updateArray(int column, Array array) throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public void updateArray(String columnName, Array array)
+        throws SQLException {
+        throw new UnsupportedOperationException();
+    }
 }
-

Modified: incubator/openjpa/trunk/openjpa-lib/main/java/org/apache/openjpa/lib/jdbc/DelegatingStatement.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/main/java/org/apache/openjpa/lib/jdbc/DelegatingStatement.java?rev=417856&r1=415364&r2=417856&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/main/java/org/apache/openjpa/lib/jdbc/DelegatingStatement.java (original)
+++ incubator/openjpa/trunk/openjpa-lib/main/java/org/apache/openjpa/lib/jdbc/DelegatingStatement.java Wed Jun 28 12:34:33 2006
@@ -15,388 +15,266 @@
  */
 package org.apache.openjpa.lib.jdbc;
 
+import org.apache.openjpa.lib.util.*;
 
 import java.sql.*;
 
-import org.apache.openjpa.lib.util.*;
-
 
 /**
- *	<p>Wrapper around an existing statement.  Subclasses can override the
- *	methods whose behavior they mean to change.  The <code>equals</code> and 
- *	<code>hashCode</code> methods pass through to the base underlying data 
- *	store statement.</p>
+ *  <p>Wrapper around an existing statement.  Subclasses can override the
+ *  methods whose behavior they mean to change.  The <code>equals</code> and
+ *  <code>hashCode</code> methods pass through to the base underlying data
+ *  store statement.</p>
  *
- *	@author		Abe White
+ *  @author Abe White
  */
-public class DelegatingStatement
-	implements Statement, Closeable
-{
-	private final Statement 			_stmnt;
-	private final DelegatingStatement	_del;
-	private final Connection			_conn;
-
-
-	public DelegatingStatement (Statement stmnt, Connection conn)
-	{
-		_conn = conn;
-		_stmnt = stmnt;
-		if (stmnt instanceof DelegatingStatement)
-			_del = (DelegatingStatement) stmnt;
-		else
-			_del = null;
-	}
-
-
-	protected ResultSet wrapResult (ResultSet rs, boolean wrap)
-	{
-		if (!wrap || rs == null)
-			return rs;
-		return new DelegatingResultSet (rs, this);
-	}
-
-
-	/**
-	 *	Return the wrapped statement.
-	 */
-	public Statement getDelegate ()
-	{
-		return _stmnt;
-	}
-
-
-	/**
-	 *	Return the base underlying data store statement.
-	 */
-	public Statement getInnermostDelegate ()
-	{
-		return (_del == null) ? _stmnt : _del.getInnermostDelegate ();
-	}
-
-
-	public int hashCode ()
-	{
-		return getInnermostDelegate ().hashCode ();
-	}
-
-
-	public boolean equals (Object other)
-	{
-		if (other == this)
-			return true;
-		if (other instanceof DelegatingStatement)
-			other = ((DelegatingStatement) other).getInnermostDelegate ();
-		return getInnermostDelegate ().equals (other);
-	}
-
-
-	public String toString ()
-	{
-		StringBuffer buf = new StringBuffer ("stmnt ").append (hashCode ());
-		appendInfo (buf);
-		return buf.toString ();
-	}
-
-
-	protected void appendInfo (StringBuffer buf)
-	{
-		if (_del != null)
-			_del.appendInfo (buf);
-	}
-
-
-    public ResultSet executeQuery (String str) 
-		throws SQLException
-	{
-		return executeQuery (str, true);
-	}
-
-
-	/**
- 	 *	Execute the query, with the option of not wrapping it in a
-	 *	{@link DelegatingResultSet}, which is the default.
-	 */
-	protected ResultSet executeQuery (String sql, boolean wrap)
-		throws SQLException
-	{
-		ResultSet rs;
-		if (_del != null)
-			rs = _del.executeQuery (sql, false);
-		else
-			rs = _stmnt.executeQuery (sql);
-		return wrapResult (rs, wrap);
-	}
-
-
-    public int executeUpdate (String str) 
-		throws SQLException
-	{
-		return _stmnt.executeUpdate (str);
-	}
-
-
-    public boolean execute (String str) 
-		throws SQLException
-	{
-		return _stmnt.execute (str);
-	}
-
-
-    public void close () 
-		throws SQLException
-	{
-		_stmnt.close ();
-	}
-
-
-    public int getMaxFieldSize () 
-		throws SQLException
-	{
-		return _stmnt.getMaxFieldSize ();
-	}
-
-
-    public void setMaxFieldSize (int i) 
-		throws SQLException
-	{
-		_stmnt.setMaxFieldSize (i);
-	}
-
-
-    public int getMaxRows () 
-		throws SQLException
-	{
-		return _stmnt.getMaxRows ();
-	}
-
-
-    public void setMaxRows (int i) 
-		throws SQLException
-	{
-		_stmnt.setMaxRows (i);
-	}
-
-
-    public void setEscapeProcessing (boolean bool) 
-		throws SQLException
-	{
-		_stmnt.setEscapeProcessing (bool);
-	}
-
-
-    public int getQueryTimeout () 
-		throws SQLException
-	{
-		return _stmnt.getQueryTimeout ();
-	}
-
-
-    public void setQueryTimeout (int i) 
-		throws SQLException
-	{
-		_stmnt.setQueryTimeout (i);
-	}
-
-
-    public void cancel () 
-		throws SQLException
-	{
-		_stmnt.cancel ();
-	}
-
-
-    public SQLWarning getWarnings () 
-		throws SQLException
-	{
-		return _stmnt.getWarnings ();
-	}
-
-
-    public void clearWarnings () 
-		throws SQLException
-	{
-		_stmnt.clearWarnings ();
-	}
-
-
-    public void setCursorName (String str) 
-		throws SQLException
-	{
-		_stmnt.setCursorName (str);
-	}
-
-
-    public ResultSet getResultSet () 
-		throws SQLException
-	{
-		return getResultSet (true);
-	}
-
-
-	/**
- 	 *	Get the last result set, with the option of not wrapping it in a
-	 *	{@link DelegatingResultSet}, which is the default.
-	 */
-	protected ResultSet getResultSet (boolean wrap)
-		throws SQLException
-	{
-		ResultSet rs;
-		if (_del != null)
-			rs = _del.getResultSet (false);
-		else
-			rs = _stmnt.getResultSet ();
-		return wrapResult (rs, wrap);
-	}
-
-
-    public int getUpdateCount () 
-		throws SQLException
-	{
-		return _stmnt.getUpdateCount ();
-	}
-
-
-    public boolean getMoreResults () 
-		throws SQLException
-	{
-		return _stmnt.getMoreResults ();
-	}
-
-
-    public void setFetchDirection (int i) 
-		throws SQLException
-	{
-		_stmnt.setFetchDirection (i);
-	}
-
-
-    public int getFetchDirection () 
-		throws SQLException
-	{
-		return _stmnt.getFetchDirection ();
-	}
-
-
-    public void setFetchSize (int i) 
-		throws SQLException
-	{
-		_stmnt.setFetchSize (i);
-	}
-
-
-    public int getFetchSize () 
-		throws SQLException
-	{
-		return _stmnt.getFetchSize ();
-	}
-
-
-    public int getResultSetConcurrency () 
-		throws SQLException
-	{
-		return _stmnt.getResultSetConcurrency ();
-	}
-
-
-    public int getResultSetType () 
-		throws SQLException
-	{
-		return _stmnt.getResultSetType ();
-	}
-
-
-    public void addBatch (String str) 
-		throws SQLException
-	{
-		_stmnt.addBatch (str);
-	}
-
-
-    public void clearBatch () 
-		throws SQLException
-	{
-		_stmnt.clearBatch ();
-	}
-
-
-    public int[] executeBatch ()
-		throws SQLException
-	{
-		return _stmnt.executeBatch ();
-	}
-
-
-    public Connection getConnection () 
-		throws SQLException
-	{
-		return _conn;
-	}
-
-
-	// JDBC 3.0 (unsupported) method follow; these are required to be able 
-	// to compile against JDK 1.4
-
-
-	public boolean getMoreResults (int i)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public ResultSet getGeneratedKeys ()
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public int executeUpdate (String s, int i) 
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public int executeUpdate (String s, int[] ia)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public int executeUpdate (String s, String[] sa)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public boolean execute (String s, int i)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public boolean execute (String s, int[] ia)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public boolean execute (String s, String[] sa)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public int getResultSetHoldability ()
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
+public class DelegatingStatement implements Statement, Closeable {
+    private final Statement _stmnt;
+    private final DelegatingStatement _del;
+    private final Connection _conn;
+
+    public DelegatingStatement(Statement stmnt, Connection conn) {
+        _conn = conn;
+        _stmnt = stmnt;
+
+        if (stmnt instanceof DelegatingStatement) {
+            _del = (DelegatingStatement) stmnt;
+        } else {
+            _del = null;
+        }
+    }
+
+    protected ResultSet wrapResult(ResultSet rs, boolean wrap) {
+        if (!wrap || (rs == null)) {
+            return rs;
+        }
+
+        return new DelegatingResultSet(rs, this);
+    }
+
+    /**
+     *  Return the wrapped statement.
+     */
+    public Statement getDelegate() {
+        return _stmnt;
+    }
+
+    /**
+     *  Return the base underlying data store statement.
+     */
+    public Statement getInnermostDelegate() {
+        return (_del == null) ? _stmnt : _del.getInnermostDelegate();
+    }
+
+    public int hashCode() {
+        return getInnermostDelegate().hashCode();
+    }
+
+    public boolean equals(Object other) {
+        if (other == this) {
+            return true;
+        }
+
+        if (other instanceof DelegatingStatement) {
+            other = ((DelegatingStatement) other).getInnermostDelegate();
+        }
+
+        return getInnermostDelegate().equals(other);
+    }
+
+    public String toString() {
+        StringBuffer buf = new StringBuffer("stmnt ").append(hashCode());
+        appendInfo(buf);
+
+        return buf.toString();
+    }
+
+    protected void appendInfo(StringBuffer buf) {
+        if (_del != null) {
+            _del.appendInfo(buf);
+        }
+    }
+
+    public ResultSet executeQuery(String str) throws SQLException {
+        return executeQuery(str, true);
+    }
+
+    /**
+      *  Execute the query, with the option of not wrapping it in a
+     *  {@link DelegatingResultSet}, which is the default.
+     */
+    protected ResultSet executeQuery(String sql, boolean wrap)
+        throws SQLException {
+        ResultSet rs;
+
+        if (_del != null) {
+            rs = _del.executeQuery(sql, false);
+        } else {
+            rs = _stmnt.executeQuery(sql);
+        }
+
+        return wrapResult(rs, wrap);
+    }
+
+    public int executeUpdate(String str) throws SQLException {
+        return _stmnt.executeUpdate(str);
+    }
+
+    public boolean execute(String str) throws SQLException {
+        return _stmnt.execute(str);
+    }
+
+    public void close() throws SQLException {
+        _stmnt.close();
+    }
+
+    public int getMaxFieldSize() throws SQLException {
+        return _stmnt.getMaxFieldSize();
+    }
+
+    public void setMaxFieldSize(int i) throws SQLException {
+        _stmnt.setMaxFieldSize(i);
+    }
+
+    public int getMaxRows() throws SQLException {
+        return _stmnt.getMaxRows();
+    }
+
+    public void setMaxRows(int i) throws SQLException {
+        _stmnt.setMaxRows(i);
+    }
+
+    public void setEscapeProcessing(boolean bool) throws SQLException {
+        _stmnt.setEscapeProcessing(bool);
+    }
+
+    public int getQueryTimeout() throws SQLException {
+        return _stmnt.getQueryTimeout();
+    }
+
+    public void setQueryTimeout(int i) throws SQLException {
+        _stmnt.setQueryTimeout(i);
+    }
+
+    public void cancel() throws SQLException {
+        _stmnt.cancel();
+    }
+
+    public SQLWarning getWarnings() throws SQLException {
+        return _stmnt.getWarnings();
+    }
+
+    public void clearWarnings() throws SQLException {
+        _stmnt.clearWarnings();
+    }
+
+    public void setCursorName(String str) throws SQLException {
+        _stmnt.setCursorName(str);
+    }
+
+    public ResultSet getResultSet() throws SQLException {
+        return getResultSet(true);
+    }
+
+    /**
+      *  Get the last result set, with the option of not wrapping it in a
+     *  {@link DelegatingResultSet}, which is the default.
+     */
+    protected ResultSet getResultSet(boolean wrap) throws SQLException {
+        ResultSet rs;
+
+        if (_del != null) {
+            rs = _del.getResultSet(false);
+        } else {
+            rs = _stmnt.getResultSet();
+        }
+
+        return wrapResult(rs, wrap);
+    }
+
+    public int getUpdateCount() throws SQLException {
+        return _stmnt.getUpdateCount();
+    }
+
+    public boolean getMoreResults() throws SQLException {
+        return _stmnt.getMoreResults();
+    }
+
+    public void setFetchDirection(int i) throws SQLException {
+        _stmnt.setFetchDirection(i);
+    }
+
+    public int getFetchDirection() throws SQLException {
+        return _stmnt.getFetchDirection();
+    }
+
+    public void setFetchSize(int i) throws SQLException {
+        _stmnt.setFetchSize(i);
+    }
+
+    public int getFetchSize() throws SQLException {
+        return _stmnt.getFetchSize();
+    }
+
+    public int getResultSetConcurrency() throws SQLException {
+        return _stmnt.getResultSetConcurrency();
+    }
+
+    public int getResultSetType() throws SQLException {
+        return _stmnt.getResultSetType();
+    }
+
+    public void addBatch(String str) throws SQLException {
+        _stmnt.addBatch(str);
+    }
+
+    public void clearBatch() throws SQLException {
+        _stmnt.clearBatch();
+    }
+
+    public int[] executeBatch() throws SQLException {
+        return _stmnt.executeBatch();
+    }
+
+    public Connection getConnection() throws SQLException {
+        return _conn;
+    }
+
+    // JDBC 3.0 (unsupported) method follow; these are required to be able 
+    // to compile against JDK 1.4
+    public boolean getMoreResults(int i) throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public ResultSet getGeneratedKeys() throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public int executeUpdate(String s, int i) throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public int executeUpdate(String s, int[] ia) throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public int executeUpdate(String s, String[] sa) throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public boolean execute(String s, int i) throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public boolean execute(String s, int[] ia) throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public boolean execute(String s, String[] sa) throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public int getResultSetHoldability() throws SQLException {
+        throw new UnsupportedOperationException();
+    }
 }
-

Modified: incubator/openjpa/trunk/openjpa-lib/main/java/org/apache/openjpa/lib/jdbc/JDBCEvent.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/main/java/org/apache/openjpa/lib/jdbc/JDBCEvent.java?rev=417856&r1=415364&r2=417856&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/main/java/org/apache/openjpa/lib/jdbc/JDBCEvent.java (original)
+++ incubator/openjpa/trunk/openjpa-lib/main/java/org/apache/openjpa/lib/jdbc/JDBCEvent.java Wed Jun 28 12:34:33 2006
@@ -15,161 +15,143 @@
  */
 package org.apache.openjpa.lib.jdbc;
 
-
 import java.sql.*;
+
 import java.util.*;
 
 
-/** 
+/**
  *  <p>A JDBC event.  The event source will be the connection.</p>
- *  
- *	@see	JDBCListener
- *  @author  Marc Prud'hommeaux
- *  @author  Abe White
+ *
+ *  @see JDBCListener
+ *  @author Marc Prud'hommeaux
+ *  @author Abe White
  */
-public class JDBCEvent
-	extends EventObject
-{
-	/** 
-	 *  Type code indicating that a {@link Statement} is being prepared.
-	 */
-	public static final short BEFORE_PREPARE_STATEMENT = 1;
-
-	/** 
-	 *  Type code indicating that a {@link Statement} is being prepared.
-	 */
-	public static final short AFTER_PREPARE_STATEMENT = 2;
-
-	/** 
-	 *  Type code indicating that a {@link Statement} is being created.
-	 */
-	public static final short BEFORE_CREATE_STATEMENT = 3;
-
-	/** 
-	 *  Type code indicating that a {@link Statement} is being created.
-	 */
-	public static final short AFTER_CREATE_STATEMENT = 4;
-
-	/** 
-	 *  Type code indicating that a {@link Statement} is about to be executed.
-	 */
-	public static final short BEFORE_EXECUTE_STATEMENT = 5;
-
-	/** 
-	 *  Type code indicating that a {@link Statement} completed execution.
-	 */
-	public static final short AFTER_EXECUTE_STATEMENT = 6;
-
-	/** 
-	 *  Type code indicating that a {@link Connection} is about to be committed.
-	 */
-	public static final short BEFORE_COMMIT = 7;
-
-	/** 
-	 *  Type code indicating that a {@link Connection} was just committed.
-	 */
-	public static final short AFTER_COMMIT = 8;
-
-	/** 
-	 *  Type code indicating that a rollback is about to occur.
-	 */
-	public static final short BEFORE_ROLLBACK = 9;
-
-	/** 
-	 *  Type code indicating that a rollback just occured.
-	 */
-	public static final short AFTER_ROLLBACK = 10;
-
-	/**
-	 *	Type code indicating that a connection was obtained.  This does
-	 *	not necessarily mean that the connection is new if pooling is enabled.
-	 */
-	public static final short AFTER_CONNECT = 11;
-
-	/**
-	 *	Type code indicating that a connection was closed.  This does
-	 *	not necessarily mean that the underlying database connection was 
-	 *	severed if pooling is enabled.
-	 */
-	public static final short BEFORE_CLOSE = 12;
-
-	private final short					type;
-	private final long 					time;
-	private final String				sql;
-	private final JDBCEvent 			associatedEvent;
-	private final transient Statement 	statement;
-
-
-	/**
-	 *	Constructor.
-	 */
-	public JDBCEvent (Connection source, short type, JDBCEvent associatedEvent, 
-		Statement statement, String sql)
-	{
-		super (source);
-		this.type = type;
-		this.time = System.currentTimeMillis ();
-		this.associatedEvent = associatedEvent;
-		this.sql = sql;
-		this.statement = statement;
-	}
-
-
-	/**
-	 *	Return the event's type code.
-	 */
-	public final short getType ()
-	{
-		return type;
-	}
-
-
-	/** 
-	 *  Return the Connection for this event.
-	 */
-	public final Connection getConnection ()
-	{
-		return (Connection) getSource ();
-	}
-
-
-	/**
-	 *	Return the time the event was constructed.
-	 */
-	public final long getTime ()
-	{
-		return time;
-	}
-
-
-	/** 
-	 *  Return the associated {@link JDBCEvent} for this event.
-	 * 	For AFTER_XXX events, this will typically be the JDBCEvent 
-	 *	that was created in the	BEFORE_XXX stage. This may be null when
-	 * 	an association is not appropriate for the event.
-	 */
-	public final JDBCEvent getAssociatedEvent ()
-	{
-		return associatedEvent;
-	}
-
-
-	/**
-	 *	Return the SQL associated with this event; may be null.
-	 */
-	public final String getSQL ()
-	{
-		return sql;
-	}
-
-
-	/** 
-	 *  Return the Statement for this event, may be null for events
-	 * 	unrelated to Statement execution.
-	 */
-	public final Statement getStatement ()
-	{
-		return statement;
-	}
+public class JDBCEvent extends EventObject {
+    /**
+     *  Type code indicating that a {@link Statement} is being prepared.
+     */
+    public static final short BEFORE_PREPARE_STATEMENT = 1;
+
+    /**
+     *  Type code indicating that a {@link Statement} is being prepared.
+     */
+    public static final short AFTER_PREPARE_STATEMENT = 2;
+
+    /**
+     *  Type code indicating that a {@link Statement} is being created.
+     */
+    public static final short BEFORE_CREATE_STATEMENT = 3;
+
+    /**
+     *  Type code indicating that a {@link Statement} is being created.
+     */
+    public static final short AFTER_CREATE_STATEMENT = 4;
+
+    /**
+     *  Type code indicating that a {@link Statement} is about to be executed.
+     */
+    public static final short BEFORE_EXECUTE_STATEMENT = 5;
+
+    /**
+     *  Type code indicating that a {@link Statement} completed execution.
+     */
+    public static final short AFTER_EXECUTE_STATEMENT = 6;
+
+    /**
+     *  Type code indicating that a {@link Connection} is about to be committed.
+     */
+    public static final short BEFORE_COMMIT = 7;
+
+    /**
+     *  Type code indicating that a {@link Connection} was just committed.
+     */
+    public static final short AFTER_COMMIT = 8;
+
+    /**
+     *  Type code indicating that a rollback is about to occur.
+     */
+    public static final short BEFORE_ROLLBACK = 9;
+
+    /**
+     *  Type code indicating that a rollback just occured.
+     */
+    public static final short AFTER_ROLLBACK = 10;
+
+    /**
+     *  Type code indicating that a connection was obtained.  This does
+     *  not necessarily mean that the connection is new if pooling is enabled.
+     */
+    public static final short AFTER_CONNECT = 11;
+
+    /**
+     *  Type code indicating that a connection was closed.  This does
+     *  not necessarily mean that the underlying database connection was
+     *  severed if pooling is enabled.
+     */
+    public static final short BEFORE_CLOSE = 12;
+    private final short type;
+    private final long time;
+    private final String sql;
+    private final JDBCEvent associatedEvent;
+    private final transient Statement statement;
+
+    /**
+     *  Constructor.
+     */
+    public JDBCEvent(Connection source, short type, JDBCEvent associatedEvent,
+        Statement statement, String sql) {
+        super(source);
+        this.type = type;
+        this.time = System.currentTimeMillis();
+        this.associatedEvent = associatedEvent;
+        this.sql = sql;
+        this.statement = statement;
+    }
+
+    /**
+     *  Return the event's type code.
+     */
+    public final short getType() {
+        return type;
+    }
+
+    /**
+     *  Return the Connection for this event.
+     */
+    public final Connection getConnection() {
+        return (Connection) getSource();
+    }
+
+    /**
+     *  Return the time the event was constructed.
+     */
+    public final long getTime() {
+        return time;
+    }
+
+    /**
+     *  Return the associated {@link JDBCEvent} for this event.
+     *  For AFTER_XXX events, this will typically be the JDBCEvent
+     *  that was created in the        BEFORE_XXX stage. This may be null when
+     *  an association is not appropriate for the event.
+     */
+    public final JDBCEvent getAssociatedEvent() {
+        return associatedEvent;
+    }
+
+    /**
+     *  Return the SQL associated with this event; may be null.
+     */
+    public final String getSQL() {
+        return sql;
+    }
+
+    /**
+     *  Return the Statement for this event, may be null for events
+     *  unrelated to Statement execution.
+     */
+    public final Statement getStatement() {
+        return statement;
+    }
 }
-

Modified: incubator/openjpa/trunk/openjpa-lib/main/java/org/apache/openjpa/lib/jdbc/JDBCEventConnectionDecorator.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/main/java/org/apache/openjpa/lib/jdbc/JDBCEventConnectionDecorator.java?rev=417856&r1=415364&r2=417856&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/main/java/org/apache/openjpa/lib/jdbc/JDBCEventConnectionDecorator.java (original)
+++ incubator/openjpa/trunk/openjpa-lib/main/java/org/apache/openjpa/lib/jdbc/JDBCEventConnectionDecorator.java Wed Jun 28 12:34:33 2006
@@ -15,364 +15,322 @@
  */
 package org.apache.openjpa.lib.jdbc;
 
+import org.apache.openjpa.lib.util.concurrent.*;
 
 import java.sql.*;
-import org.apache.openjpa.lib.util.*;
+
+import java.util.*;
+
+import javax.sql.*;
 
 
 /**
- *	<p>Manages the firing of {@link JDBCEvent}s.</p>
+ *  <p>Manages the firing of {@link JDBCEvent}s.</p>
  *
- *	@author		Abe White
- *	@nojavadoc
- */
-public class JDBCEventConnectionDecorator
-	extends AbstractEventManager
-	implements ConnectionDecorator
-{
-	public Connection decorate (Connection conn)
-	{
-		if (!hasListeners ())
-			return conn;
-		return new EventConnection (conn); 
-	}
-
-
-	/**
-	 *	Fire the given event to all listeners.  Prevents creation of an
-	 *	event object when there are no listeners.
-	 */
-	private JDBCEvent fireEvent (Connection source, short type, 
-		JDBCEvent associatedEvent, Statement stmnt, String sql)
-	{
-		if (!hasListeners ())
-			return null;
-
-		JDBCEvent event = new JDBCEvent (source, type, associatedEvent,
-			stmnt, sql);
-		fireEvent (event);
-		return event;
-	}
-
-
-	/**
-	 *	Fire the given event to all listeners.
-	 */
-	protected void fireEvent (Object event, Object listener)
-	{
-		JDBCListener listen = (JDBCListener) listener;
-		JDBCEvent ev = (JDBCEvent) event;
-		switch (ev.getType ())
-		{
-		case JDBCEvent.BEFORE_PREPARE_STATEMENT:
-			listen.beforePrepareStatement (ev);
-			break;
-		case JDBCEvent.AFTER_PREPARE_STATEMENT:
-			listen.afterPrepareStatement (ev);
-			break;
-		case JDBCEvent.BEFORE_CREATE_STATEMENT:
-			listen.beforeCreateStatement (ev);
-			break;
-		case JDBCEvent.AFTER_CREATE_STATEMENT:
-			listen.afterCreateStatement (ev);
-			break;
-		case JDBCEvent.BEFORE_EXECUTE_STATEMENT:
-			listen.beforeExecuteStatement (ev);
-			break;
-		case JDBCEvent.AFTER_EXECUTE_STATEMENT:
-			listen.afterExecuteStatement (ev);
-			break;
-		case JDBCEvent.BEFORE_COMMIT:
-			listen.beforeCommit (ev);
-			break;
-		case JDBCEvent.AFTER_COMMIT:
-			listen.afterCommit (ev);
-			break;
-		case JDBCEvent.BEFORE_ROLLBACK:
-			listen.beforeRollback (ev);
-			break;
-		case JDBCEvent.AFTER_ROLLBACK:
-			listen.afterRollback (ev);
-			break;
-		case JDBCEvent.AFTER_CONNECT:
-			listen.afterConnect (ev);
-			break;
-		case JDBCEvent.BEFORE_CLOSE:
-			listen.beforeClose (ev);
-			break;
-		}
-	}
-
-	
-	/**
-	 *	Fires events as appropriate.
-	 */
-	private class EventConnection
-		extends DelegatingConnection
-	{
-		public EventConnection (Connection conn)
-		{
-			super (conn);
-			fireEvent (getDelegate (), JDBCEvent.AFTER_CONNECT, 
-				null, null, null);
-		}
-
-
-		public void commit ()
-			throws SQLException
-		{
-			JDBCEvent before = fireEvent (getDelegate (), 
-				JDBCEvent.BEFORE_COMMIT, null, null, null);
-			try
-			{ 
-				super.commit ();
-			}
-			finally
-			{
-				fireEvent (getDelegate (), JDBCEvent.AFTER_COMMIT, before,
-					null, null);	
-			}
-		}
-
-
-		public void rollback ()
-			throws SQLException
-		{
-			JDBCEvent before = fireEvent (getDelegate (), 
-				JDBCEvent.BEFORE_ROLLBACK, null, null, null);
-			try
-			{ 
-				super.rollback ();
-			}
-			finally
-			{
-				fireEvent (getDelegate (), JDBCEvent.AFTER_ROLLBACK, before, 
-					null, null);	
-			}
-		}
-
-
-		protected Statement createStatement (boolean wrap)
-			throws SQLException
-		{
-			JDBCEvent before = fireEvent (getDelegate (), 
-				JDBCEvent.BEFORE_CREATE_STATEMENT, null, null, null);
-			Statement stmnt = null;
-			try
-			{ 
-				stmnt = new EventStatement (super.createStatement (false),
-					EventConnection.this);
-			}
-			finally
-			{
-				fireEvent (getDelegate (), JDBCEvent.AFTER_CREATE_STATEMENT, 
-					before, stmnt, null);	
-			}
-			return stmnt;
-		}
-
-
-		protected Statement createStatement (int rsType, int rsConcur, 
-			boolean wrap)
-			throws SQLException
-		{
-			JDBCEvent before = fireEvent (getDelegate (), 
-				JDBCEvent.BEFORE_CREATE_STATEMENT, null, null, null);
-			Statement stmnt = null;
-			try
-			{ 
-				stmnt = new EventStatement (super.createStatement 
-					(rsType, rsConcur, false), EventConnection.this);
-			}
-			finally
-			{
-				fireEvent (getDelegate (), JDBCEvent.AFTER_CREATE_STATEMENT, 
-					before, stmnt, null);	
-			}
-			return stmnt;
-		}
-
-
-		protected PreparedStatement prepareStatement (String sql, boolean wrap)
-			throws SQLException
-		{
-			JDBCEvent before = fireEvent (getDelegate (), 
-				JDBCEvent.BEFORE_PREPARE_STATEMENT, null, null, sql);
-			PreparedStatement stmnt = null;
-			try
-			{ 
-				stmnt = new EventPreparedStatement (super.prepareStatement 
-					(sql, false), EventConnection.this, sql); 
-			}
-			finally
-			{
-				fireEvent (getDelegate (), JDBCEvent.AFTER_PREPARE_STATEMENT, 
-					before, stmnt, sql);	
-			}
-			return stmnt;
-		}
-
-
-		protected PreparedStatement prepareStatement (String sql, int rsType,
-			int rsConcur, boolean wrap)
-			throws SQLException
-		{
-			JDBCEvent before = fireEvent (getDelegate (), 
-				JDBCEvent.BEFORE_PREPARE_STATEMENT, null, null, sql);
-			PreparedStatement stmnt = null;
-			try
-			{ 
-				stmnt = new EventPreparedStatement (super.prepareStatement 
-					(sql, rsType, rsConcur, false), EventConnection.this, sql);
-			}
-			finally
-			{
-				fireEvent (getDelegate (), JDBCEvent.AFTER_PREPARE_STATEMENT, 
-					before, stmnt, sql);	
-			}
-			return stmnt;
-		}
-
-
-		public void close ()
-			throws SQLException
-		{
-			try
-			{
-				fireEvent (getDelegate (), JDBCEvent.BEFORE_CLOSE,
-					null, null, null);
-			}
-			finally
-			{
-				super.close ();
-			}
-		}
-	}
-
-
-	/**
-	 *	Fires events as appropriate.
-	 */
-	private class EventPreparedStatement
-		extends DelegatingPreparedStatement
-	{
-		private final EventConnection	_conn;
-		private final String 			_sql;
-
-
-		public EventPreparedStatement (PreparedStatement ps, 
-			EventConnection conn, String sql)
-		{
-			super (ps, conn);
-			_conn = conn;
-			_sql = sql;
-		}
-
-
-		public int executeUpdate ()
-			throws SQLException
-		{
-			JDBCEvent before = fireEvent (_conn.getDelegate (), 
-				JDBCEvent.BEFORE_EXECUTE_STATEMENT, null, getDelegate (), _sql);
-			try
-			{ 
-				return super.executeUpdate ();
-			}
-			finally
-			{
-				fireEvent (_conn.getDelegate (), 
-					JDBCEvent.AFTER_EXECUTE_STATEMENT, before, 
-					getDelegate (), _sql);
-			}
-		}
-
-
-		protected ResultSet executeQuery (boolean wrap)
-			throws SQLException
-		{
-			JDBCEvent before = fireEvent (_conn.getDelegate (), 
-				JDBCEvent.BEFORE_EXECUTE_STATEMENT, null, getDelegate (), _sql);
-			try
-			{ 
-				return super.executeQuery (wrap);
-			}
-			finally
-			{
-				fireEvent (_conn.getDelegate (), 
-					JDBCEvent.AFTER_EXECUTE_STATEMENT, before, 
-					getDelegate (), _sql);
-			}
-		}
-
-
-		public int[] executeBatch ()
-			throws SQLException
-		{
-			JDBCEvent before = fireEvent (_conn.getDelegate (), 
-				JDBCEvent.BEFORE_EXECUTE_STATEMENT, null, getDelegate (), _sql);
-			try
-			{ 
-				return super.executeBatch ();
-			}
-			finally
-			{
-				fireEvent (_conn.getDelegate (), 
-					JDBCEvent.AFTER_EXECUTE_STATEMENT, before, 
-					getDelegate (), _sql);
-			}
-		}
-	}
-
-
-	/**
-	 *	Fires events as appropriate.
-	 */
-	private class EventStatement
-		extends DelegatingStatement
-	{
-		private final EventConnection _conn;
-
-
-		public EventStatement (Statement stmnt, EventConnection conn)
-		{
-			super (stmnt, conn);
-			_conn = conn;
-		}
-
-
-		public int executeUpdate (String sql)
-			throws SQLException
-		{
-			JDBCEvent before = fireEvent (_conn.getDelegate (), 
-				JDBCEvent.BEFORE_EXECUTE_STATEMENT, null, getDelegate (), sql);
-			try
-			{ 
-				return super.executeUpdate (sql);
-			}
-			finally
-			{
-				fireEvent (_conn.getDelegate (), 
-					JDBCEvent.AFTER_EXECUTE_STATEMENT, before, 
-					getDelegate (), sql);
-			}
-		}
-
-
-		protected ResultSet executeQuery (String sql, boolean wrap)
-			throws SQLException
-		{
-			JDBCEvent before = fireEvent (_conn.getDelegate (), 
-				JDBCEvent.BEFORE_EXECUTE_STATEMENT, null, getDelegate (), sql);
-			try
-			{ 
-				return super.executeQuery (sql, wrap);
-			}
-			finally
-			{
-				fireEvent (_conn.getDelegate (), 
-					JDBCEvent.AFTER_EXECUTE_STATEMENT, before, 
-					getDelegate (), sql);
-			}
-		}
-	}
+ *  @author Abe White
+ *  @nojavadoc */
+public class JDBCEventConnectionDecorator extends AbstractConcurrentEventManager
+    implements ConnectionDecorator {
+    public Connection decorate(Connection conn) {
+        if (!hasListeners()) {
+            return conn;
+        }
+
+        return new EventConnection(conn);
+    }
+
+    /**
+     *  Fire the given event to all listeners.  Prevents creation of an
+     *  event object when there are no listeners.
+     */
+    private JDBCEvent fireEvent(Connection source, short type,
+        JDBCEvent associatedEvent, Statement stmnt, String sql) {
+        if (!hasListeners()) {
+            return null;
+        }
+
+        JDBCEvent event = new JDBCEvent(source, type, associatedEvent, stmnt,
+                sql);
+        fireEvent(event);
+
+        return event;
+    }
+
+    /**
+     *  Fire the given event to all listeners.
+     */
+    protected void fireEvent(Object event, Object listener) {
+        JDBCListener listen = (JDBCListener) listener;
+        JDBCEvent ev = (JDBCEvent) event;
+
+        switch (ev.getType()) {
+        case JDBCEvent.BEFORE_PREPARE_STATEMENT:
+            listen.beforePrepareStatement(ev);
+
+            break;
+
+        case JDBCEvent.AFTER_PREPARE_STATEMENT:
+            listen.afterPrepareStatement(ev);
+
+            break;
+
+        case JDBCEvent.BEFORE_CREATE_STATEMENT:
+            listen.beforeCreateStatement(ev);
+
+            break;
+
+        case JDBCEvent.AFTER_CREATE_STATEMENT:
+            listen.afterCreateStatement(ev);
+
+            break;
+
+        case JDBCEvent.BEFORE_EXECUTE_STATEMENT:
+            listen.beforeExecuteStatement(ev);
+
+            break;
+
+        case JDBCEvent.AFTER_EXECUTE_STATEMENT:
+            listen.afterExecuteStatement(ev);
+
+            break;
+
+        case JDBCEvent.BEFORE_COMMIT:
+            listen.beforeCommit(ev);
+
+            break;
+
+        case JDBCEvent.AFTER_COMMIT:
+            listen.afterCommit(ev);
+
+            break;
+
+        case JDBCEvent.BEFORE_ROLLBACK:
+            listen.beforeRollback(ev);
+
+            break;
+
+        case JDBCEvent.AFTER_ROLLBACK:
+            listen.afterRollback(ev);
+
+            break;
+
+        case JDBCEvent.AFTER_CONNECT:
+            listen.afterConnect(ev);
+
+            break;
+
+        case JDBCEvent.BEFORE_CLOSE:
+            listen.beforeClose(ev);
+
+            break;
+        }
+    }
+
+    /**
+     *  Fires events as appropriate.
+     */
+    private class EventConnection extends DelegatingConnection {
+        public EventConnection(Connection conn) {
+            super(conn);
+            fireEvent(getDelegate(), JDBCEvent.AFTER_CONNECT, null, null, null);
+        }
+
+        public void commit() throws SQLException {
+            JDBCEvent before = fireEvent(getDelegate(),
+                    JDBCEvent.BEFORE_COMMIT, null, null, null);
+
+            try {
+                super.commit();
+            } finally {
+                fireEvent(getDelegate(), JDBCEvent.AFTER_COMMIT, before, null,
+                    null);
+            }
+        }
+
+        public void rollback() throws SQLException {
+            JDBCEvent before = fireEvent(getDelegate(),
+                    JDBCEvent.BEFORE_ROLLBACK, null, null, null);
+
+            try {
+                super.rollback();
+            } finally {
+                fireEvent(getDelegate(), JDBCEvent.AFTER_ROLLBACK, before,
+                    null, null);
+            }
+        }
+
+        protected Statement createStatement(boolean wrap)
+            throws SQLException {
+            JDBCEvent before = fireEvent(getDelegate(),
+                    JDBCEvent.BEFORE_CREATE_STATEMENT, null, null, null);
+            Statement stmnt = null;
+
+            try {
+                stmnt = new EventStatement(super.createStatement(false),
+                        EventConnection.this);
+            } finally {
+                fireEvent(getDelegate(), JDBCEvent.AFTER_CREATE_STATEMENT,
+                    before, stmnt, null);
+            }
+
+            return stmnt;
+        }
+
+        protected Statement createStatement(int rsType, int rsConcur,
+            boolean wrap) throws SQLException {
+            JDBCEvent before = fireEvent(getDelegate(),
+                    JDBCEvent.BEFORE_CREATE_STATEMENT, null, null, null);
+            Statement stmnt = null;
+
+            try {
+                stmnt = new EventStatement(super.createStatement(rsType,
+                            rsConcur, false), EventConnection.this);
+            } finally {
+                fireEvent(getDelegate(), JDBCEvent.AFTER_CREATE_STATEMENT,
+                    before, stmnt, null);
+            }
+
+            return stmnt;
+        }
+
+        protected PreparedStatement prepareStatement(String sql, boolean wrap)
+            throws SQLException {
+            JDBCEvent before = fireEvent(getDelegate(),
+                    JDBCEvent.BEFORE_PREPARE_STATEMENT, null, null, sql);
+            PreparedStatement stmnt = null;
+
+            try {
+                stmnt = new EventPreparedStatement(super.prepareStatement(sql,
+                            false), EventConnection.this, sql);
+            } finally {
+                fireEvent(getDelegate(), JDBCEvent.AFTER_PREPARE_STATEMENT,
+                    before, stmnt, sql);
+            }
+
+            return stmnt;
+        }
+
+        protected PreparedStatement prepareStatement(String sql, int rsType,
+            int rsConcur, boolean wrap) throws SQLException {
+            JDBCEvent before = fireEvent(getDelegate(),
+                    JDBCEvent.BEFORE_PREPARE_STATEMENT, null, null, sql);
+            PreparedStatement stmnt = null;
+
+            try {
+                stmnt = new EventPreparedStatement(super.prepareStatement(sql,
+                            rsType, rsConcur, false), EventConnection.this, sql);
+            } finally {
+                fireEvent(getDelegate(), JDBCEvent.AFTER_PREPARE_STATEMENT,
+                    before, stmnt, sql);
+            }
+
+            return stmnt;
+        }
+
+        public void close() throws SQLException {
+            try {
+                fireEvent(getDelegate(), JDBCEvent.BEFORE_CLOSE, null, null,
+                    null);
+            } finally {
+                super.close();
+            }
+        }
+    }
+
+    /**
+     *  Fires events as appropriate.
+     */
+    private class EventPreparedStatement extends DelegatingPreparedStatement {
+        private final EventConnection _conn;
+        private final String _sql;
+
+        public EventPreparedStatement(PreparedStatement ps,
+            EventConnection conn, String sql) {
+            super(ps, conn);
+            _conn = conn;
+            _sql = sql;
+        }
+
+        public int executeUpdate() throws SQLException {
+            JDBCEvent before = fireEvent(_conn.getDelegate(),
+                    JDBCEvent.BEFORE_EXECUTE_STATEMENT, null, getDelegate(),
+                    _sql);
+
+            try {
+                return super.executeUpdate();
+            } finally {
+                fireEvent(_conn.getDelegate(),
+                    JDBCEvent.AFTER_EXECUTE_STATEMENT, before, getDelegate(),
+                    _sql);
+            }
+        }
+
+        protected ResultSet executeQuery(boolean wrap)
+            throws SQLException {
+            JDBCEvent before = fireEvent(_conn.getDelegate(),
+                    JDBCEvent.BEFORE_EXECUTE_STATEMENT, null, getDelegate(),
+                    _sql);
+
+            try {
+                return super.executeQuery(wrap);
+            } finally {
+                fireEvent(_conn.getDelegate(),
+                    JDBCEvent.AFTER_EXECUTE_STATEMENT, before, getDelegate(),
+                    _sql);
+            }
+        }
+
+        public int[] executeBatch() throws SQLException {
+            JDBCEvent before = fireEvent(_conn.getDelegate(),
+                    JDBCEvent.BEFORE_EXECUTE_STATEMENT, null, getDelegate(),
+                    _sql);
+
+            try {
+                return super.executeBatch();
+            } finally {
+                fireEvent(_conn.getDelegate(),
+                    JDBCEvent.AFTER_EXECUTE_STATEMENT, before, getDelegate(),
+                    _sql);
+            }
+        }
+    }
+
+    /**
+     *  Fires events as appropriate.
+     */
+    private class EventStatement extends DelegatingStatement {
+        private final EventConnection _conn;
+
+        public EventStatement(Statement stmnt, EventConnection conn) {
+            super(stmnt, conn);
+            _conn = conn;
+        }
+
+        public int executeUpdate(String sql) throws SQLException {
+            JDBCEvent before = fireEvent(_conn.getDelegate(),
+                    JDBCEvent.BEFORE_EXECUTE_STATEMENT, null, getDelegate(), sql);
+
+            try {
+                return super.executeUpdate(sql);
+            } finally {
+                fireEvent(_conn.getDelegate(),
+                    JDBCEvent.AFTER_EXECUTE_STATEMENT, before, getDelegate(),
+                    sql);
+            }
+        }
+
+        protected ResultSet executeQuery(String sql, boolean wrap)
+            throws SQLException {
+            JDBCEvent before = fireEvent(_conn.getDelegate(),
+                    JDBCEvent.BEFORE_EXECUTE_STATEMENT, null, getDelegate(), sql);
+
+            try {
+                return super.executeQuery(sql, wrap);
+            } finally {
+                fireEvent(_conn.getDelegate(),
+                    JDBCEvent.AFTER_EXECUTE_STATEMENT, before, getDelegate(),
+                    sql);
+            }
+        }
+    }
 }

Modified: incubator/openjpa/trunk/openjpa-lib/main/java/org/apache/openjpa/lib/jdbc/JDBCListener.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/main/java/org/apache/openjpa/lib/jdbc/JDBCListener.java?rev=417856&r1=415364&r2=417856&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/main/java/org/apache/openjpa/lib/jdbc/JDBCListener.java (original)
+++ incubator/openjpa/trunk/openjpa-lib/main/java/org/apache/openjpa/lib/jdbc/JDBCListener.java Wed Jun 28 12:34:33 2006
@@ -16,84 +16,71 @@
 package org.apache.openjpa.lib.jdbc;
 
 
-/** 
- *	A listener for all {@link JDBCEvent}s that occur.
+/**
+ *  A listener for all {@link JDBCEvent}s that occur.
  *
- *	@see	AbstractJDBCListener
- *  @author  Marc Prud'hommeaux
- *	@author	Abe White
+ *  @see AbstractJDBCListener
+ *  @author Marc Prud'hommeaux
+ *  @author Abe White
  */
-public interface JDBCListener
-{
-	/**
-	 *	@see JDBCEvent#BEFORE_PREPARE_STATEMENT
-	 */
-	public void beforePrepareStatement (JDBCEvent event);
-
-
-	/**
-	 *	@see JDBCEvent#AFTER_PREPARE_STATEMENT
-	 */
-	public void afterPrepareStatement (JDBCEvent event);
-
-
-	/**
-	 *	@see JDBCEvent#BEFORE_CREATE_STATEMENT
-	 */
-	public void beforeCreateStatement (JDBCEvent event);
-
-
-	/**
-	 *	@see JDBCEvent#AFTER_CREATE_STATEMENT
-	 */
-	public void afterCreateStatement (JDBCEvent event);
-
-
-	/**
-	 *	@see JDBCEvent#BEFORE_EXECUTE_STATEMENT
-	 */
-	public void beforeExecuteStatement (JDBCEvent event);
-
-
-	/**
-	 *	@see JDBCEvent#AFTER_EXECUTE_STATEMENT
-	 */
-	public void afterExecuteStatement (JDBCEvent event);
-
-
-	/**
-	 *	@see JDBCEvent#BEFORE_COMMIT
-	 */
-	public void beforeCommit (JDBCEvent event);
-
-
-	/**
-	 *	@see JDBCEvent#AFTER_COMMIT
-	 */
-	public void afterCommit (JDBCEvent event);
-
-
-	/**
-	 *	@see JDBCEvent#BEFORE_ROLLBACK
-	 */
-	public void beforeRollback (JDBCEvent event);
-
-
-	/**
-	 *	@see JDBCEvent#AFTER_ROLLBACK
-	 */
-	public void afterRollback (JDBCEvent event);
-
-
-	/**
-	 *	@see JDBCEvent#AFTER_CONNECT
-	 */
-	public void afterConnect (JDBCEvent event);
-
-
-	/**
-	 *	@see JDBCEvent#BEFORE_CLOSE
-	 */
-	public void beforeClose (JDBCEvent event);
+public interface JDBCListener {
+    /**
+     *  @see JDBCEvent#BEFORE_PREPARE_STATEMENT
+     */
+    public void beforePrepareStatement(JDBCEvent event);
+
+    /**
+     *  @see JDBCEvent#AFTER_PREPARE_STATEMENT
+     */
+    public void afterPrepareStatement(JDBCEvent event);
+
+    /**
+     *  @see JDBCEvent#BEFORE_CREATE_STATEMENT
+     */
+    public void beforeCreateStatement(JDBCEvent event);
+
+    /**
+     *  @see JDBCEvent#AFTER_CREATE_STATEMENT
+     */
+    public void afterCreateStatement(JDBCEvent event);
+
+    /**
+     *  @see JDBCEvent#BEFORE_EXECUTE_STATEMENT
+     */
+    public void beforeExecuteStatement(JDBCEvent event);
+
+    /**
+     *  @see JDBCEvent#AFTER_EXECUTE_STATEMENT
+     */
+    public void afterExecuteStatement(JDBCEvent event);
+
+    /**
+     *  @see JDBCEvent#BEFORE_COMMIT
+     */
+    public void beforeCommit(JDBCEvent event);
+
+    /**
+     *  @see JDBCEvent#AFTER_COMMIT
+     */
+    public void afterCommit(JDBCEvent event);
+
+    /**
+     *  @see JDBCEvent#BEFORE_ROLLBACK
+     */
+    public void beforeRollback(JDBCEvent event);
+
+    /**
+     *  @see JDBCEvent#AFTER_ROLLBACK
+     */
+    public void afterRollback(JDBCEvent event);
+
+    /**
+     *  @see JDBCEvent#AFTER_CONNECT
+     */
+    public void afterConnect(JDBCEvent event);
+
+    /**
+     *  @see JDBCEvent#BEFORE_CLOSE
+     */
+    public void beforeClose(JDBCEvent event);
 }
-