{
super.init();
Bean<?> comp = getComponent();
InjectManager cdiManager = InjectManager.create();
ManagedConnectionFactory managedFactory
= (ManagedConnectionFactory) cdiManager.getReference(comp);
if (managedFactory instanceof ResourceAdapterAssociation) {
Class<?> cl = managedFactory.getClass();
ResourceAdapter ra = findResourceAdapter(cl);
ResourceAdapterAssociation factoryAssoc
= (ResourceAdapterAssociation) managedFactory;
try {
factoryAssoc.setResourceAdapter(ra);
} catch (Exception e) {
throw ConfigException.create(e);
}
}
ResourceManagerImpl rm = ResourceManagerImpl.create();
ConnectionPool cm = rm.createConnectionPool();
if (getName() != null)
cm.setName(getName());
cm.setMaxConnections(_maxConnections);
cm.setMaxActiveTime(_maxActiveTime);
ResourceArchive rar = null;
if (rar != null) {
String trans = rar.getTransactionSupport();
if (trans == null) { // guess XA
cm.setXATransaction(true);
cm.setLocalTransaction(true);
}
else if (trans.equals("XATransaction")) {
cm.setXATransaction(true);
cm.setLocalTransaction(true);
}
else if (trans.equals("NoTransaction")) {
cm.setXATransaction(false);
cm.setLocalTransaction(false);
}
else if (trans.equals("LocalTransaction")) {
cm.setXATransaction(false);
cm.setLocalTransaction(true);
}
}
/*
cm.setLocalTransactionOptimization(getLocalTransactionOptimization());
cm.setShareable(getShareable());
*/
Object connectionFactory;
try {
connectionFactory = cm.init(managedFactory);
cm.start();
BeanBuilder factory
= cdiManager.createBeanFactory(connectionFactory.getClass());
if (getName() != null) {
Jndi.bindDeepShort(getName(), connectionFactory);
factory.name(getName());
factory.qualifier(Names.create(getName()));
// server/30i0
factory.qualifier(CurrentLiteral.CURRENT);
}
factory.qualifier(DefaultLiteral.DEFAULT);
Bean bean = factory.singleton(connectionFactory);
cdiManager.addBean(bean);
} catch (Exception e) {
throw ConfigException.create(e);
}
}