ConnectionDefinitionInstance[] old = getConnectionDefinitionInstance();
this.instances = instances;
for (int i = 0; i < instances.length; i++) { // catch additions
ConnectionDefinitionInstance instance = instances[i];
if (!instance.hasParent()) {
GerConnectiondefinitionInstanceType xmlObject = getConnectionDefinition().addNewConnectiondefinitionInstance();
xmlObject.setConnectionmanager(GerConnectionmanagerType.Factory.newInstance());
instance.initialize(xmlObject, this);
}
}
for (int i = 0; i < old.length; i++) { // catch removals
ConnectionDefinitionInstance instance = old[i];
boolean found = false;
for (int j = 0; j < instances.length; j++) {
if (instances[j] == instance) {
found = true;
break;
}
}
if (!found) {
// remove the XmlBean
for (int j = 0; j < getConnectionDefinition().getConnectiondefinitionInstanceArray().length; j++) {
GerConnectiondefinitionInstanceType test = getConnectionDefinition().getConnectiondefinitionInstanceArray(j);
if (test == instance.getConnectiondefinitionInstance()) {
getConnectionDefinition().removeConnectiondefinitionInstance(j);
break;
}
}