throw MESSAGES.cannotLoad(e, resourceRef.getType());
}
}
// our injection (source) comes from the local (ENC) lookup, no matter what.
LookupInjectionSource injectionSource = new LookupInjectionSource(name);
classType = processInjectionTargets(resourceInjectionTarget, injectionSource, classLoader, deploymentReflectionIndex, resourceRef, classType);
final BindingConfiguration bindingConfiguration;
if (!isEmpty(resourceRef.getLookupName())) {
bindingConfiguration = new BindingConfiguration(name, new LookupInjectionSource(resourceRef.getLookupName()));
} else if (!isEmpty(resourceRef.getResUrl())) {
//
if (classType != null && classType.equals(URI.class)) {
try {
//we need a newURI every time
bindingConfiguration = new BindingConfiguration(name, new FixedInjectionSource(new ManagedReferenceFactory() {
@Override
public ManagedReference getReference() {
try {
return new ValueManagedReference(new ImmediateValue(new URI(resourceRef.getResUrl())));
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
}
}, new URI(resourceRef.getResUrl())));
} catch (URISyntaxException e) {
throw MESSAGES.cannotParseResourceRefUri(e, resourceRef.getResUrl());
}
} else {
try {
bindingConfiguration = new BindingConfiguration(name, new FixedInjectionSource(new ManagedReferenceFactory() {
@Override
public ManagedReference getReference() {
try {
return new ValueManagedReference(new ImmediateValue(new URL(resourceRef.getResUrl())));
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
}
}, new URL(resourceRef.getResUrl())));
} catch (MalformedURLException e) {
throw MESSAGES.cannotParseResourceRefUri(e, resourceRef.getResUrl());
}
}
} else {
if (classType == null) {
throw MESSAGES.cannotDetermineType(name);
}
//check if it is a well known type
final String lookup = ResourceInjectionAnnotationParsingProcessor.FIXED_LOCATIONS.get(classType.getName());
if (lookup != null) {
bindingConfiguration = new BindingConfiguration(name, new LookupInjectionSource(lookup));
} else {
final EEResourceReferenceProcessor resourceReferenceProcessor = registry.getResourceReferenceProcessor(classType.getName());
if (resourceReferenceProcessor != null) {
InjectionSource valueSource = resourceReferenceProcessor.getResourceReferenceBindingSource();
bindingConfiguration = new BindingConfiguration(name, valueSource);
} else if (!resourceRef.getResourceRefName().startsWith("java:")) {
bindingConfiguration = new BindingConfiguration(name, new LookupInjectionSource("java:jboss/resources/" + resourceRef.getResourceRefName()));
} else {
//if we cannot resolve it just log
ROOT_LOGGER.cannotResolve("resource-env-ref", name);
continue;
}