ResourceAdapter adapter = connector.getResourceAdapter()[0];
ConnectionDefinition definition = new ConnectionDefinition();
adapter.setConnectionDefinition(new ConnectionDefinition[]{definition});
definition.setConnectionFactoryInterface("javax.sql.DataSource");
ConnectionDefinitionInstance instance = new ConnectionDefinitionInstance();
definition.setConnectionInstance(new ConnectionDefinitionInstance[]{instance});
instance.setName(data.getName());
ConfigPropertySetting[] settings = instance.getConfigPropertySetting();
if (data.isGeneric()) { // it's a generic TranQL JDBC pool
for (ConfigPropertySetting setting : settings) {
if (setting.getName().equals("UserName")) {
setting.setValue(data.user);
} else if (setting.getName().equals("Password")) {
setting.setValue(data.password);
} else if (setting.getName().equals("ConnectionURL")) {
setting.setValue(data.url);
} else if (setting.getName().equals("Driver")) {
setting.setValue(data.driverClass);
}
}
} else { // it's an XA driver or non-TranQL RA
for (ConfigPropertySetting setting : settings) {
String value = data.properties.get("property-" + setting.getName());
setting.setValue(value == null ? "" : value);
}
}
ConnectionManager manager = instance.getConnectionManager();
if(XA.equals(data.transactionType)){
manager.setTransactionXA(true);
} else if (NONE.equals(data.transactionType)){
manager.setTransactionNone(true);
} else {