org.opennms.netmgt.config
Class BaseConnectionFactory

java.lang.Object
  extended by org.opennms.netmgt.config.BaseConnectionFactory
All Implemented Interfaces:
Wrapper, CommonDataSource, DataSource, ClosableDataSource
Direct Known Subclasses:
C3P0ConnectionFactory, DBPoolConnectionFactory, TomcatJdbcPoolConnectionFactory

public abstract class BaseConnectionFactory
extends Object
implements ClosableDataSource

C3P0ConnectionFactory class.


Constructor Summary
protected BaseConnectionFactory(InputStream stream, String dsName)
           
protected BaseConnectionFactory(String configFile, String dsName)
           
 
Method Summary
 void close()
          close
abstract  Connection getConnection()
          getConnection
abstract  Connection getConnection(String username, String password)
          
abstract  DataSource getDataSource()
          getDataSource
abstract  int getLoginTimeout()
          getLoginTimeout
abstract  PrintWriter getLogWriter()
          getLogWriter
abstract  String getUrl()
          getUrl
abstract  String getUser()
          getUser
protected abstract  void initializePool(JdbcDataSource ds)
           
 boolean isWrapperFor(Class<?> iface)
          isWrapperFor
abstract  void setLoginTimeout(int seconds)
          How long, in seconds, to attempt to make a connection to the database.
abstract  void setLogWriter(PrintWriter out)
          
abstract  void setUrl(String url)
          setUrl
abstract  void setUser(String user)
          setUser
<T> T
unwrap(Class<T> iface)
          unwrap
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.opennms.netmgt.config.ClosableDataSource
setIdleTimeout, setMaxPool, setMaxSize, setMinPool
 

Constructor Detail

BaseConnectionFactory

protected BaseConnectionFactory(InputStream stream,
                                String dsName)
                         throws org.exolab.castor.xml.MarshalException,
                                org.exolab.castor.xml.ValidationException,
                                PropertyVetoException,
                                SQLException
Parameters:
stream - A configuration file as an InputStream.
dsName - The data source's name.
Throws:
org.exolab.castor.xml.MarshalException - if any.
org.exolab.castor.xml.ValidationException - if any.
PropertyVetoException - if any.
SQLException - if any.

BaseConnectionFactory

protected BaseConnectionFactory(String configFile,
                                String dsName)
                         throws IOException,
                                org.exolab.castor.xml.MarshalException,
                                org.exolab.castor.xml.ValidationException,
                                PropertyVetoException,
                                SQLException
Parameters:
configFile - A configuration file name.
dsName - The data source's name.
Throws:
IOException - if any.
org.exolab.castor.xml.MarshalException - if any.
org.exolab.castor.xml.ValidationException - if any.
PropertyVetoException - if any.
SQLException - if any.
Method Detail

initializePool

protected abstract void initializePool(JdbcDataSource ds)
                                throws SQLException
Throws:
SQLException

getConnection

public abstract Connection getConnection()
                                  throws SQLException

getConnection

Specified by:
getConnection in interface DataSource
Returns:
a Connection object.
Throws:
SQLException - if any.

getUrl

public abstract String getUrl()

getUrl

Returns:
a String object.

setUrl

public abstract void setUrl(String url)

setUrl

Parameters:
url - a String object.

getUser

public abstract String getUser()

getUser

Returns:
a String object.

setUser

public abstract void setUser(String user)

setUser

Parameters:
user - a String object.

getDataSource

public abstract DataSource getDataSource()

getDataSource

Returns:
a DataSource object.

getConnection

public abstract Connection getConnection(String username,
                                         String password)
                                  throws SQLException

Specified by:
getConnection in interface DataSource
Throws:
SQLException

getLogWriter

public abstract PrintWriter getLogWriter()
                                  throws SQLException

getLogWriter

Specified by:
getLogWriter in interface CommonDataSource
Returns:
a PrintWriter object.
Throws:
SQLException - if any.

setLogWriter

public abstract void setLogWriter(PrintWriter out)
                           throws SQLException

Specified by:
setLogWriter in interface CommonDataSource
Throws:
SQLException

setLoginTimeout

public abstract void setLoginTimeout(int seconds)
                              throws SQLException
How long, in seconds, to attempt to make a connection to the database.

Specified by:
setLoginTimeout in interface CommonDataSource
Specified by:
setLoginTimeout in interface ClosableDataSource
Throws:
SQLException

getLoginTimeout

public abstract int getLoginTimeout()
                             throws SQLException

getLoginTimeout

Specified by:
getLoginTimeout in interface CommonDataSource
Returns:
a int.
Throws:
SQLException - if any.

close

public void close()
           throws SQLException

close

Specified by:
close in interface ClosableDataSource
Throws:
SQLException - if any.

unwrap

public <T> T unwrap(Class<T> iface)
         throws SQLException

unwrap

Specified by:
unwrap in interface Wrapper
Type Parameters:
T - a T object.
Parameters:
iface - a Class object.
Returns:
a T object.
Throws:
SQLException - if any.

isWrapperFor

public boolean isWrapperFor(Class<?> iface)
                     throws SQLException

isWrapperFor

Specified by:
isWrapperFor in interface Wrapper
Parameters:
iface - a Class object.
Returns:
a boolean.
Throws:
SQLException - if any.


Copyright © 2011. All Rights Reserved.