Package groovy.sql
Class GroovyResultSetProxy
- java.lang.Object
-
- groovy.sql.GroovyResultSetProxy
-
- All Implemented Interfaces:
InvocationHandler
public final class GroovyResultSetProxy extends Object implements InvocationHandler
GroovyResultSetProxy is used to create a proxy for GroovyResultSet. Due to the version incompatibility between java 6 and older versions methods with additional logic were moved into an extension class. When getting properties or calling methods, the runtime will try to first execute these on the extension and then on the ResultSet itself. This way it is possible to replace and add methods. To overload methods from ResultSet all methods have to be implemented on the extension class.
-
-
Constructor Summary
Constructors Constructor Description GroovyResultSetProxy(GroovyResultSetExtension ext)
Creates a new proxy instance with a custom extension.GroovyResultSetProxy(ResultSet set)
Creates a new proxy instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description GroovyResultSet
getImpl()
Gets a proxy instance that can be used as GroovyResultSet.Object
invoke(Object proxy, Method method, Object[] args)
Invokes a method for the GroovyResultSet.
-
-
-
Constructor Detail
-
GroovyResultSetProxy
public GroovyResultSetProxy(ResultSet set)
Creates a new proxy instance. This will create the extension automatically using GroovyResultSetExtension- Parameters:
set
- the result set to delegate to- See Also:
GroovyResultSetExtension
-
GroovyResultSetProxy
public GroovyResultSetProxy(GroovyResultSetExtension ext)
Creates a new proxy instance with a custom extension.- Parameters:
ext
- the extension- See Also:
GroovyResultSetExtension
-
-
Method Detail
-
invoke
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
Invokes a method for the GroovyResultSet. This will try to invoke the given method first on the extension and then on the result set given as proxy parameter.- Specified by:
invoke
in interfaceInvocationHandler
- Parameters:
proxy
- the result setmethod
- the method name of this method will be used to make a call on the extension. If this fails the call will be done on the proxy insteadargs
- for the call- Throws:
Throwable
- See Also:
ResultSet
,InvocationHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
-
getImpl
public GroovyResultSet getImpl()
Gets a proxy instance that can be used as GroovyResultSet.- Returns:
- the proxy
-
-