public class ConnectionProxy extends java.lang.Object implements ICurrentConnectionProvider, java.lang.reflect.InvocationHandler
ConnectionPluginManager to initialize
JdbcConnection and execute JDBC methods.| Modifier and Type | Field and Description |
|---|---|
protected java.util.Map<java.lang.String,java.lang.String> |
initialConnectionProps |
protected Log |
log
The logger we're going to use.
|
protected static Log |
NULL_LOGGER
Null logger shared by all connections at startup.
|
protected ConnectionPluginManager |
pluginManager |
| Constructor and Description |
|---|
ConnectionProxy(ConnectionUrl connectionUrl) |
ConnectionProxy(ConnectionUrl connectionUrl,
JdbcConnection connection)
Instantiates a new AuroraConnectionProxy for the given list of hosts and connection properties.
|
| Modifier and Type | Method and Description |
|---|---|
static JdbcConnection |
autodetectClusterAndCreateProxyInstance(ConnectionUrl connectionUrl)
Checks if connection is associated with Aurora cluster and instantiates a new
AuroraConnectionProxy if needed.
|
static JdbcConnection |
createProxyInstance(ConnectionUrl connectionUrl)
Instantiates a new
ConnectionProxy. |
JdbcConnection |
getCurrentConnection() |
HostInfo |
getCurrentHostInfo() |
protected java.lang.reflect.InvocationHandler |
getNewJdbcInterfaceProxy(java.lang.Object toProxy) |
protected void |
initLogger(ConnectionUrl connUrl) |
protected void |
initPluginManager(java.util.function.Function<Log,ConnectionPluginManager> connectionPluginManagerInitializer,
ConnectionUrl connectionUrl) |
protected void |
initSettings(ConnectionUrl connectionUrl) |
java.lang.Object |
invoke(java.lang.Object proxy,
java.lang.reflect.Method method,
java.lang.Object[] args) |
protected java.lang.Object |
proxyIfReturnTypeIsJdbcInterface(java.lang.Class<?> returnType,
java.lang.Object toProxy)
If the given return type is or implements a JDBC interface, proxies the given object so that we can catch SQL errors and fire a connection switch.
|
void |
setCurrentConnection(JdbcConnection connection,
HostInfo info) |
protected static final Log NULL_LOGGER
protected transient Log log
protected java.util.Map<java.lang.String,java.lang.String> initialConnectionProps
protected ConnectionPluginManager pluginManager
public ConnectionProxy(ConnectionUrl connectionUrl) throws java.sql.SQLException
java.sql.SQLExceptionpublic ConnectionProxy(ConnectionUrl connectionUrl, JdbcConnection connection) throws java.sql.SQLException
connectionUrl - ConnectionUrl instance containing the lists of hosts available to
switch on.connection - JdbcConnectionjava.sql.SQLException - if an error occurspublic static JdbcConnection autodetectClusterAndCreateProxyInstance(ConnectionUrl connectionUrl) throws java.sql.SQLException
connectionUrl - ConnectionUrl instance containing the lists of hosts available to
switch on.java.sql.SQLException - if an error occurspublic static JdbcConnection createProxyInstance(ConnectionUrl connectionUrl) throws java.sql.SQLException
ConnectionProxy.connectionUrl - ConnectionUrl instance containing the lists of hosts available to
switch on.java.sql.SQLException - if an error occurspublic JdbcConnection getCurrentConnection()
getCurrentConnection in interface ICurrentConnectionProviderpublic HostInfo getCurrentHostInfo()
getCurrentHostInfo in interface ICurrentConnectionProviderpublic void setCurrentConnection(JdbcConnection connection, HostInfo info)
setCurrentConnection in interface ICurrentConnectionProviderpublic java.lang.Object invoke(java.lang.Object proxy,
java.lang.reflect.Method method,
java.lang.Object[] args)
throws java.lang.Throwable
invoke in interface java.lang.reflect.InvocationHandlerjava.lang.Throwableprotected java.lang.reflect.InvocationHandler getNewJdbcInterfaceProxy(java.lang.Object toProxy)
protected void initLogger(ConnectionUrl connUrl)
protected void initSettings(ConnectionUrl connectionUrl) throws java.sql.SQLException
java.sql.SQLExceptionprotected java.lang.Object proxyIfReturnTypeIsJdbcInterface(java.lang.Class<?> returnType,
java.lang.Object toProxy)
returnType - The type the object instance to proxy is supposed to be.toProxy - The object instance to proxy.protected void initPluginManager(java.util.function.Function<Log,ConnectionPluginManager> connectionPluginManagerInitializer, ConnectionUrl connectionUrl) throws java.sql.SQLException
java.sql.SQLException