/** * Generates a proxy wrapping the ResultSet. * * @param resultSet The resultSet to wrap. * @param columnNameCache The cache storing data for converting column names to column indexes. * @param serviceRegistry Access to any needed services * * @return The generated proxy. */ public static ResultSet generateProxy( ResultSet resultSet, ColumnNameCache columnNameCache, ServiceRegistry serviceRegistry) { return serviceRegistry.getService( ClassLoaderService.class ).generateProxy( new ResultSetWrapperProxy( resultSet, columnNameCache ), ResultSet.class ); }
@Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if ( "findColumn".equals( method.getName() ) ) { return findColumn( (String) args[0] ); } if ( isFirstArgColumnLabel( method ) ) { Method columnIndexMethod = NAME_TO_INDEX_METHOD_MAPPING.get( new ResultSetMethodKey( method.getName(), method.getParameterTypes() ) ); if ( columnIndexMethod != null ) { try { final Integer columnIndex = findColumn( (String) args[0] ); return invokeMethod( columnIndexMethod, buildColumnIndexMethodArgs( args, columnIndex ) ); } catch ( SQLException ex ) { final String msg = "Exception getting column index for column: [" + args[0] + "].\nReverting to using: [" + args[0] + "] as first argument for method: [" + method + "]"; SQL_EXCEPTION_HELPER.logExceptions( ex, msg ); } } } return invokeMethod( method, args ); }
@Override public ResultSet wrap(ResultSet resultSet, ColumnNameCache columnNameCache) { return ResultSetWrapperProxy.generateProxy( resultSet, columnNameCache, serviceRegistry ); } }
/** * Generates a proxy wrapping the ResultSet. * * @param resultSet The resultSet to wrap. * @param columnNameCache The cache storing data for converting column names to column indexes. * @return The generated proxy. */ public static ResultSet generateProxy(ResultSet resultSet, ColumnNameCache columnNameCache) { return ( ResultSet ) Proxy.newProxyInstance( getProxyClassLoader(), PROXY_INTERFACES, new ResultSetWrapperProxy( resultSet, columnNameCache ) ); }
/** * Generates a proxy wrapping the ResultSet. * * @param resultSet The resultSet to wrap. * @param columnNameCache The cache storing data for converting column names to column indexes. * @return The generated proxy. */ public static ResultSet generateProxy(ResultSet resultSet, ColumnNameCache columnNameCache) { return ( ResultSet ) Proxy.newProxyInstance( getProxyClassLoader(), PROXY_INTERFACES, new ResultSetWrapperProxy( resultSet, columnNameCache ) ); }
@Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if ( "findColumn".equals( method.getName() ) ) { return findColumn( (String) args[0] ); } if ( isFirstArgColumnLabel( method ) ) { Method columnIndexMethod = NAME_TO_INDEX_METHOD_MAPPING.get( new ResultSetMethodKey( method.getName(), method.getParameterTypes() ) ); if ( columnIndexMethod != null ) { try { final Integer columnIndex = findColumn( (String) args[0] ); return invokeMethod( columnIndexMethod, buildColumnIndexMethodArgs( args, columnIndex ) ); } catch ( SQLException ex ) { final String msg = "Exception getting column index for column: [" + args[0] + "].\nReverting to using: [" + args[0] + "] as first argument for method: [" + method + "]"; SQL_EXCEPTION_HELPER.logExceptions( ex, msg ); } } } return invokeMethod( method, args ); }
@Override public ResultSet wrap(ResultSet resultSet, ColumnNameCache columnNameCache) { return ResultSetWrapperProxy.generateProxy( resultSet, columnNameCache, serviceRegistry ); } }
/** * Generates a proxy wrapping the ResultSet. * * @param resultSet The resultSet to wrap. * @param columnNameCache The cache storing data for converting column names to column indexes. * @param serviceRegistry Access to any needed services * * @return The generated proxy. */ public static ResultSet generateProxy( ResultSet resultSet, ColumnNameCache columnNameCache, ServiceRegistry serviceRegistry) { return serviceRegistry.getService( ClassLoaderService.class ).generateProxy( new ResultSetWrapperProxy( resultSet, columnNameCache ), ResultSet.class ); }
@Override @SuppressWarnings( {"UnnecessaryBoxing"}) public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if ( "findColumn".equals( method.getName() ) ) { return Integer.valueOf( findColumn( ( String ) args[0] ) ); } if ( isFirstArgColumnLabel( method, args ) ) { try { int columnIndex = findColumn( ( String ) args[0] ); return invokeMethod( locateCorrespondingColumnIndexMethod( method ), buildColumnIndexMethodArgs( args, columnIndex ) ); } catch ( SQLException ex ) { StringBuffer buf = new StringBuffer() .append( "Exception getting column index for column: [" ) .append( args[0] ) .append( "].\nReverting to using: [" ) .append( args[0] ) .append( "] as first argument for method: [" ) .append( method ) .append( "]" ); sqlExceptionHelper.logExceptions( ex, buf.toString() ); } catch ( NoSuchMethodException ex ) { LOG.unableToSwitchToMethodUsingColumnIndex( method ); } } return invokeMethod( method, args ); }
/** * {@inheritDoc} */ public ResultSet wrap(ResultSet resultSet, ColumnNameCache columnNameCache) { return ResultSetWrapperProxy.generateProxy( resultSet, columnNameCache ); } }
@Override @SuppressWarnings( {"UnnecessaryBoxing"}) public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if ( "findColumn".equals( method.getName() ) ) { return Integer.valueOf( findColumn( ( String ) args[0] ) ); } if ( isFirstArgColumnLabel( method, args ) ) { try { int columnIndex = findColumn( ( String ) args[0] ); return invokeMethod( locateCorrespondingColumnIndexMethod( method ), buildColumnIndexMethodArgs( args, columnIndex ) ); } catch ( SQLException ex ) { StringBuffer buf = new StringBuffer() .append( "Exception getting column index for column: [" ) .append( args[0] ) .append( "].\nReverting to using: [" ) .append( args[0] ) .append( "] as first argument for method: [" ) .append( method ) .append( "]" ); sqlExceptionHelper.logExceptions( ex, buf.toString() ); } catch ( NoSuchMethodException ex ) { LOG.unableToSwitchToMethodUsingColumnIndex( method ); } } return invokeMethod( method, args ); }
/** * {@inheritDoc} */ public ResultSet wrap(ResultSet resultSet, ColumnNameCache columnNameCache) { return ResultSetWrapperProxy.generateProxy( resultSet, columnNameCache ); } }