ConnectionLabelingCallback
public interface ConnectionLabelingCallback
The callback object is registered with the Universal Connection Pool allowing applications to configure connections based on requested labels, as well as calculating the cost of such configuration that sets the connections to the desired states.
The cost(...)
method projects the cost of configuring
connections considering label-matching differences. Upon a
connection-borrowing request, the connection pool uses this method to select
a connection with the least reconfiguration cost and returns that
connection to the application. The cost is represented in the form of an
integer value.
The configure(...)
method is called by the connection pool
on the selected connection before returning it to the application.
It is an error to register more than one connection labeling
callback with the connection pool. Any such attempt results
in a UniversalConnectionPoolException
at the pool layer
or an exception specific to the type of a Universal Connection Pool
Adapter (for example, JDBC, JCA, and so forth).
UniversalConnectionPool
,
PoolDataSource
Modifier and Type | Method | Description |
---|---|---|
boolean |
configure(java.util.Properties requestedLabels,
java.lang.Object connection) |
Configures the selected connection for a borrowing request before
returning the connection to the application.
|
int |
cost(java.util.Properties requestedLabels,
java.util.Properties currentLabels) |
Projects the cost of configuring connections considering label-matching
differences.
|
int cost(java.util.Properties requestedLabels, java.util.Properties currentLabels)
requestedLabels
- The desired labels on a connection request.currentLabels
- The current labels associated with a connection.boolean configure(java.util.Properties requestedLabels, java.lang.Object connection)
A Universal Connection Pool Adapter passes in a resource-specific
connection appropriate for the Adapter type. For example, a JDBC
Adapter could pass in a java.sql.Connection
.
requestedLabels
- The desired labels on a connection request.connection
- The connection chosen by the pool to return
to the application.true
;
otherwise, return false
.