use of org.tranql.connector.UserPasswordManagedConnectionFactory in project aries by apache.
the class ConnectionManagerFactory method init.
public void init() throws Exception {
if (transactionManager == null && ("xa".equals(transaction) || "local".equals(transaction))) {
throw new IllegalArgumentException("transactionManager must be set");
}
if (managedConnectionFactory == null) {
throw new IllegalArgumentException("managedConnectionFactory must be set");
}
// Apply the default value for property if necessary
if (transactionSupport == null) {
// No transaction
if ("local".equalsIgnoreCase(transaction)) {
transactionSupport = LocalTransactions.INSTANCE;
} else if ("none".equalsIgnoreCase(transaction)) {
transactionSupport = NoTransactions.INSTANCE;
} else if ("xa".equalsIgnoreCase(transaction)) {
transactionSupport = new XATransactions(true, false);
} else {
throw new IllegalArgumentException("Unknown transaction type " + transaction + " (must be local, none or xa)");
}
}
if (poolingSupport == null) {
// No pool
if (!pooling) {
poolingSupport = new NoPool();
} else {
if (partitionStrategy == null || "none".equalsIgnoreCase(partitionStrategy)) {
// unpartitioned pool
poolingSupport = new SinglePool(poolMaxSize, poolMinSize, connectionMaxWaitMilliseconds, connectionMaxIdleMinutes, allConnectionsEqual, !allConnectionsEqual, false);
} else if ("by-connector-properties".equalsIgnoreCase(partitionStrategy)) {
// partition by connector properties such as username and password on a jdbc connection
poolingSupport = new PartitionedPool(poolMaxSize, poolMinSize, connectionMaxWaitMilliseconds, connectionMaxIdleMinutes, allConnectionsEqual, !allConnectionsEqual, false, true, false);
} else if ("by-subject".equalsIgnoreCase(partitionStrategy)) {
// partition by caller subject
poolingSupport = new PartitionedPool(poolMaxSize, poolMinSize, connectionMaxWaitMilliseconds, connectionMaxIdleMinutes, allConnectionsEqual, !allConnectionsEqual, false, false, true);
} else {
throw new IllegalArgumentException("Unknown partition strategy " + partitionStrategy + " (must be none, by-connector-properties or by-subject)");
}
}
}
if (connectionTracker == null) {
connectionTracker = new ConnectionTrackingCoordinator();
}
if (transactionManagerMonitor == null && transactionManager != null) {
transactionManagerMonitor = new GeronimoTransactionListener(connectionTracker);
transactionManager.addTransactionAssociationListener(transactionManagerMonitor);
}
if (connectionManager == null) {
if (validateOnMatch || backgroundValidation) {
// Wrap the original ManagedConnectionFactory to add validation capability
managedConnectionFactory = new ValidatingDelegatingManagedConnectionFactory((UserPasswordManagedConnectionFactory) managedConnectionFactory);
}
if (backgroundValidation) {
// Instantiate the Validating Connection Manager
connectionManager = new ValidatingGenericConnectionManager(transactionSupport, poolingSupport, subjectSource, connectionTracker, transactionManager, managedConnectionFactory, name != null ? name : getClass().getName(), getClass().getClassLoader(), backgroundValidationMilliseconds);
} else {
// Instantiate the Geronimo Connection Manager
connectionManager = new GenericConnectionManager(transactionSupport, poolingSupport, subjectSource, connectionTracker, transactionManager, managedConnectionFactory, name != null ? name : getClass().getName(), getClass().getClassLoader());
}
connectionManager.doStart();
}
}
Aggregations