org.apache.openjpa.lib.jdbc
Class DelegatingDataSource

java.lang.Object
  extended by org.apache.openjpa.lib.jdbc.DelegatingDataSource
All Implemented Interfaces:
Wrapper, CommonDataSource, DataSource, Closeable
Direct Known Subclasses:
DataSourceFactory.DefaultsDataSource, DecoratingDataSource

public abstract class DelegatingDataSource
extends Object
implements DataSource, Closeable

Wrapper around an existing data source. Subclasses can override the methods whose behavior they mean to change. The equals and hashCode methods pass through to the base underlying data store.

Author:
Abe White

Field Summary
(package private) static Constructor<DelegatingDataSource> concreteImpl
           
 
Constructor Summary
DelegatingDataSource(DataSource ds)
          Constructor.
 
Method Summary
protected  void appendInfo(StringBuffer buf)
           
 void close()
           
protected abstract  void enforceAbstract()
          Marker to enforce that subclasses of this class are abstract.
 boolean equals(Object other)
           
 Connection getConnection()
           
 Connection getConnection(String user, String pass)
           
 DataSource getDelegate()
          Return the wrapped data source.
 DataSource getInnermostDelegate()
          Return the inner-most wrapped delegate.
 int getLoginTimeout()
           
 PrintWriter getLogWriter()
           
 int hashCode()
           
 boolean isWrapperFor(Class iface)
           
static DelegatingDataSource newInstance(DataSource ds)
          Constructor for the concrete implementation of this abstract class.
 void setLoginTimeout(int timeout)
           
 void setLogWriter(PrintWriter out)
           
 String toString()
           
 Object unwrap(Class iface)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

concreteImpl

static final Constructor<DelegatingDataSource> concreteImpl
Constructor Detail

DelegatingDataSource

public DelegatingDataSource(DataSource ds)
Constructor. Supply wrapped data source.

Method Detail

newInstance

public static DelegatingDataSource newInstance(DataSource ds)
Constructor for the concrete implementation of this abstract class.


enforceAbstract

protected abstract void enforceAbstract()
Marker to enforce that subclasses of this class are abstract.


getDelegate

public DataSource getDelegate()
Return the wrapped data source.


getInnermostDelegate

public DataSource getInnermostDelegate()
Return the inner-most wrapped delegate.


hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object other)
Overrides:
equals in class Object

toString

public String toString()
Overrides:
toString in class Object

appendInfo

protected void appendInfo(StringBuffer buf)

getLogWriter

public PrintWriter getLogWriter()
                         throws SQLException
Specified by:
getLogWriter in interface CommonDataSource
Throws:
SQLException

setLogWriter

public void setLogWriter(PrintWriter out)
                  throws SQLException
Specified by:
setLogWriter in interface CommonDataSource
Throws:
SQLException

getLoginTimeout

public int getLoginTimeout()
                    throws SQLException
Specified by:
getLoginTimeout in interface CommonDataSource
Throws:
SQLException

setLoginTimeout

public void setLoginTimeout(int timeout)
                     throws SQLException
Specified by:
setLoginTimeout in interface CommonDataSource
Throws:
SQLException

getConnection

public Connection getConnection()
                         throws SQLException
Specified by:
getConnection in interface DataSource
Throws:
SQLException

getConnection

public Connection getConnection(String user,
                                String pass)
                         throws SQLException
Specified by:
getConnection in interface DataSource
Throws:
SQLException

close

public void close()
           throws Exception
Specified by:
close in interface Closeable
Throws:
Exception

isWrapperFor

public boolean isWrapperFor(Class iface)
Specified by:
isWrapperFor in interface Wrapper

unwrap

public Object unwrap(Class iface)
Specified by:
unwrap in interface Wrapper


Copyright © 2006-2010 Apache Software Foundation. All Rights Reserved.