类 MultiHostConnectionProxy
- java.lang.Object
-
- com.mysql.cj.jdbc.ha.MultiHostConnectionProxy
-
- 所有已实现的接口:
InvocationHandler
public abstract class MultiHostConnectionProxy extends Object implements InvocationHandler
An abstract class that processes generic multi-host configurations. This class has to be sub-classed by specific multi-host implementations, such as load-balancing and failover.
-
-
字段概要
字段 修饰符和类型 字段 说明 protected ConnectionUrlconnectionUrlprotected ThrowablelastExceptionDealtWith
-
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 protected booleanallowedOnClosedConnection(Method method)Checks if the given method is allowed on closed connections.protected JdbcConnectiongetParentProxy()Get this connection's parent proxy.protected JdbcConnectiongetProxy()Get this connection's proxy.Objectinvoke(Object proxy, Method method, Object[] args)Proxies method invocation on the java.sql.Connection interface, trapping multi-host specific methods and generic methods.protected voidpropagateProxyDown(JdbcConnection proxyConn)Propagates the connection proxy down through the multi-host connections chain.protected voidsetProxy(JdbcConnection proxyConn)Sets this connection's proxy.
-
-
-
字段详细资料
-
connectionUrl
protected ConnectionUrl connectionUrl
-
lastExceptionDealtWith
protected Throwable lastExceptionDealtWith
-
-
方法详细资料
-
getProxy
protected JdbcConnection getProxy()
Get this connection's proxy. A multi-host connection may not be at top level in the multi-host connections chain. In such case the first connection in the chain is available as a proxy.- 返回:
- Returns this connection's proxy if there is one or itself if this is the first one.
-
getParentProxy
protected JdbcConnection getParentProxy()
Get this connection's parent proxy.- 返回:
- Returns this connection's proxy if there is one.
-
setProxy
protected final void setProxy(JdbcConnection proxyConn)
Sets this connection's proxy. This proxy should be the first connection in the multi-host connections chain. After setting the connection proxy locally, propagates it through the dependent connections.- 参数:
proxyConn- The top level connection in the multi-host connections chain.
-
propagateProxyDown
protected void propagateProxyDown(JdbcConnection proxyConn)
Propagates the connection proxy down through the multi-host connections chain. This method is intended to be overridden in subclasses that manage more than one active connection at same time.- 参数:
proxyConn- The top level connection in the multi-host connections chain.
-
invoke
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
Proxies method invocation on the java.sql.Connection interface, trapping multi-host specific methods and generic methods. Subclasses have to override this to complete the method invocation process, deal with exceptions and decide when to switch connection. To avoid unnecessary additional exception handling overriders should consult #canDealWith(Method) before chaining here.- 指定者:
invoke在接口中InvocationHandler- 参数:
proxy- proxy objectmethod- method to invokeargs- method parameters- 返回:
- method result
- 抛出:
Throwable- if an error occurs
-
allowedOnClosedConnection
protected boolean allowedOnClosedConnection(Method method)
Checks if the given method is allowed on closed connections.- 参数:
method- method- 返回:
- true if the given method is allowed on closed connections
-
-