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.SQLException
public ConnectionProxy(ConnectionUrl connectionUrl, JdbcConnection connection) throws java.sql.SQLException
connectionUrl
- ConnectionUrl
instance containing the lists of hosts available to
switch on.connection
- JdbcConnection
java.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 ICurrentConnectionProvider
public HostInfo getCurrentHostInfo()
getCurrentHostInfo
in interface ICurrentConnectionProvider
public void setCurrentConnection(JdbcConnection connection, HostInfo info)
setCurrentConnection
in interface ICurrentConnectionProvider
public 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.InvocationHandler
java.lang.Throwable
protected 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.SQLException
protected 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