org.jmonit.support.jdbc
Class MonitoredDataSource

java.lang.Object
  extended by org.jmonit.support.jdbc.MonitoredDataSource
All Implemented Interfaces:
java.sql.Wrapper, javax.sql.CommonDataSource, javax.sql.DataSource

public class MonitoredDataSource
extends java.lang.Object
implements javax.sql.DataSource

DataSource wrapper that adds monitoring on JDBC connexions.

Author:
Nicolas De Loof

Constructor Summary
MonitoredDataSource()
           
MonitoredDataSource(javax.sql.DataSource dataSource)
          Constructor
 
Method Summary
 java.sql.Connection getConnection()
          
 java.sql.Connection getConnection(java.lang.String username, java.lang.String password)
          
 int getLoginTimeout()
          
 java.io.PrintWriter getLogWriter()
          
 javax.sql.DataSource init()
          Init
 java.lang.Object invoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args)
          
 boolean isWrapperFor(java.lang.Class<?> iface)
           
 void setDataSource(javax.sql.DataSource dataSource)
           
 void setDataSourceName(java.lang.String dataSourceName)
           
 void setLoginTimeout(int seconds)
          
 void setLogWriter(java.io.PrintWriter out)
          
 void setMonitor(Monitor monitor)
           
<T> T
unwrap(java.lang.Class<T> iface)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MonitoredDataSource

public MonitoredDataSource(javax.sql.DataSource dataSource)
Constructor

Parameters:
dataSource - the datasource to monitor

MonitoredDataSource

public MonitoredDataSource()
Method Detail

setDataSource

public void setDataSource(javax.sql.DataSource dataSource)
Parameters:
dataSource - the dataSource to set

setDataSourceName

public void setDataSourceName(java.lang.String dataSourceName)
Parameters:
dataSourceName - the dataSourceName to set

setMonitor

public void setMonitor(Monitor monitor)
Parameters:
monitor - the monitor to set

init

public javax.sql.DataSource init()
Init

Returns:
DataSource ready for use

getConnection

public java.sql.Connection getConnection()
                                  throws java.sql.SQLException

Specified by:
getConnection in interface javax.sql.DataSource
Throws:
java.sql.SQLException
See Also:
DataSource.getConnection()

getConnection

public java.sql.Connection getConnection(java.lang.String username,
                                         java.lang.String password)
                                  throws java.sql.SQLException

Specified by:
getConnection in interface javax.sql.DataSource
Throws:
java.sql.SQLException
See Also:
DataSource.getConnection(java.lang.String, java.lang.String)

invoke

public java.lang.Object invoke(java.lang.Object proxy,
                               java.lang.reflect.Method method,
                               java.lang.Object[] args)
                        throws java.lang.Throwable

Throws:
java.lang.Throwable
See Also:
InvocationHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])

getLoginTimeout

public int getLoginTimeout()
                    throws java.sql.SQLException

Specified by:
getLoginTimeout in interface javax.sql.CommonDataSource
Throws:
java.sql.SQLException
See Also:
CommonDataSource.getLoginTimeout()

getLogWriter

public java.io.PrintWriter getLogWriter()
                                 throws java.sql.SQLException

Specified by:
getLogWriter in interface javax.sql.CommonDataSource
Throws:
java.sql.SQLException
See Also:
CommonDataSource.getLogWriter()

setLoginTimeout

public void setLoginTimeout(int seconds)
                     throws java.sql.SQLException

Specified by:
setLoginTimeout in interface javax.sql.CommonDataSource
Throws:
java.sql.SQLException
See Also:
CommonDataSource.setLoginTimeout(int)

setLogWriter

public void setLogWriter(java.io.PrintWriter out)
                  throws java.sql.SQLException

Specified by:
setLogWriter in interface javax.sql.CommonDataSource
Throws:
java.sql.SQLException
See Also:
CommonDataSource.setLogWriter(java.io.PrintWriter)

isWrapperFor

public boolean isWrapperFor(java.lang.Class<?> iface)
                     throws java.sql.SQLException
Specified by:
isWrapperFor in interface java.sql.Wrapper
Throws:
java.sql.SQLException

unwrap

public <T> T unwrap(java.lang.Class<T> iface)
         throws java.sql.SQLException
Specified by:
unwrap in interface java.sql.Wrapper
Throws:
java.sql.SQLException


Copyright © 2007 Nicolas De Loof. All Rights Reserved.