T
- the generic type of the connection being wrapped by each individual instance@NoImplement public interface ConnectionHandler<T>
This is actually a wrapper which provides an unique API for managing connections of different
types and using different policies. For example, clients of this API will use the getConnection()
method to obtain the actual connection that's been managed, without independently of the connection
being pooled, cached, lazy, validated, reconnected, etc.
Modifier and Type | Method and Description |
---|---|
T |
getConnection()
Returns the connection that's being wrapped.
|
void |
invalidate()
Similar to
release() but for cases in which the wrapped connection is in an error state and should
not be used anymore. |
void |
release()
When a component requests an instance of this interface, it
becomes obligated to invoke this method after it no longer requires
such instance.
|
T getConnection() throws ConnectionException
No guarantees are offered regarding how this method provisions the connection.
The only commitment this method takes is that it will either provide a
connection ready to be used or throw a ConnectionException
ConnectionException
- if a valid connection could not be obtainedvoid release()
Just like with getConnection()
, the implications of executing
this method are not guaranteed. Depending on the implementation,
the connection could be closed, returned to a pooled, recycled, etc.
It is not to be assumed that any resources allocated by the wrapped connection
will be freed after invoking this method.
The only strong piece on the contract is the user's obligation to invoke this method once it's done with the instance
void invalidate()
release()
but for cases in which the wrapped connection is in an error state and should
not be used anymore.
Just like with release()
, the implications of executing
this method are not guaranteed. Depending on the implementation, the effect could be the same as release()
,
pool invalidation, cache eviction, etc.
It is not to be assumed that any resources allocated by the wrapped connection will be freed after invoking this method.
Copyright © 2018. All rights reserved.