In order to get resource injection working in geronimo to pass the cdi tck, I
needed to change the CdiResourceInjectionService.getResourceReference method.
What I find works for all the tck cases is:
return resourceReference.getResourceType().cast(new
InitialContext().lookup(resourceReference.getJndiName()));
I assume we can cache the new InitialContext().
Is there some reason we need the current more complicated code that extracts
the jndi name from some openejb artifacts?
for (Entry<CdiBeanInfo, Context> entry : this.contexts.entrySet()) {
if (entry.getKey().getBeanClass() ==
resourceReference.getOwnerClass()) {
List<Injection> injections = entry.getKey().getInjections();
for (Injection injection : injections) {
if (injection.getTarget() ==
resourceReference.getOwnerClass() &&
injection.getName().equals(resourceReference.getName())) {
Context context =
InjectionProcessor.unwrap(entry.getValue());
try {
return
resourceReference.getResourceType().cast(context.lookup(injection.getJndiName()));
} catch (NamingException e2) {
logger.warning("Injection data not found in
JNDI context: jndiName='" + injection.getJndiName() + "', target=" +
injection.getTarget().getName() + "/" + injection.getName(), e2);
return null;
}
}
}
}
}
thanks
david jencks