List existingResources = null;
try {
existingResources = persistencyManager.load(name);
}
catch (IOException ioe) {
throw new ResourceProcessorException(ResourceProcessorException.CODE_PREPARE, "Unable to read existing resources for resource " + name, ioe);
}
// update configuration
if (m_resource.isFactoryConfig()) {
// check if this is an factory config instance update
for (Iterator i = existingResources.iterator(); i.hasNext();) {
AutoConfResource existingResource = (AutoConfResource) i.next();
if (m_resource.equalsTargetConfiguration(existingResource)) {
// existing instance found
configuration = configAdmin.getConfiguration(existingResource.getGeneratedPid(), bundleLocation);
existingResources.remove(existingResource);
break;
}
}
if (configuration == null) {
// no existing instance, create new
configuration = configAdmin.createFactoryConfiguration(m_resource.getFactoryPid(), bundleLocation);
}
m_resource.setGeneratedPid(configuration.getPid());
}
else {
for (Iterator i = existingResources.iterator(); i.hasNext();) {
AutoConfResource existingResource = (AutoConfResource) i.next();
if (m_resource.getPid().equals(existingResource.getPid())) {
// existing resource found
existingResources.remove(existingResource);
break;
}
}
configuration = configAdmin.getConfiguration(m_resource.getPid(), bundleLocation);
if (!bundleLocation.equals(configuration.getBundleLocation())) {
// an existing configuration exists that is bound to a different location, which is not allowed
throw new ResourceProcessorException(ResourceProcessorException.CODE_PREPARE, "Existing configuration was bound to " + configuration.getBundleLocation() + " instead of " + bundleLocation);
}
}
if (m_resource.isMerge()) {
Dictionary existingProperties = configuration.getProperties();
if (existingProperties != null) {