if (resources.size() == 0) return;
List<JndiConsumer> jndiConsumers = new ArrayList<JndiConsumer>();
for (WebModule webModule : module.getWebModules()) {
final JndiConsumer consumer = webModule.getWebApp();
jndiConsumers.add(consumer);
}
for (EjbModule ejbModule : module.getEjbModules()) {
Collections.addAll(jndiConsumers, ejbModule.getEjbJar().getEnterpriseBeans());
}
for (Resource resource : resources) {
Properties properties = resource.getProperties();
if (DataSource.class.getName().equals(resource.getType())
|| DataSource.class.getSimpleName().equals(resource.getType())) {
trimNotSupportedDataSourceProperties(properties);
}
ResourceInfo resourceInfo = configFactory.configureService(resource, ResourceInfo.class);
final ResourceRef resourceRef = new ResourceRef();
resourceRef.setResType(resource.getType());
if (DataSource.class.getName().equals(resource.getType())
&& resource.getProperties().containsKey(ORIGIN_FLAG)
&& resource.getProperties().getProperty(ORIGIN_FLAG).equals(ORIGIN_ANNOTATION)) {
properties.remove(ORIGIN_FLAG);
resourceInfo.id = module.getModuleId() + "/" + resourceInfo.id;
if (properties.get("JdbcUrl") == null) {
final String url = getVendorUrl(properties);
if (url != null) {
properties.put("JdbcUrl", url);
}
}
resourceRef.setResRefName(dataSourceLookupName(resource));
} else {
resourceRef.setResRefName(OPENEJB_RESOURCE_JNDI_PREFIX + resourceInfo.id);
}
resourceRef.setMappedName(resourceInfo.id);
for (JndiConsumer consumer : jndiConsumers) {
final ResourceRef existing = consumer.getResourceRefMap().get(resourceRef.getKey());
if (existing != null) {
existing.setMappedName(resourceRef.getMappedName());
} else {
consumer.getResourceRef().add(resourceRef);
}
}
installResource(module.getModuleId(), resourceInfo);
}