groovy.sql
Class GroovyResultSetProxy

java.lang.Object
  extended by groovy.sql.GroovyResultSetProxy
All Implemented Interfaces:
java.lang.reflect.InvocationHandler

public final class GroovyResultSetProxy
extends java.lang.Object
implements java.lang.reflect.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.

Author:
Jochen Theodorou

Field Summary
private  GroovyResultSetExtension extension
           
private  MetaClass metaClass
           
 
Constructor Summary
GroovyResultSetProxy(GroovyResultSetExtension ext)
          Creates a new proxy instance with a custom extension.
GroovyResultSetProxy(java.sql.ResultSet set)
          Creates a new procy instance.
 
Method Summary
 GroovyResultSet getImpl()
          Gets a proxy instance that can be used as GroovyResultSet.
private  MetaClass getMetaClass()
           
 java.lang.Object invoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args)
          Invokes a method for the GroovyResultSet.
private  MetaClass setMetaClass(MetaClass mc)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

extension

private GroovyResultSetExtension extension

metaClass

private MetaClass metaClass
Constructor Detail

GroovyResultSetProxy

public GroovyResultSetProxy(java.sql.ResultSet set)
Creates a new procy 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 java.lang.Object invoke(java.lang.Object proxy,
                               java.lang.reflect.Method method,
                               java.lang.Object[] args)
                        throws java.lang.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 interface java.lang.reflect.InvocationHandler
Parameters:
proxy - the result set
method - 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 instead
args - for the call
Throws:
java.lang.Throwable
See Also:
ResultSet, InvocationHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])

setMetaClass

private MetaClass setMetaClass(MetaClass mc)

getMetaClass

private MetaClass getMetaClass()

getImpl

public GroovyResultSet getImpl()
Gets a proxy instance that can be used as GroovyResultSet.

Returns:
the proxy


Copyright © ${year} The Codehaus. All Rights Reserved.