org.apache.commons.dbcp.managed
Class DataSourceXAConnectionFactory

java.lang.Object
  extended by org.apache.commons.dbcp.managed.DataSourceXAConnectionFactory
All Implemented Interfaces:
ConnectionFactory, XAConnectionFactory

public class DataSourceXAConnectionFactory
extends Object
implements XAConnectionFactory

An implementation of XAConnectionFactory which uses a real XADataSource to obtain connections and XAResources.

Version:
$Revision: 892307 $
Author:
Dain Sundstrom

Field Summary
protected  String password
           
protected  TransactionRegistry transactionRegistry
           
protected  String username
           
protected  XADataSource xaDataSource
           
 
Constructor Summary
DataSourceXAConnectionFactory(TransactionManager transactionManager, XADataSource xaDataSource)
          Creates an DataSourceXAConnectionFactory which uses the specified XADataSource to create database connections.
DataSourceXAConnectionFactory(TransactionManager transactionManager, XADataSource xaDataSource, String username, String password)
          Creates an DataSourceXAConnectionFactory which uses the specified XADataSource to create database connections.
 
Method Summary
 Connection createConnection()
          Create a new Connection in an implementation specific fashion.
 TransactionRegistry getTransactionRegistry()
          Gets the TransactionRegistry for this connection factory which contains a the XAResource for every connection created by this factory.
 String getUsername()
          Gets the username used to authenticate new connections.
 void setPassword(String password)
          Sets the password used to authenticate new connections.
 void setUsername(String username)
          Sets the username used to authenticate new connections.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

transactionRegistry

protected TransactionRegistry transactionRegistry

xaDataSource

protected XADataSource xaDataSource

username

protected String username

password

protected String password
Constructor Detail

DataSourceXAConnectionFactory

public DataSourceXAConnectionFactory(TransactionManager transactionManager,
                                     XADataSource xaDataSource)
Creates an DataSourceXAConnectionFactory which uses the specified XADataSource to create database connections. The connections are enlisted into transactions using the specified transaction manager.

Parameters:
transactionManager - the transaction manager in which connections will be enlisted
xaDataSource - the data source from which connections will be retrieved

DataSourceXAConnectionFactory

public DataSourceXAConnectionFactory(TransactionManager transactionManager,
                                     XADataSource xaDataSource,
                                     String username,
                                     String password)
Creates an DataSourceXAConnectionFactory which uses the specified XADataSource to create database connections. The connections are enlisted into transactions using the specified transaction manager.

Parameters:
transactionManager - the transaction manager in which connections will be enlisted
xaDataSource - the data source from which connections will be retrieved
username - the username used for authenticating new connections or null for unauthenticated
password - the password used for authenticating new connections
Method Detail

getUsername

public String getUsername()
Gets the username used to authenticate new connections.

Returns:
the user name or null if unauthenticated connections are used

setUsername

public void setUsername(String username)
Sets the username used to authenticate new connections.

Parameters:
username - the username used for authenticating the connection or null for unauthenticated

setPassword

public void setPassword(String password)
Sets the password used to authenticate new connections.

Parameters:
password - the password used for authenticating the connection or null for unauthenticated

getTransactionRegistry

public TransactionRegistry getTransactionRegistry()
Description copied from interface: XAConnectionFactory
Gets the TransactionRegistry for this connection factory which contains a the XAResource for every connection created by this factory.

Specified by:
getTransactionRegistry in interface XAConnectionFactory
Returns:
the transaction registry for this connection factory

createConnection

public Connection createConnection()
                            throws SQLException
Description copied from interface: ConnectionFactory
Create a new Connection in an implementation specific fashion.

Specified by:
createConnection in interface ConnectionFactory
Specified by:
createConnection in interface XAConnectionFactory
Returns:
a new Connection
Throws:
SQLException - if a database error occurs creating the connection


Copyright © 2001-2010 The Apache Software Foundation. All Rights Reserved.