Author: cbegin
Date: Sun Sep 6 18:18:32 2009
New Revision: 811852
URL: http://svn.apache.org/viewvc?rev=811852&view=rev
Log:
converted CS RS adapter to be a dynamic proxy to enable compilation under JDK
1.6 (thanks Apple, for not including Java 5 in Snow Leopard :-/)
Modified:
ibatis/java/ibatis-3/trunk/ibatis-3-compat/src/main/java/com/ibatis/sqlmap/engine/builder/TypeHandlerCallbackAdapter.java
Modified:
ibatis/java/ibatis-3/trunk/ibatis-3-compat/src/main/java/com/ibatis/sqlmap/engine/builder/TypeHandlerCallbackAdapter.java
URL:
http://svn.apache.org/viewvc/ibatis/java/ibatis-3/trunk/ibatis-3-compat/src/main/java/com/ibatis/sqlmap/engine/builder/TypeHandlerCallbackAdapter.java?rev=811852&r1=811851&r2=811852&view=diff
==============================================================================
---
ibatis/java/ibatis-3/trunk/ibatis-3-compat/src/main/java/com/ibatis/sqlmap/engine/builder/TypeHandlerCallbackAdapter.java
(original)
+++
ibatis/java/ibatis-3/trunk/ibatis-3-compat/src/main/java/com/ibatis/sqlmap/engine/builder/TypeHandlerCallbackAdapter.java
Sun Sep 6 18:18:32 2009
@@ -13,6 +13,9 @@
import java.sql.*;
import java.util.Calendar;
import java.util.Map;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
public class TypeHandlerCallbackAdapter implements TypeHandler {
@@ -31,7 +34,7 @@
}
public Object getResult(CallableStatement cs, int columnIndex) throws
SQLException {
- return callback.getResult(new ResultGetterImpl(new
CallableStatementResultSet(cs), columnIndex));
+ return callback.getResult(new
ResultGetterImpl(CallableStatementResultSet.newProxy(cs), columnIndex));
}
public static class ParameterSetterImpl implements ParameterSetter {
@@ -405,573 +408,21 @@
}
}
- public static class CallableStatementResultSet implements ResultSet {
+ public static class CallableStatementResultSet implements InvocationHandler {
private CallableStatement cs;
- /**
- * Constructor to stretch a ResultSet interface over a CallableStatement
- *
- * @param cs - the CallableStatement
- */
- public CallableStatementResultSet(CallableStatement cs) {
+ private CallableStatementResultSet(CallableStatement cs) {
this.cs = cs;
}
- public boolean absolute(int row) throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public void afterLast() throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public void beforeFirst() throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public void cancelRowUpdates() throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public void clearWarnings() throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public void close() throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public void deleteRow() throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public int findColumn(String columnName) throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public boolean first() throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public Array getArray(String colName) throws SQLException {
- return cs.getArray(colName);
- }
-
- public Array getArray(int i) throws SQLException {
- return cs.getArray(i);
- }
-
- public InputStream getAsciiStream(int columnIndex) throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public InputStream getAsciiStream(String columnName) throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public BigDecimal getBigDecimal(int columnIndex) throws SQLException {
- return cs.getBigDecimal(columnIndex);
- }
-
- public BigDecimal getBigDecimal(int columnIndex, int scale) throws
SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public BigDecimal getBigDecimal(String columnName) throws SQLException {
- return cs.getBigDecimal(columnName);
- }
-
- public BigDecimal getBigDecimal(String columnName, int scale) throws
SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public InputStream getBinaryStream(int columnIndex) throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public InputStream getBinaryStream(String columnName) throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public Blob getBlob(String colName) throws SQLException {
- return cs.getBlob(colName);
- }
-
- public Blob getBlob(int i) throws SQLException {
- return cs.getBlob(i);
- }
-
- public boolean getBoolean(int columnIndex) throws SQLException {
- return cs.getBoolean(columnIndex);
- }
-
- public boolean getBoolean(String columnName) throws SQLException {
- return cs.getBoolean(columnName);
- }
-
- public byte getByte(int columnIndex) throws SQLException {
- return cs.getByte(columnIndex);
- }
-
- public byte getByte(String columnName) throws SQLException {
- return cs.getByte(columnName);
- }
-
- public byte[] getBytes(int columnIndex) throws SQLException {
- return cs.getBytes(columnIndex);
- }
-
- public byte[] getBytes(String columnName) throws SQLException {
- return cs.getBytes(columnName);
- }
-
- public Reader getCharacterStream(int columnIndex) throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public Reader getCharacterStream(String columnName) throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public Clob getClob(String colName) throws SQLException {
- return cs.getClob(colName);
- }
-
- public Clob getClob(int i) throws SQLException {
- return cs.getClob(i);
- }
-
- public int getConcurrency() throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public String getCursorName() throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public Date getDate(int columnIndex) throws SQLException {
- return cs.getDate(columnIndex);
- }
-
- public Date getDate(int columnIndex, Calendar cal) throws SQLException {
- return cs.getDate(columnIndex, cal);
- }
-
- public Date getDate(String columnName) throws SQLException {
- return cs.getDate(columnName);
- }
-
- public Date getDate(String columnName, Calendar cal) throws SQLException {
- return cs.getDate(columnName, cal);
- }
-
- public double getDouble(int columnIndex) throws SQLException {
- return cs.getDouble(columnIndex);
- }
-
- public double getDouble(String columnName) throws SQLException {
- return cs.getDouble(columnName);
- }
-
- public int getFetchDirection() throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public int getFetchSize() throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public float getFloat(int columnIndex) throws SQLException {
- return cs.getFloat(columnIndex);
- }
-
- public float getFloat(String columnName) throws SQLException {
- return cs.getFloat(columnName);
- }
-
- public int getInt(int columnIndex) throws SQLException {
- return cs.getInt(columnIndex);
- }
-
- public int getInt(String columnName) throws SQLException {
- return cs.getInt(columnName);
- }
-
- public long getLong(int columnIndex) throws SQLException {
- return cs.getLong(columnIndex);
- }
-
- public long getLong(String columnName) throws SQLException {
- return cs.getLong(columnName);
- }
-
- public ResultSetMetaData getMetaData() throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public Object getObject(String colName, Map map) throws SQLException {
- return cs.getObject(colName, map);
- }
-
- public Object getObject(int columnIndex) throws SQLException {
- return cs.getObject(columnIndex);
- }
-
- public Object getObject(String columnName) throws SQLException {
- return cs.getObject(columnName);
- }
-
- public Object getObject(int i, Map map) throws SQLException {
- return cs.getObject(i, map);
- }
-
- public Ref getRef(String colName) throws SQLException {
- return cs.getRef(colName);
- }
-
- public Ref getRef(int i) throws SQLException {
- return cs.getRef(i);
- }
-
- public int getRow() throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public short getShort(int columnIndex) throws SQLException {
- return cs.getShort(columnIndex);
- }
-
- public short getShort(String columnName) throws SQLException {
- return cs.getShort(columnName);
- }
-
- public Statement getStatement() throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public String getString(int columnIndex) throws SQLException {
- return cs.getString(columnIndex);
- }
-
- public String getString(String columnName) throws SQLException {
- return cs.getString(columnName);
- }
-
- public Time getTime(int columnIndex) throws SQLException {
- return cs.getTime(columnIndex);
- }
-
- public Time getTime(int columnIndex, Calendar cal) throws SQLException {
- return cs.getTime(columnIndex, cal);
- }
-
- public Time getTime(String columnName) throws SQLException {
- return cs.getTime(columnName);
- }
-
- public Time getTime(String columnName, Calendar cal) throws SQLException {
- return cs.getTime(columnName, cal);
- }
-
- public Timestamp getTimestamp(int columnIndex) throws SQLException {
- return cs.getTimestamp(columnIndex);
- }
-
- public Timestamp getTimestamp(int columnIndex, Calendar cal) throws
SQLException {
- return cs.getTimestamp(columnIndex, cal);
- }
-
- public Timestamp getTimestamp(String columnName) throws SQLException {
- return cs.getTimestamp(columnName);
- }
-
- public Timestamp getTimestamp(String columnName, Calendar cal) throws
SQLException {
- return cs.getTimestamp(columnName, cal);
- }
-
- public int getType() throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
+ public static ResultSet newProxy(CallableStatement cs) {
+ return (ResultSet)
Proxy.newProxyInstance(cs.getClass().getClassLoader(),new
Class[]{ResultSet.class}, new CallableStatementResultSet(cs));
}
- public InputStream getUnicodeStream(int columnIndex) throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public InputStream getUnicodeStream(String columnName) throws SQLException
{
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public URL getURL(int columnIndex) throws SQLException {
- return cs.getURL(columnIndex);
- }
-
- public URL getURL(String columnName) throws SQLException {
- return cs.getURL(columnName);
- }
-
- public SQLWarning getWarnings() throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public void insertRow() throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public boolean isAfterLast() throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public boolean isBeforeFirst() throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public boolean isFirst() throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public boolean isLast() throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public boolean last() throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public void moveToCurrentRow() throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public void moveToInsertRow() throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public boolean next() throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public boolean previous() throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public void refreshRow() throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public boolean relative(int rows) throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public boolean rowDeleted() throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public boolean rowInserted() throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public boolean rowUpdated() throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public void setFetchDirection(int direction) throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public void setFetchSize(int rows) throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public void updateArray(int columnIndex, Array x) throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public void updateArray(String columnName, Array x) throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public void updateAsciiStream(int columnIndex, InputStream x, int length)
throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public void updateAsciiStream(String columnName, InputStream x, int
length) throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public void updateBigDecimal(int columnIndex, BigDecimal x) throws
SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public void updateBigDecimal(String columnName, BigDecimal x) throws
SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public void updateBinaryStream(int columnIndex, InputStream x, int length)
throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public void updateBinaryStream(String columnName, InputStream x, int
length) throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public void updateBlob(int columnIndex, Blob x) throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public void updateBlob(String columnName, Blob x) throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public void updateBoolean(int columnIndex, boolean x) throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public void updateBoolean(String columnName, boolean x) throws
SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public void updateByte(int columnIndex, byte x) throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public void updateByte(String columnName, byte x) throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public void updateBytes(int columnIndex, byte x[]) throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public void updateBytes(String columnName, byte x[]) throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public void updateCharacterStream(int columnIndex, Reader x, int length)
throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public void updateCharacterStream(String columnName, Reader reader, int
length) throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public void updateClob(int columnIndex, Clob x) throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public void updateClob(String columnName, Clob x) throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public void updateDate(int columnIndex, Date x) throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public void updateDate(String columnName, Date x) throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public void updateDouble(int columnIndex, double x) throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public void updateDouble(String columnName, double x) throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public void updateFloat(int columnIndex, float x) throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public void updateFloat(String columnName, float x) throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public void updateInt(int columnIndex, int x) throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public void updateInt(String columnName, int x) throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public void updateLong(int columnIndex, long x) throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public void updateLong(String columnName, long x) throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public void updateNull(int columnIndex) throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public void updateNull(String columnName) throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public void updateObject(int columnIndex, Object x) throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public void updateObject(int columnIndex, Object x, int scale) throws
SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public void updateObject(String columnName, Object x) throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public void updateObject(String columnName, Object x, int scale) throws
SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public void updateRef(int columnIndex, Ref x) throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public void updateRef(String columnName, Ref x) throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public void updateRow() throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public void updateShort(int columnIndex, short x) throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public void updateShort(String columnName, short x) throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public void updateString(int columnIndex, String x) throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public void updateString(String columnName, String x) throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public void updateTime(int columnIndex, Time x) throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public void updateTime(String columnName, Time x) throws SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public void updateTimestamp(int columnIndex, Timestamp x) throws
SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public void updateTimestamp(String columnName, Timestamp x) throws
SQLException {
- throw new UnsupportedOperationException("CallableStatement does not
support this method.");
- }
-
- public boolean wasNull() throws SQLException {
- return cs.wasNull();
+ public Object invoke(Object proxy, Method method, Object[] args) throws
Throwable {
+ Method csMethod =
cs.getClass().getMethod(method.getName(),method.getParameterTypes());
+ return csMethod.invoke(cs,args);
}
}