package com.github.witoldsz.ultm.internal; import java.io.PrintWriter; import java.sql.Connection; import java.sql.SQLException; import java.sql.SQLFeatureNotSupportedException; import java.util.logging.Logger; import javax.sql.DataSource; /** * * @author witoldsz */ public class ManagedDataSource implements DataSource { private final DataSource delegate; private final ConnectionProvider supplier; public ManagedDataSource(DataSource delegate, ConnectionProvider supplier) { this.delegate = delegate; this.supplier = supplier; } @Override public Connection getConnection() throws SQLException { return supplier.get(); } @Override public Connection getConnection(String username, String password) throws SQLException { throw new UnsupportedOperationException(); } // // // delegate what's left (auto-generated) // // @Override public <T> T unwrap(Class<T> iface) throws SQLException { return delegate.unwrap(iface); } @Override public boolean isWrapperFor(Class<?> iface) throws SQLException { return delegate.isWrapperFor(iface); } @Override public PrintWriter getLogWriter() throws SQLException { return delegate.getLogWriter(); } @Override public void setLogWriter(PrintWriter out) throws SQLException { delegate.setLogWriter(out); } @Override public void setLoginTimeout(int seconds) throws SQLException { delegate.setLoginTimeout(seconds); } @Override public int getLoginTimeout() throws SQLException { return delegate.getLoginTimeout(); } @Override public Logger getParentLogger() throws SQLFeatureNotSupportedException { return delegate.getParentLogger(); } }