use of org.apache.aries.transaction.jdbc.internal.XADataSourceMCFFactory in project aries by apache.
the class RecoverableDataSource method start.
/**
* @org.apache.xbean.InitMethod
*/
public void start() throws Exception {
AbstractMCFFactory mcf;
if (("xa".equals(transaction) || "local".equals(transaction)) && transactionManager == null) {
throw new IllegalArgumentException("xa or local transactions specified, but no TransactionManager set");
}
if ("xa".equals(transaction) && !(dataSource instanceof XADataSource)) {
throw new IllegalArgumentException("xa transactions specified, but DataSource does not implement javax.sql.XADataSource");
}
if ("xa".equals(transaction) || (transactionManager != null && dataSource instanceof XADataSource)) {
mcf = new XADataSourceMCFFactory();
if (transaction == null) {
transaction = "xa";
}
} else if (dataSource instanceof DataSource) {
mcf = new DataSourceMCFFactory();
if (transaction == null) {
transaction = transactionManager != null ? "local" : "none";
}
} else {
throw new IllegalArgumentException("dataSource must be of type javax.sql.DataSource/XADataSource");
}
mcf.setDataSource(dataSource);
mcf.setExceptionSorterAsString(exceptionSorter);
mcf.setUserName(username);
mcf.setPassword(password);
mcf.init();
cm = new ConnectionManagerFactory();
cm.setManagedConnectionFactory(mcf.getConnectionFactory());
cm.setTransactionManager(transactionManager);
cm.setAllConnectionsEqual(allConnectionsEquals);
cm.setConnectionMaxIdleMinutes(connectionMaxIdleMinutes);
cm.setConnectionMaxWaitMilliseconds(connectionMaxWaitMilliseconds);
cm.setPartitionStrategy(partitionStrategy);
cm.setPooling(pooling);
cm.setPoolMaxSize(poolMaxSize);
cm.setPoolMinSize(poolMinSize);
cm.setValidateOnMatch(validateOnMatch);
cm.setBackgroundValidation(backgroundValidation);
cm.setBackgroundValidationMilliseconds(backgroundValidationMilliseconds);
cm.setTransaction(transaction);
cm.setName(name);
cm.init();
delegate = (DataSource) mcf.getConnectionFactory().createConnectionFactory(cm.getConnectionManager());
if (dataSource instanceof XADataSource) {
Recovery.recover(name, (XADataSource) dataSource, transactionManager);
}
}
Aggregations