public class C3P0PooledConnectionProvider extends java.lang.Object implements PooledConnectionProvider, CanReleaseResources
| Modifier and Type | Field and Description |
|---|---|
protected static java.util.Map<java.lang.String,HostSelector> |
acceptedStrategies |
protected static SlidingExpirationCache<java.lang.String,com.mchange.v2.c3p0.ComboPooledDataSource> |
databasePools |
protected static long |
poolExpirationCheckNanos |
protected static RdsUtils |
rdsUtils |
| Constructor and Description |
|---|
C3P0PooledConnectionProvider() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
acceptsStrategy(@Nullable HostRole role,
@NonNull java.lang.String strategy)
Indicates whether the selection strategy is supported by the connection provider.
|
boolean |
acceptsUrl(@NonNull java.lang.String protocol,
@NonNull HostSpec hostSpec,
@NonNull java.util.Properties props)
Indicates whether this ConnectionProvider can provide connections for the given host and
properties.
|
@NonNull ConnectionInfo |
connect(@NonNull java.lang.String protocol,
@NonNull Dialect dialect,
@NonNull TargetDriverDialect targetDriverDialect,
@NonNull HostSpec hostSpec,
@NonNull java.util.Properties props)
Called once per connection that needs to be created.
|
protected com.mchange.v2.c3p0.ComboPooledDataSource |
createDataSource(@NonNull java.lang.String protocol,
@NonNull HostSpec hostSpec,
@NonNull java.util.Properties props,
TargetDriverDialect driverDialect) |
@Nullable HostSpec |
getHostSpecByStrategy(@NonNull java.util.List<HostSpec> hosts,
@Nullable HostRole role,
@NonNull java.lang.String strategy,
@Nullable java.util.Properties props)
Return a reader or a writer node using the specified strategy.
|
java.util.List<Pair<java.lang.String,java.lang.Object>> |
getSnapshotState() |
java.lang.String |
getTargetName() |
void |
logConnections() |
void |
releaseResources()
An object that implements this interface should release all acquired resources assuming it may
be disposed at any time.
|
protected static final SlidingExpirationCache<java.lang.String,com.mchange.v2.c3p0.ComboPooledDataSource> databasePools
protected static final java.util.Map<java.lang.String,HostSelector> acceptedStrategies
protected static final long poolExpirationCheckNanos
protected static final RdsUtils rdsUtils
public boolean acceptsUrl(@NonNull java.lang.String protocol,
@NonNull HostSpec hostSpec,
@NonNull java.util.Properties props)
ConnectionProvideracceptsUrl in interface ConnectionProviderprotocol - the connection protocol (example "jdbc:mysql://")hostSpec - the HostSpec containing the host-port information for the host to connect toprops - the Properties to use for the connectionpublic boolean acceptsStrategy(@Nullable HostRole role, @NonNull java.lang.String strategy)
ConnectionProvideracceptsStrategy in interface ConnectionProviderrole - determines if the connection provider should return a reader host or a writer
host. Null value means no preferences on host role.strategy - the selection strategy to usepublic @Nullable HostSpec getHostSpecByStrategy(@NonNull java.util.List<HostSpec> hosts, @Nullable HostRole role, @NonNull java.lang.String strategy, @Nullable java.util.Properties props) throws java.sql.SQLException, java.lang.UnsupportedOperationException
ConnectionProviderUnsupportedOperationException if the specified strategy is unsupported.getHostSpecByStrategy in interface ConnectionProviderhosts - the list of HostSpec to select fromrole - determines if the connection provider should return a writer or a readerstrategy - the strategy determining how the HostSpec should be selected, e.g.,
random or round-robinprops - any properties that are required by the provided strategy to select a hostHostSpec selected using the specified strategy, or null if no host matchesjava.sql.SQLException - if an error occurred while returning the hostsjava.lang.UnsupportedOperationException - if the strategy is unsupported by the providerpublic @NonNull ConnectionInfo connect(@NonNull java.lang.String protocol, @NonNull Dialect dialect, @NonNull TargetDriverDialect targetDriverDialect, @NonNull HostSpec hostSpec, @NonNull java.util.Properties props) throws java.sql.SQLException
ConnectionProviderconnect in interface ConnectionProviderprotocol - the connection protocol (example "jdbc:mysql://")dialect - the database dialecttargetDriverDialect - the target driver dialecthostSpec - the HostSpec containing the host-port information for the host to connect toprops - the Properties to use for the connectionConnectionInfo resulting from the given connection informationjava.sql.SQLException - if an error occursprotected com.mchange.v2.c3p0.ComboPooledDataSource createDataSource(@NonNull java.lang.String protocol,
@NonNull HostSpec hostSpec,
@NonNull java.util.Properties props,
TargetDriverDialect driverDialect)
public java.lang.String getTargetName()
getTargetName in interface ConnectionProviderpublic void releaseResources()
CanReleaseResourcesCalling this method does NOT mean that an object is disposing and there won't be any further calls. An object should keep its functional state after calling this method.
releaseResources in interface CanReleaseResourcespublic void logConnections()
public java.util.List<Pair<java.lang.String,java.lang.Object>> getSnapshotState()
getSnapshotState in interface StateSnapshotProvider