}
logger.debug(message);
// if there is a provider with the specified name. use it
if (ServiceUtils.hasServiceProvider(resourceId)) {
ResourceInfo resourceInfo = configFactory.configureService(resourceId, ResourceInfo.class);
return installResource(beanName, resourceInfo);
} else if (ServiceUtils.hasServiceProvider(shortName)) {
ResourceInfo resourceInfo = configFactory.configureService(shortName, ResourceInfo.class);
return installResource(beanName, resourceInfo);
}
// if there are any resources of the desired type, use the first one
if (resourceIds.size() > 0) {
return resourceIds.get(0);
}
// Auto create a resource using the first provider that can supply a resource of the desired type
resourceId = ServiceUtils.getServiceProviderId(type);
if (resourceId == null) {
throw new OpenEJBException("No provider available for resource reference '" + resourceId + "' of type '" + type + "' for '" + beanName + "'.");
}
ResourceInfo resourceInfo = configFactory.configureService(resourceId, ResourceInfo.class);
logger.info("Auto-creating a resource with id '" + resourceInfo.id + "' of type '" + type + " for '" + beanName + "'.");
return installResource(beanName, resourceInfo);
}