// create the data holder for our connection manager
GBeanData connectionManagerGBean = new GBeanData(connectionManagerAbstractName, GenericConnectionManagerGBean.class);
//we configure our connection manager
GerConnectionmanagerType connectionManager = connectionfactoryInstance.getConnectionmanager();
TransactionSupport transactionSupport;
if (connectionManager.isSetNoTransaction()) {
transactionSupport = NoTransactions.INSTANCE;
} else if (connectionManager.isSetLocalTransaction()) {
if ("NoTransaction".equals(ddTransactionSupport)) {
throw new DeploymentException("You are requesting local transaction support for a connector that does not support transactions: named: " + connectionfactoryInstance.getName().trim());
}
transactionSupport = LocalTransactions.INSTANCE;
} else if (connectionManager.isSetTransactionLog()) {
if ("NoTransaction".equals(ddTransactionSupport)) {
throw new DeploymentException("You are requesting local transaction support for a connector that does not support transactions: named: " + connectionfactoryInstance.getName().trim());
}
transactionSupport = TransactionLog.INSTANCE;
} else if (connectionManager.isSetXaTransaction()) {
if ("NoTransaction".equals(ddTransactionSupport)) {
throw new DeploymentException("You are requesting xa transaction support for a connector that does not support transactions: named: " + connectionfactoryInstance.getName().trim());
}
if ("LocalTransaction".equals(ddTransactionSupport)) {
throw new DeploymentException("You are requesting xa transaction support for a connector that supports only local transactions: named: " + connectionfactoryInstance.getName().trim());
}
transactionSupport = new XATransactions(connectionManager.getXaTransaction().isSetTransactionCaching(),
connectionManager.getXaTransaction().isSetThreadCaching());
} else if ("NoTransaction".equals(ddTransactionSupport)) {
transactionSupport = NoTransactions.INSTANCE;
} else if ("LocalTransaction".equals(ddTransactionSupport)) {
transactionSupport = LocalTransactions.INSTANCE;
} else if ("XATransaction".equals(ddTransactionSupport)) {
transactionSupport = new XATransactions(defaultXATransactionCaching, defaultXAThreadCaching);
} else {
//this should not happen
throw new DeploymentException("Unexpected transaction support element in connector named: " + connectionfactoryInstance.getName().trim());
}
PoolingSupport pooling;
if (connectionManager.getSinglePool() != null) {
GerSinglepoolType pool = connectionManager.getSinglePool();
pooling = new SinglePool(pool.isSetMaxSize() ? pool.getMaxSize() : defaultMaxSize,
pool.isSetMinSize() ? pool.getMinSize() : defaultMinSize,
pool.isSetBlockingTimeoutMilliseconds() ? pool.getBlockingTimeoutMilliseconds() : defaultBlockingTimeoutMilliseconds,
pool.isSetIdleTimeoutMinutes() ? pool.getIdleTimeoutMinutes() : defaultIdleTimeoutMinutes,
pool.getMatchOne() != null,
pool.getMatchAll() != null,
pool.getSelectOneAssumeMatch() != null);
} else if (connectionManager.getPartitionedPool() != null) {
GerPartitionedpoolType pool = connectionManager.getPartitionedPool();
pooling = new PartitionedPool(pool.isSetMaxSize() ? pool.getMaxSize() : defaultMaxSize,
pool.isSetMinSize() ? pool.getMinSize() : defaultMinSize,
pool.isSetBlockingTimeoutMilliseconds() ? pool.getBlockingTimeoutMilliseconds() : defaultBlockingTimeoutMilliseconds,
pool.isSetIdleTimeoutMinutes() ? pool.getIdleTimeoutMinutes() : defaultIdleTimeoutMinutes,
pool.getMatchOne() != null,
pool.getMatchAll() != null,
pool.getSelectOneAssumeMatch() != null,
pool.isSetPartitionByConnectionrequestinfo(),
pool.isSetPartitionBySubject());
} else if (connectionManager.getNoPool() != null) {
pooling = new NoPool();
} else {
throw new DeploymentException("Unexpected pooling support element in connector named " + connectionfactoryInstance.getName().trim());
}
try {
String jndiName = naming.toOsgiJndiName(connectionManagerAbstractName);
connectionManagerGBean.getServiceProperties().put(OSGI_JNDI_SERVICE_NAME, jndiName);
connectionManagerGBean.setAttribute("transactionSupport", transactionSupport);
connectionManagerGBean.setAttribute("pooling", pooling);
connectionManagerGBean.setReferencePattern("ConnectionTracker", connectionTrackerName);
connectionManagerGBean.setAttribute("containerManagedSecurity", connectionManager.isSetContainerManagedSecurity());
connectionManagerGBean.setReferencePattern("TransactionManager", transactionManagerName);
connectionManagerGBean.setReferencePattern("ManagedConnectionFactory", managedConnectionFactoryName);
} catch (Exception e) {
throw new DeploymentException("Problem setting up ConnectionManager named " + connectionfactoryInstance.getName().trim(), e);
}