Class ConnectionFactoryCallbackHandler
java.lang.Object
io.r2dbc.proxy.callback.ConnectionFactoryCallbackHandler
- All Implemented Interfaces:
CallbackHandler
Proxy callback handler for
ConnectionFactory
.- Author:
- Tadaya Tsuyukubo
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final io.r2dbc.proxy.callback.CallbackHandlerSupport.MethodInvocationStrategy
protected io.r2dbc.proxy.callback.CallbackHandlerSupport.MethodInvocationStrategy
protected final ProxyConfig
-
Constructor Summary
ConstructorsConstructorDescriptionConnectionFactoryCallbackHandler
(ConnectionFactory connectionFactory, ProxyConfig proxyConfig) -
Method Summary
Modifier and TypeMethodDescriptionprotected Object
handleCommonMethod
(String methodName, Object original, Object[] args, Connection originalConnection) interceptQueryExecution
(Publisher<? extends Result> publisher, io.r2dbc.proxy.callback.MutableQueryExecutionInfo executionInfo) Augment query execution result to hook up listener lifecycle.When proxy is invoked, actual implementation of the proxy handler delegates the invocation to this method.protected boolean
isCommonMethod
(String methodName) protected Object
proceedExecution
(Method method, Object target, Object[] args, ProxyExecutionListener listener, ConnectionInfo connectionInfo, Consumer<MethodExecutionInfo> onComplete) Augment method invocation and call method listener.void
setMethodInvocationStrategy
(io.r2dbc.proxy.callback.CallbackHandlerSupport.MethodInvocationStrategy methodInvocationStrategy) SetCallbackHandlerSupport.MethodInvocationStrategy
to invoke the original instance(non-proxy) and retrieve result.
-
Field Details
-
DEFAULT_INVOCATION_STRATEGY
protected static final io.r2dbc.proxy.callback.CallbackHandlerSupport.MethodInvocationStrategy DEFAULT_INVOCATION_STRATEGY -
proxyConfig
-
methodInvocationStrategy
protected io.r2dbc.proxy.callback.CallbackHandlerSupport.MethodInvocationStrategy methodInvocationStrategy
-
-
Constructor Details
-
ConnectionFactoryCallbackHandler
public ConnectionFactoryCallbackHandler(ConnectionFactory connectionFactory, ProxyConfig proxyConfig)
-
-
Method Details
-
invoke
Description copied from interface:CallbackHandler
When proxy is invoked, actual implementation of the proxy handler delegates the invocation to this method.- Parameters:
proxy
- the proxy instance that the method was invoked onmethod
- the method that has invoked on the proxy instanceargs
- an array of objects that has passed to the method invocation. this can benull
when method is invoked with no argument.- Returns:
- result returned from the method invocation on the proxy instance. (can be
null
.) - Throws:
Throwable
- the exception thrown from the method invocation on the proxy instance.
-
isCommonMethod
-
handleCommonMethod
-
proceedExecution
protected Object proceedExecution(Method method, Object target, @Nullable Object[] args, ProxyExecutionListener listener, @Nullable ConnectionInfo connectionInfo, @Nullable Consumer<MethodExecutionInfo> onComplete) throws Throwable Augment method invocation and call method listener.- Parameters:
method
- method to invoke on targettarget
- an object being invokedargs
- arguments for the method.null
if the method doesn't take any arguments.listener
- listener that before/after method callbacks will be calledconnectionInfo
- current connection information.null
when invoked operation is not associated to theConnection
.onComplete
- a callback that will be invoked at successful termination(onComplete) of the result publisher.- Returns:
- result of invoking the original object
- Throws:
Throwable
- thrown exception during the invocationIllegalArgumentException
- ifmethod
isnull
IllegalArgumentException
- iftarget
isnull
IllegalArgumentException
- iflistener
isnull
-
interceptQueryExecution
protected Flux<? extends Result> interceptQueryExecution(Publisher<? extends Result> publisher, io.r2dbc.proxy.callback.MutableQueryExecutionInfo executionInfo) Augment query execution result to hook up listener lifecycle.- Parameters:
publisher
- query invocation result publisherexecutionInfo
- query execution context info- Returns:
- query invocation result flux
- Throws:
IllegalArgumentException
- ifflux
isnull
IllegalArgumentException
- ifexecutionInfo
isnull
-
setMethodInvocationStrategy
public void setMethodInvocationStrategy(io.r2dbc.proxy.callback.CallbackHandlerSupport.MethodInvocationStrategy methodInvocationStrategy) SetCallbackHandlerSupport.MethodInvocationStrategy
to invoke the original instance(non-proxy) and retrieve result.- Parameters:
methodInvocationStrategy
- strategy for method invocation- Throws:
IllegalArgumentException
- ifmethodInvocationStrategy
isnull
- See Also:
-