public synchronized Object invoke(final Object proxy, final Method method,
                                      final Object[] args) throws Throwable {

        Object result;

        switch (_computeSurrogateType(method)) {

            case WIH_CLOSE_SURROGATE : {
                closeSurrogate();

                result = null;

                break;
            }
            case WIH_IS_CLOSED_SURROGATE : {
                result = isClosedSurrogate() ? Boolean.TRUE
                                             : Boolean.FALSE;

                break;
            }
            case WIH_GET_PARENT_SURROGATE : {
                checkSurrogateClosed();

                result = getParentSurrogate(method, args);

                break;
            }
            case WIH_GET_DATABASEMETADATA_SURROGATE : {
                checkSurrogateClosed();

                result = getDatabaseMetaDataSurrogate(method, args);

                break;
            }
            case WIH_CREATE_OR_PREPARE_STATEMENT_SURROGATE : {
                checkSurrogateClosed();

                result = getCreatedOrPreparedStatementSurrogate(method, args);

                break;
            }
            case WIH_GET_RESULTSET_SURROGATE : {
                checkSurrogateClosed();

                result = getResultSetSurrogate(method, args);

                break;
            }
            case WIH_UNWRAP_SURROGATE : {
                checkSurrogateClosed();

                result = unwrapSurrogate(method, args);

                break;
            }
            case WIH_GET_ARRAY_SURROGATE : {
                checkSurrogateClosed();

                result = getArraySurrogate(method, args);

                break;
            }
            case WIH_NO_SURROGATE :
            default : {
                checkSurrogateClosed();

                result = method.invoke(delegate, args);

                break;
            }
        }

        return result;
    }
public synchronized Object invoke ( final Object proxy , final Method method , final Object [ ] args ) throws Throwable { Object result ; switch ( _computeSurrogateType ( method ) ) { case WIH_CLOSE_SURROGATE : { closeSurrogate ( ) ; result = null ; break ; } case WIH_IS_CLOSED_SURROGATE : { result = isClosedSurrogate ( ) ? Boolean . TRUE : Boolean . FALSE ; break ; } case WIH_GET_PARENT_SURROGATE : { checkSurrogateClosed ( ) ; result = getParentSurrogate ( method , args ) ; break ; } case WIH_GET_DATABASEMETADATA_SURROGATE : { checkSurrogateClosed ( ) ; result = getDatabaseMetaDataSurrogate ( method , args ) ; break ; } case WIH_CREATE_OR_PREPARE_STATEMENT_SURROGATE : { checkSurrogateClosed ( ) ; result = getCreatedOrPreparedStatementSurrogate ( method , args ) ; break ; } case WIH_GET_RESULTSET_SURROGATE : { checkSurrogateClosed ( ) ; result = getResultSetSurrogate ( method , args ) ; break ; } case WIH_UNWRAP_SURROGATE : { checkSurrogateClosed ( ) ; result = unwrapSurrogate ( method , args ) ; break ; } case WIH_GET_ARRAY_SURROGATE : { checkSurrogateClosed ( ) ; result = getArraySurrogate ( method , args ) ; break ; } case WIH_NO_SURROGATE : default : { checkSurrogateClosed ( ) ; result = method . invoke ( delegate , args ) ; break ; } } return result ; }
@todo: - Synchronization can be made more granular if performance suffers.
- Requires some private lock objects and synchronized blocks in
certain methods.
- This was the obvious and easy synchronization point to pick
initially for prototyping purposes