org.dbmaintain.datasource
Class SimpleDataSource.SimpleDataSourceInvocationHandler

java.lang.Object
  extended by org.dbmaintain.datasource.SimpleDataSource.SimpleDataSourceInvocationHandler
All Implemented Interfaces:
InvocationHandler
Enclosing class:
SimpleDataSource

protected static class SimpleDataSource.SimpleDataSourceInvocationHandler
extends Object
implements InvocationHandler

Invocation handler for a dynamic proxy that implements the javax.sql.DataSource interface. This invocation handler implements the getConnection method: this method will create a new database connection to the database configured with the driverClassName, url, userName and password given with the constructor invocation.


Constructor Summary
protected SimpleDataSource.SimpleDataSourceInvocationHandler(String driverClassName, String url, String userName, String password)
           
 
Method Summary
protected  Connection getDatabaseConnection()
           
 Object invoke(Object dataSourceProxy, Method method, Object[] args)
          Handles all invocations on the DataSource.
protected  boolean isEqualsMethod(Method method)
           
protected  boolean isHashCodeMethod(Method method)
           
protected  boolean isParameterLessGetConnectionMethod(Method method)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleDataSource.SimpleDataSourceInvocationHandler

protected SimpleDataSource.SimpleDataSourceInvocationHandler(String driverClassName,
                                                             String url,
                                                             String userName,
                                                             String password)
Method Detail

invoke

public Object invoke(Object dataSourceProxy,
                     Method method,
                     Object[] args)
              throws Throwable
Handles all invocations on the DataSource. We only implement the parameterless getConnection method, since this is the only method used in dbmaintain

Specified by:
invoke in interface InvocationHandler
Parameters:
dataSourceProxy - The proxy that represents the datasource
method - The method invoked on the datasource
args - The arguments of the invoked method
Returns:
The return object
Throws:
Throwable

getDatabaseConnection

protected Connection getDatabaseConnection()
Returns:
A connection to the database

isEqualsMethod

protected boolean isEqualsMethod(Method method)
Parameters:
method - The invoked method
Returns:
Whether the given method is the equals method

isHashCodeMethod

protected boolean isHashCodeMethod(Method method)
Parameters:
method - The invoked method
Returns:
Whether the given method is the hashCode method

isParameterLessGetConnectionMethod

protected boolean isParameterLessGetConnectionMethod(Method method)
Parameters:
method - The method invoked on the datasource proxy
Returns:
whether the given method is the method DataSource.getConnection()


Copyright © 2011. All Rights Reserved.