1 17 18 package org.apache.geronimo.connector.outbound; 19 20 import javax.transaction.TransactionManager ; 21 22 import org.apache.geronimo.connector.outbound.connectionmanagerconfig.PartitionedPool; 23 import org.apache.geronimo.connector.outbound.connectionmanagerconfig.PoolingSupport; 24 import org.apache.geronimo.connector.outbound.connectionmanagerconfig.TransactionSupport; 25 import org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTracker; 26 import org.apache.commons.logging.Log; 27 import org.apache.commons.logging.LogFactory; 28 29 35 public class GenericConnectionManager extends AbstractConnectionManager { 36 protected static final Log log = LogFactory.getLog(AbstractSinglePoolConnectionInterceptor.class.getName()); 37 38 public GenericConnectionManager() { 40 super(); 41 } 42 43 public GenericConnectionManager(TransactionSupport transactionSupport, 44 PoolingSupport pooling, 45 boolean containerManagedSecurity, 46 ConnectionTracker connectionTracker, 47 TransactionManager transactionManager, 48 String objectName, 49 ClassLoader classLoader) { 50 super(new InterceptorsImpl(transactionSupport, pooling, containerManagedSecurity, objectName, connectionTracker, transactionManager, classLoader)); 51 } 52 53 private static class InterceptorsImpl implements AbstractConnectionManager.Interceptors { 54 55 private final ConnectionInterceptor stack; 56 private final ConnectionInterceptor recoveryStack; 57 private final PoolingSupport poolingSupport; 58 59 72 public InterceptorsImpl(TransactionSupport transactionSupport, 73 PoolingSupport pooling, 74 boolean containerManagedSecurity, 75 String objectName, 76 ConnectionTracker connectionTracker, 77 TransactionManager transactionManager, 78 ClassLoader classLoader) { 79 if (!containerManagedSecurity && pooling instanceof PartitionedPool && ((PartitionedPool) pooling).isPartitionBySubject()) { 81 throw new IllegalStateException ("To use Subject in pooling, you need a SecurityDomain"); 82 } 83 84 MCFConnectionInterceptor tail = new MCFConnectionInterceptor(); 86 ConnectionInterceptor stack = tail; 87 88 stack = transactionSupport.addXAResourceInsertionInterceptor(stack, objectName); 89 stack = pooling.addPoolingInterceptors(stack); 90 if (log.isTraceEnabled()) { 91 log.trace("Connection Manager " + objectName + " installed pool " + stack); 92 } 93 94 this.poolingSupport = pooling; 95 stack = transactionSupport.addTransactionInterceptors(stack, transactionManager); 96 97 if (containerManagedSecurity) { 98 stack = new SubjectInterceptor(stack); 99 } 100 101 ConnectionInterceptor recoveryStack = stack; 102 this.recoveryStack = new TCCLInterceptor(recoveryStack, classLoader); 103 104 105 stack = new ConnectionHandleInterceptor(stack); 106 stack = new TCCLInterceptor(stack, classLoader); 107 if (connectionTracker != null) { 108 stack = new ConnectionTrackingInterceptor(stack, 109 objectName, 110 connectionTracker); 111 } 112 tail.setStack(stack); 113 this.stack = stack; 114 } 115 116 public ConnectionInterceptor getStack() { 117 return stack; 118 } 119 120 public ConnectionInterceptor getRecoveryStack() { 121 return recoveryStack; 122 } 123 124 public PoolingSupport getPoolingAttributes() { 125 return poolingSupport; 126 } 127 } 128 129 } 130 | Popular Tags |