org.axonframework.common.jdbc
Class UnitOfWorkAwareConnectionProviderWrapper

java.lang.Object
  extended by org.axonframework.common.jdbc.UnitOfWorkAwareConnectionProviderWrapper
All Implemented Interfaces:
ConnectionProvider

public class UnitOfWorkAwareConnectionProviderWrapper
extends Object
implements ConnectionProvider

Wrapper for a ConnectionProvider that checks if a connection is already attached to the Unit of Work, favoring that connection over creating a new one.

Since:
2.2
Author:
Allard Buijze

Constructor Summary
UnitOfWorkAwareConnectionProviderWrapper(ConnectionProvider delegate)
          Initializes a ConnectionProvider, using given delegate to create a new instance, when on is not already attached to the Unit of Work.
UnitOfWorkAwareConnectionProviderWrapper(ConnectionProvider delegate, boolean attachAsInheritedResource)
          Initializes a ConnectionProvider, using given delegate to create a new instance, when on is not already attached to the Unit of Work.
 
Method Summary
 Connection getConnection()
          Returns a connection, ready for use.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UnitOfWorkAwareConnectionProviderWrapper

public UnitOfWorkAwareConnectionProviderWrapper(ConnectionProvider delegate)
Initializes a ConnectionProvider, using given delegate to create a new instance, when on is not already attached to the Unit of Work. Nested Unit of Work will inherit the same connection.

Parameters:
delegate - The connection provider creating connections, when required

UnitOfWorkAwareConnectionProviderWrapper

public UnitOfWorkAwareConnectionProviderWrapper(ConnectionProvider delegate,
                                                boolean attachAsInheritedResource)
Initializes a ConnectionProvider, using given delegate to create a new instance, when on is not already attached to the Unit of Work. Given attachAsInheritedResource flag indicates whether the resource should be inherited by nested Unit of Work.

Parameters:
delegate - The connection provider creating connections, when required
attachAsInheritedResource - whether or not nested Units of Work should inherit connections
Method Detail

getConnection

public Connection getConnection()
                         throws SQLException
Description copied from interface: ConnectionProvider
Returns a connection, ready for use.

Specified by:
getConnection in interface ConnectionProvider
Returns:
a new connection to use
Throws:
SQLException - when an error occurs obtaining the connection


Copyright © 2010-2016. All Rights Reserved.