Search in sources :

Example 1 with GeronimoTransactionListener

use of org.apache.geronimo.connector.outbound.connectiontracking.GeronimoTransactionListener 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();
    }
}
Also used : NoPool(org.apache.geronimo.connector.outbound.connectionmanagerconfig.NoPool) SinglePool(org.apache.geronimo.connector.outbound.connectionmanagerconfig.SinglePool) GenericConnectionManager(org.apache.geronimo.connector.outbound.GenericConnectionManager) ConnectionTrackingCoordinator(org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTrackingCoordinator) UserPasswordManagedConnectionFactory(org.tranql.connector.UserPasswordManagedConnectionFactory) XATransactions(org.apache.geronimo.connector.outbound.connectionmanagerconfig.XATransactions) GeronimoTransactionListener(org.apache.geronimo.connector.outbound.connectiontracking.GeronimoTransactionListener) PartitionedPool(org.apache.geronimo.connector.outbound.connectionmanagerconfig.PartitionedPool)

Aggregations

GenericConnectionManager (org.apache.geronimo.connector.outbound.GenericConnectionManager)1 NoPool (org.apache.geronimo.connector.outbound.connectionmanagerconfig.NoPool)1 PartitionedPool (org.apache.geronimo.connector.outbound.connectionmanagerconfig.PartitionedPool)1 SinglePool (org.apache.geronimo.connector.outbound.connectionmanagerconfig.SinglePool)1 XATransactions (org.apache.geronimo.connector.outbound.connectionmanagerconfig.XATransactions)1 ConnectionTrackingCoordinator (org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTrackingCoordinator)1 GeronimoTransactionListener (org.apache.geronimo.connector.outbound.connectiontracking.GeronimoTransactionListener)1 UserPasswordManagedConnectionFactory (org.tranql.connector.UserPasswordManagedConnectionFactory)1