org.axonframework.common.jdbc
Class ConnectionWrapperFactory

java.lang.Object
  extended by org.axonframework.common.jdbc.ConnectionWrapperFactory

public abstract class ConnectionWrapperFactory
extends Object

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
static interface ConnectionWrapperFactory.ConnectionCloseHandler
          Interface defining an operation to close the wrapped connection
static class ConnectionWrapperFactory.NoOpCloseHandler
          Implementation of ConnectionCloseHandler that does nothing on close.
 
Method Summary
static
<I> Connection
wrap(Connection connection, Class<I> wrapperInterface, I wrapperHandler, ConnectionWrapperFactory.ConnectionCloseHandler closeHandler)
          Wrap the given connection, creating a Proxy with an additional wrapperInterface (implemented by given wrapperHandler).
static Connection wrap(Connection connection, ConnectionWrapperFactory.ConnectionCloseHandler closeHandler)
          Wrap the given connection, creating a Proxy with an additional wrapperInterface (implemented by given wrapperHandler).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

wrap

public static <I> Connection wrap(Connection connection,
                                  Class<I> wrapperInterface,
                                  I wrapperHandler,
                                  ConnectionWrapperFactory.ConnectionCloseHandler closeHandler)
Wrap the given connection, creating a Proxy with an additional wrapperInterface (implemented by given wrapperHandler). Calls to the close method are forwarded to the given closeHandler.

Note that all invocations on methods declared on the wrapperInterface (including equals, hashCode) are forwarded to the wrapperHandler.

Type Parameters:
I - The type of additional interface for the wrapper to implement
Parameters:
connection - The connection to wrap
wrapperInterface - The additional interface to implement
wrapperHandler - The implementation for the additional interface
closeHandler - The handler to redirect close invocations to
Returns:
a wrapped Connection

wrap

public static Connection wrap(Connection connection,
                              ConnectionWrapperFactory.ConnectionCloseHandler closeHandler)
Wrap the given connection, creating a Proxy with an additional wrapperInterface (implemented by given wrapperHandler). Calls to the close method are forwarded to the given closeHandler.

Parameters:
connection - The connection to wrap
closeHandler - The handler to redirect close invocations to
Returns:
a wrapped Connection


Copyright © 2010-2016. All Rights Reserved.