[Proxool-cvs] proxool/src/java/org/logicalcobwebs/proxool ProxyConnection.java,1.28,1.29 ProxyDataba
UNMAINTAINED!
Brought to you by:
billhorsman
Update of /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/proxool
In directory sc8-pr-cvs1:/tmp/cvs-serv25985/src/java/org/logicalcobwebs/proxool
Modified Files:
ProxyConnection.java ProxyDatabaseMetaData.java
ProxyFactory.java ProxyStatement.java
Log Message:
Now uses Cglib 2.0
Index: ProxyConnection.java
===================================================================
RCS file: /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/proxool/ProxyConnection.java,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -d -r1.28 -r1.29
*** ProxyConnection.java 30 Sep 2003 18:39:08 -0000 1.28
--- ProxyConnection.java 12 Dec 2003 19:29:47 -0000 1.29
***************
*** 9,13 ****
import org.logicalcobwebs.logging.LogFactory;
! import net.sf.cglib.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
--- 9,16 ----
import org.logicalcobwebs.logging.LogFactory;
! import org.logicalcobwebs.cglib.proxy.MethodProxy;
! import org.logicalcobwebs.cglib.proxy.MethodInterceptor;
! import org.logicalcobwebs.cglib.proxy.InvocationHandler;
!
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
***************
*** 23,27 ****
* @author $Author$ (current maintainer)
*/
! class ProxyConnection extends AbstractProxyConnection implements InvocationHandler {
private static final Log LOG = LogFactory.getLog(ProxyConnection.class);
--- 26,30 ----
* @author $Author$ (current maintainer)
*/
! class ProxyConnection extends AbstractProxyConnection implements InvocationHandler, MethodInterceptor {
private static final Log LOG = LogFactory.getLog(ProxyConnection.class);
***************
*** 41,64 ****
}
! public Object invoke(Object proxy, Method m, Object[] args)
! throws Throwable {
Object result = null;
int argCount = args != null ? args.length : 0;
try {
! if (m.getName().equals(CLOSE_METHOD)) {
close();
! } else if (m.getName().equals(EQUALS_METHOD) && argCount == 1) {
result = new Boolean(equals(args[0]));
! } else if (m.getName().equals(IS_CLOSED_METHOD) && argCount == 0) {
result = new Boolean(isClosed());
! } else if (m.getName().equals(GET_META_DATA_METHOD) && argCount == 0) {
result = getMetaData();
! } else if (m.getName().equals(FINALIZE_METHOD)) {
super.finalize();
} else {
! if (m.getName().startsWith(ConnectionResetter.MUTATOR_PREFIX)) {
setNeedToReset(true);
}
! result = m.invoke(getConnection(), args);
}
--- 44,70 ----
}
! public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable {
! return invoke(proxy, method, args);
! }
!
! public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
Object result = null;
int argCount = args != null ? args.length : 0;
try {
! if (method.getName().equals(CLOSE_METHOD)) {
close();
! } else if (method.getName().equals(EQUALS_METHOD) && argCount == 1) {
result = new Boolean(equals(args[0]));
! } else if (method.getName().equals(IS_CLOSED_METHOD) && argCount == 0) {
result = new Boolean(isClosed());
! } else if (method.getName().equals(GET_META_DATA_METHOD) && argCount == 0) {
result = getMetaData();
! } else if (method.getName().equals(FINALIZE_METHOD)) {
super.finalize();
} else {
! if (method.getName().startsWith(ConnectionResetter.MUTATOR_PREFIX)) {
setNeedToReset(true);
}
! result = method.invoke(getConnection(), args);
}
***************
*** 106,109 ****
--- 112,118 ----
Revision history:
$Log$
+ Revision 1.29 2003/12/12 19:29:47 billhorsman
+ Now uses Cglib 2.0
+
Revision 1.28 2003/09/30 18:39:08 billhorsman
New test-before-use, test-after-use and fatal-sql-exception-wrapper-class properties.
Index: ProxyDatabaseMetaData.java
===================================================================
RCS file: /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/proxool/ProxyDatabaseMetaData.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** ProxyDatabaseMetaData.java 10 Sep 2003 22:21:04 -0000 1.5
--- ProxyDatabaseMetaData.java 12 Dec 2003 19:29:47 -0000 1.6
***************
*** 9,13 ****
import org.logicalcobwebs.logging.LogFactory;
! import net.sf.cglib.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
--- 9,16 ----
import org.logicalcobwebs.logging.LogFactory;
! import org.logicalcobwebs.cglib.proxy.MethodInterceptor;
! import org.logicalcobwebs.cglib.proxy.MethodProxy;
! import org.logicalcobwebs.cglib.proxy.InvocationHandler;
!
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
***************
*** 22,26 ****
* @author $Author$ (current maintainer)
*/
! class ProxyDatabaseMetaData extends AbstractDatabaseMetaData implements InvocationHandler {
private static final Log LOG = LogFactory.getLog(ProxyDatabaseMetaData.class);
--- 25,29 ----
* @author $Author$ (current maintainer)
*/
! class ProxyDatabaseMetaData extends AbstractDatabaseMetaData implements MethodInterceptor, InvocationHandler {
private static final Log LOG = LogFactory.getLog(ProxyDatabaseMetaData.class);
***************
*** 36,52 ****
}
! public Object invoke(Object proxy, Method m, Object[] args)
! throws Throwable {
Object result = null;
int argCount = args != null ? args.length : 0;
try {
! if (m.getName().equals(GET_CONNECTION_METHOD)) {
result = getConnection();
! } else if (m.getName().equals(EQUALS_METHOD) && argCount == 1) {
result = new Boolean(equals(args[0]));
! } else if (m.getName().equals(FINALIZE_METHOD)) {
super.finalize();
} else {
! result = m.invoke(getDatabaseMetaData(), args);
}
} catch (InvocationTargetException e) {
--- 39,58 ----
}
! public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable {
! return invoke(proxy, method, args);
! }
!
! public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
Object result = null;
int argCount = args != null ? args.length : 0;
try {
! if (method.getName().equals(GET_CONNECTION_METHOD)) {
result = getConnection();
! } else if (method.getName().equals(EQUALS_METHOD) && argCount == 1) {
result = new Boolean(equals(args[0]));
! } else if (method.getName().equals(FINALIZE_METHOD)) {
super.finalize();
} else {
! result = method.invoke(getDatabaseMetaData(), args);
}
} catch (InvocationTargetException e) {
***************
*** 66,69 ****
--- 72,78 ----
Revision history:
$Log$
+ Revision 1.6 2003/12/12 19:29:47 billhorsman
+ Now uses Cglib 2.0
+
Revision 1.5 2003/09/10 22:21:04 chr32
Removing > jdk 1.2 dependencies.
Index: ProxyFactory.java
===================================================================
RCS file: /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/proxool/ProxyFactory.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** ProxyFactory.java 30 Sep 2003 18:39:08 -0000 1.24
--- ProxyFactory.java 12 Dec 2003 19:29:47 -0000 1.25
***************
*** 9,14 ****
import org.logicalcobwebs.logging.LogFactory;
! import net.sf.cglib.InvocationHandler;
! import net.sf.cglib.Proxy;
import java.sql.CallableStatement;
import java.sql.Connection;
--- 9,15 ----
import org.logicalcobwebs.logging.LogFactory;
! import org.logicalcobwebs.cglib.proxy.Proxy;
! import org.logicalcobwebs.cglib.proxy.InvocationHandler;
!
import java.sql.CallableStatement;
import java.sql.Connection;
***************
*** 23,30 ****
* A central place to build proxy objects ({@link ProxyConnection connections}
* and {@link ProxyStatement statements}).
! *
! * @version $Revision$, $Date$
* @author Bill Horsman (bi...@lo...)
* @author $Author$ (current maintainer)
* @since Proxool 0.5
*/
--- 24,31 ----
* A central place to build proxy objects ({@link ProxyConnection connections}
* and {@link ProxyStatement statements}).
! *
* @author Bill Horsman (bi...@lo...)
* @author $Author$ (current maintainer)
+ * @version $Revision$, $Date$
* @since Proxool 0.5
*/
***************
*** 41,47 ****
Object delegate = Proxy.newProxyInstance(
! null,
! realConnection.getClass().getInterfaces(),
! new ProxyConnection(realConnection, id, url, connectionPool, status));
return (ProxyConnection) Proxy.getInvocationHandler(delegate);
--- 42,48 ----
Object delegate = Proxy.newProxyInstance(
! realConnection.getClass().getClassLoader(),
! realConnection.getClass().getInterfaces(),
! new ProxyConnection(realConnection, id, url, connectionPool, status));
return (ProxyConnection) Proxy.getInvocationHandler(delegate);
***************
*** 50,60 ****
/**
* Get a Connection from the ProxyConnection
! *
* @param proxyConnection where to find the connection
! * @return
*/
protected static Connection getConnection(ProxyConnectionIF proxyConnection) {
return (Connection) Proxy.newProxyInstance(
! null,
new Class[]{Connection.class},
(InvocationHandler) proxyConnection);
--- 51,61 ----
/**
* Get a Connection from the ProxyConnection
! *
* @param proxyConnection where to find the connection
! * @return
*/
protected static Connection getConnection(ProxyConnectionIF proxyConnection) {
return (Connection) Proxy.newProxyInstance(
! Connection.class.getClassLoader(),
new Class[]{Connection.class},
(InvocationHandler) proxyConnection);
***************
*** 63,66 ****
--- 64,68 ----
/**
* Gets the real Statement that we got from the delegate driver
+ *
* @param statement proxy statement
* @return delegate statement
***************
*** 75,78 ****
--- 77,81 ----
/**
* Gets the real Connection that we got from the delegate driver
+ *
* @param connection proxy connection
* @return deletgate connection
***************
*** 85,89 ****
}
! protected static Statement createProxyStatement(Statement delegate, ConnectionPool connectionPool, ProxyConnectionIF proxyConnection, String sqlStatement) {
// We can't use Class#getInterfaces since that doesn't take
// into account superclass interfaces. We could, laboriously,
--- 88,92 ----
}
! protected static Statement createProxyStatement(Statement delegate, ConnectionPool connectionPool, ProxyConnectionIF proxyConnection, String sqlStatement) {
// We can't use Class#getInterfaces since that doesn't take
// into account superclass interfaces. We could, laboriously,
***************
*** 103,111 ****
}
*/
! return (Statement) Proxy.newProxyInstance(null, interfaces, new ProxyStatement(delegate, connectionPool, proxyConnection, sqlStatement));
}
/**
* Create a new DatabaseMetaData from a connection
* @param connection the proxy connection we are using
* @return databaseMetaData
--- 106,115 ----
}
*/
! return (Statement) Proxy.newProxyInstance(delegate.getClass().getClassLoader(), interfaces, new ProxyStatement(delegate, connectionPool, proxyConnection, sqlStatement));
}
/**
* Create a new DatabaseMetaData from a connection
+ *
* @param connection the proxy connection we are using
* @return databaseMetaData
***************
*** 114,124 ****
protected static DatabaseMetaData getDatabaseMetaData(Connection connection, ProxyConnectionIF proxyConnection) throws SQLException {
return (DatabaseMetaData) Proxy.newProxyInstance(
! null,
new Class[]{DatabaseMetaData.class},
new ProxyDatabaseMetaData(connection, proxyConnection)
);
}
-
-
}
--- 118,126 ----
protected static DatabaseMetaData getDatabaseMetaData(Connection connection, ProxyConnectionIF proxyConnection) throws SQLException {
return (DatabaseMetaData) Proxy.newProxyInstance(
! DatabaseMetaData.class.getClassLoader(),
new Class[]{DatabaseMetaData.class},
new ProxyDatabaseMetaData(connection, proxyConnection)
);
}
}
***************
*** 126,129 ****
--- 128,134 ----
Revision history:
$Log$
+ Revision 1.25 2003/12/12 19:29:47 billhorsman
+ Now uses Cglib 2.0
+
Revision 1.24 2003/09/30 18:39:08 billhorsman
New test-before-use, test-after-use and fatal-sql-exception-wrapper-class properties.
Index: ProxyStatement.java
===================================================================
RCS file: /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/proxool/ProxyStatement.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** ProxyStatement.java 19 Oct 2003 09:50:33 -0000 1.24
--- ProxyStatement.java 12 Dec 2003 19:29:47 -0000 1.25
***************
*** 9,13 ****
import org.logicalcobwebs.logging.LogFactory;
! import net.sf.cglib.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
--- 9,16 ----
import org.logicalcobwebs.logging.LogFactory;
! import org.logicalcobwebs.cglib.proxy.MethodInterceptor;
! import org.logicalcobwebs.cglib.proxy.MethodProxy;
! import org.logicalcobwebs.cglib.proxy.InvocationHandler;
!
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
***************
*** 23,27 ****
* @author $Author$ (current maintainer)
*/
! class ProxyStatement extends AbstractProxyStatement implements InvocationHandler {
private static final Log LOG = LogFactory.getLog(ProxyStatement.class);
--- 26,30 ----
* @author $Author$ (current maintainer)
*/
! class ProxyStatement extends AbstractProxyStatement implements InvocationHandler, MethodInterceptor {
private static final Log LOG = LogFactory.getLog(ProxyStatement.class);
***************
*** 45,50 ****
}
! public Object invoke(Object proxy, Method method, Object[] args)
! throws Throwable {
Object result = null;
long startTime = System.currentTimeMillis();
--- 48,56 ----
}
! public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable {
! return invoke(proxy, method, args);
! }
!
! public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
Object result = null;
long startTime = System.currentTimeMillis();
***************
*** 130,133 ****
--- 136,142 ----
Revision history:
$Log$
+ Revision 1.25 2003/12/12 19:29:47 billhorsman
+ Now uses Cglib 2.0
+
Revision 1.24 2003/10/19 09:50:33 billhorsman
Drill down into InvocationTargetException during execution debug.
|