{
super.init();
Bean comp = getComponent();
InjectManager manager = InjectManager.create();
ManagedConnectionFactory managedFactory
= (ManagedConnectionFactory) manager.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();
BeanFactory factory
= manager.createBeanFactory(connectionFactory.getClass());
if (getName() != null) {
Jndi.bindDeepShort(getName(), connectionFactory);
factory.name(getName());
factory.binding(Names.create(getName()));
// server/30i0
factory.binding(CurrentLiteral.CURRENT);
}
Bean bean = factory.singleton(connectionFactory);
manager.addBean(bean);
} catch (Exception e) {
throw ConfigException.create(e);
}
}