| | |
| | | return new ConnectionFactory() { |
| | | |
| | | @Override |
| | | public void close() { |
| | | factory.close(); |
| | | } |
| | | |
| | | @Override |
| | | public Connection getConnection() throws ErrorResultException { |
| | | return factory.getConnection(); |
| | | } |
| | |
| | | return factory.getConnectionAsync(handler); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public String toString() { |
| | | return name; |
| | |
| | | * @return An uncloseable view of the provided connection. |
| | | */ |
| | | public static Connection uncloseable(Connection connection) { |
| | | return new AbstractConnectionWrapper(connection) { |
| | | return new AbstractConnectionWrapper<Connection>(connection) { |
| | | @Override |
| | | public void close() { |
| | | // Do nothing. |
| | |
| | | }; |
| | | } |
| | | |
| | | /** |
| | | * Returns an uncloseable view of the provided connection factory. Attempts |
| | | * to call {@link ConnectionFactory#close()} will be ignored. |
| | | * |
| | | * @param factory |
| | | * The connection factory whose {@code close} method is to be |
| | | * disabled. |
| | | * @return An uncloseable view of the provided connection factory. |
| | | */ |
| | | public static ConnectionFactory uncloseable(final ConnectionFactory factory) { |
| | | return new ConnectionFactory() { |
| | | |
| | | @Override |
| | | public FutureResult<Connection> getConnectionAsync( |
| | | ResultHandler<? super Connection> handler) { |
| | | return factory.getConnectionAsync(handler); |
| | | } |
| | | |
| | | @Override |
| | | public Connection getConnection() throws ErrorResultException { |
| | | return factory.getConnection(); |
| | | } |
| | | |
| | | @Override |
| | | public void close() { |
| | | // Do nothing. |
| | | } |
| | | }; |
| | | } |
| | | |
| | | // Prevent instantiation. |
| | | private Connections() { |
| | | // Do nothing. |