public class ConnectionProviderManager
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
ConnectionProviderManager.ConnectionInitFunc |
| Constructor and Description |
|---|
ConnectionProviderManager(ConnectionProvider defaultProvider,
@Nullable ConnectionProvider effectiveConnProvider)
ConnectionProviderManager constructor. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
acceptsStrategy(HostRole role,
java.lang.String strategy)
Returns a boolean indicating if the available
ConnectionProvider instances support the
selection of a host with the requested role and strategy via getHostSpecByStrategy(java.util.List<software.amazon.jdbc.HostSpec>, software.amazon.jdbc.HostRole, java.lang.String, java.util.Properties). |
ConnectionProvider |
getConnectionProvider(java.lang.String driverProtocol,
HostSpec host,
java.util.Properties props)
Get the
ConnectionProvider to use to establish a connection using the given driver
protocol, host details, and properties. |
ConnectionProvider |
getDefaultProvider()
Get the default
ConnectionProvider. |
HostSpec |
getHostSpecByStrategy(java.util.List<HostSpec> hosts,
HostRole role,
java.lang.String strategy,
java.util.Properties props)
Select a
HostSpec with the desired role from the given hosts using the requested
strategy. |
void |
initConnection(@Nullable java.sql.Connection connection,
@NonNull java.lang.String protocol,
@NonNull HostSpec hostSpec,
@NonNull java.util.Properties props) |
static void |
releaseResources()
Releases any resources held by the available
ConnectionProvider instances. |
static void |
resetConnectionInitFunc()
Deprecated.
Use
Driver.resetConnectionInitFunc() instead |
static void |
resetProvider()
Deprecated.
Use
Driver.resetCustomConnectionProvider() instead |
static void |
setConnectionInitFunc(@NonNull ConnectionProviderManager.ConnectionInitFunc func)
Deprecated.
@see Driver#setConnectionInitFunc(ConnectionInitFunc)
|
static void |
setConnectionProvider(ConnectionProvider connProvider)
Deprecated.
|
public ConnectionProviderManager(ConnectionProvider defaultProvider, @Nullable ConnectionProvider effectiveConnProvider)
ConnectionProviderManager constructor.defaultProvider - the default ConnectionProvider to use if a non-default
ConnectionProvider has not been set or the non-default
ConnectionProvider has been set but does not accept a requested URLeffectiveConnProvider - the non-default ConnectionProvider to use@Deprecated public static void setConnectionProvider(ConnectionProvider connProvider)
Driver.setCustomConnectionProvider(ConnectionProvider) instead.ConnectionProvider. The
requested ConnectionProvider will be used to establish future connections unless it does not
support a requested URL, in which case the default ConnectionProvider will be used. See
ConnectionProvider.acceptsUrl(java.lang.String, software.amazon.jdbc.HostSpec, java.util.Properties) for more info.connProvider - the ConnectionProvider to use to establish new connectionspublic ConnectionProvider getConnectionProvider(java.lang.String driverProtocol, HostSpec host, java.util.Properties props)
ConnectionProvider to use to establish a connection using the given driver
protocol, host details, and properties. If a non-default ConnectionProvider has been set using
setConnectionProvider(software.amazon.jdbc.ConnectionProvider) and ConnectionProvider.acceptsUrl(java.lang.String, software.amazon.jdbc.HostSpec, java.util.Properties) returns true, the
non-default ConnectionProvider will be returned. Otherwise, the default ConnectionProvider will
be returned. See ConnectionProvider.acceptsUrl(java.lang.String, software.amazon.jdbc.HostSpec, java.util.Properties) for more info.driverProtocol - the driver protocol that will be used to establish the connectionhost - the host info for the connection that will be establishedprops - the connection properties for the connection that will be establishedConnectionProvider to use to establish a connection using the given driver
protocol, host details, and propertiespublic ConnectionProvider getDefaultProvider()
ConnectionProvider.ConnectionProvider.public boolean acceptsStrategy(HostRole role, java.lang.String strategy)
ConnectionProvider instances support the
selection of a host with the requested role and strategy via getHostSpecByStrategy(java.util.List<software.amazon.jdbc.HostSpec>, software.amazon.jdbc.HostRole, java.lang.String, java.util.Properties).role - the desired host rolestrategy - the strategy that should be used to pick a host (eg "random")ConnectionProvider instances support the selection of a
host with the requested role and strategy via getHostSpecByStrategy(java.util.List<software.amazon.jdbc.HostSpec>, software.amazon.jdbc.HostRole, java.lang.String, java.util.Properties). Otherwise,
return falsepublic HostSpec getHostSpecByStrategy(java.util.List<HostSpec> hosts, HostRole role, java.lang.String strategy, java.util.Properties props) throws java.sql.SQLException, java.lang.UnsupportedOperationException
HostSpec with the desired role from the given hosts using the requested
strategy. acceptsStrategy(software.amazon.jdbc.HostRole, java.lang.String) should be called first to evaluate if the available
ConnectionProvider instances support the selection of a host with the requested role
and strategy.hosts - the list of hosts to select fromrole - the desired role of the host - either a writer or a readerstrategy - the strategy that should be used to select a HostSpec from the host
list (eg "random")props - any properties that are required by the provided strategy to select a hostHostSpec with the requested rolejava.sql.SQLException - if the available ConnectionProvider instances
cannot find a host in the host list matching the
requested role or an error occurs while selecting a hostjava.lang.UnsupportedOperationException - if the available ConnectionProvider instances do
not support the requested strategy@Deprecated public static void resetProvider()
Driver.resetCustomConnectionProvider() insteadConnectionProvider if it has been set. The default
ConnectionProvider will be used if the non-default ConnectionProvider has not been set or has
been cleared.public static void releaseResources()
ConnectionProvider instances.@Deprecated public static void setConnectionInitFunc(@NonNull ConnectionProviderManager.ConnectionInitFunc func)
func - A function that initialize a new connection@Deprecated public static void resetConnectionInitFunc()
Driver.resetConnectionInitFunc() insteadpublic void initConnection(@Nullable java.sql.Connection connection,
@NonNull java.lang.String protocol,
@NonNull HostSpec hostSpec,
@NonNull java.util.Properties props)
throws java.sql.SQLException
java.sql.SQLException