Package org.axonframework.common.jdbc
Class ConnectionWrapperFactory
java.lang.Object
org.axonframework.common.jdbc.ConnectionWrapperFactory
Factory for creating wrappers around a Connection, allowing one to override the behavior of the
Connection.close() method.- Since:
- 2.2
- Author:
- Allard Buijze
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceInterface defining an operation to close the wrapped connectionstatic classImplementation of ConnectionCloseHandler that does nothing on close or commit. -
Method Summary
Modifier and TypeMethodDescriptionstatic <I> Connectionwrap(Connection connection, Class<I> wrapperInterface, I wrapperHandler, ConnectionWrapperFactory.ConnectionCloseHandler closeHandler) Wrap the givenconnection, creating a Proxy with an additionalwrapperInterface(implemented by givenwrapperHandler).static Connectionwrap(Connection connection, ConnectionWrapperFactory.ConnectionCloseHandler closeHandler) Wrap the givenconnection, creating a Proxy with an additionalwrapperInterface(implemented by givenwrapperHandler).
-
Method Details
-
wrap
public static <I> Connection wrap(Connection connection, Class<I> wrapperInterface, I wrapperHandler, ConnectionWrapperFactory.ConnectionCloseHandler closeHandler) Wrap the givenconnection, creating a Proxy with an additionalwrapperInterface(implemented by givenwrapperHandler). Calls to the close method are forwarded to the givencloseHandler. Note that all invocations on methods declared on thewrapperInterface(including equals, hashCode) are forwarded to thewrapperHandler.- Type Parameters:
I- The type of additional interface for the wrapper to implement- Parameters:
connection- The connection to wrapwrapperInterface- The additional interface to implementwrapperHandler- The implementation for the additional interfacecloseHandler- The handler to redirect close invocations to- Returns:
- a wrapped Connection
-
wrap
public static Connection wrap(Connection connection, ConnectionWrapperFactory.ConnectionCloseHandler closeHandler) Wrap the givenconnection, creating a Proxy with an additionalwrapperInterface(implemented by givenwrapperHandler). Calls to the close method are forwarded to the givencloseHandler.- Parameters:
connection- The connection to wrapcloseHandler- The handler to redirect close invocations to- Returns:
- a wrapped Connection
-