if (URL.class.equals(type)) {
reference = new URLReference(referenceInfo.resourceID);
} else if (type.isAnnotationPresent(ManagedBean.class)) {
ManagedBean managed = type.getAnnotation(ManagedBean.class);
String name = managed.value().length() == 0 ? type.getSimpleName() : managed.value();
reference = new LinkRef("module/" + name);
} else if (Request.class.equals(type)) {
reference = new ObjectReference(ThreadLocalContextManager.REQUEST);
} else if (UriInfo.class.equals(type)) {
reference = new ObjectReference(ThreadLocalContextManager.URI_INFO);
} else if (HttpHeaders.class.equals(type)) {
reference = new ObjectReference(ThreadLocalContextManager.HTTP_HEADERS);
} else if (SecurityContext.class.equals(type)) {
reference = new ObjectReference(ThreadLocalContextManager.SECURITY_CONTEXT);
} else if (ContextResolver.class.equals(type)) {
reference = new ObjectReference(ThreadLocalContextManager.CONTEXT_RESOLVER);
} else if (referenceInfo.resourceID != null) {
String jndiName = "openejb/Resource/" + referenceInfo.resourceID;
reference = new IntraVmJndiReference(jndiName);
} else {
String jndiName = "openejb/Resource/" + referenceInfo.referenceName;
reference = new IntraVmJndiReference(jndiName);
}
bindings.put(normalize(referenceInfo.referenceName), reference);
}
for (ResourceEnvReferenceInfo referenceInfo : jndiEnc.resourceEnvRefs) {
if (referenceInfo.location != null) {
Reference reference = buildReferenceLocation(referenceInfo.location);
bindings.put(normalize(referenceInfo.referenceName), reference);
continue;
}
final Class<?> type = getType(referenceInfo.resourceEnvRefType, referenceInfo);
final Object reference;
if (EJBContext.class.isAssignableFrom(type)) {
String jndiName = "comp/EJBContext";
reference = new LinkRef(jndiName);
// Let the container bind this into JNDI
if (jndiName.equals(referenceInfo.referenceName)) continue;
} else if (Validator.class.equals(type)) {
String jndiName = "comp/Validator";
reference = new LinkRef(jndiName);
} else if (ValidatorFactory.class.equals(type)) {
String jndiName = "comp/ValidatorFactory";
reference = new LinkRef(jndiName);
} else if (WebServiceContext.class.equals(type)) {
String jndiName = "comp/WebServiceContext";
reference = new LinkRef(jndiName);
} else if (TimerService.class.equals(type)) {
String jndiName = "comp/TimerService";
reference = new LinkRef(jndiName);
// TODO Bind the BeanManager
} else if (BeanManager.class.equals(type)) {
String jndiName = "java:app/BeanManager";
reference = new LinkRef(jndiName);
} else if (UserTransaction.class.equals(type)) {
reference = new IntraVmJndiReference("comp/UserTransaction");
} else if (referenceInfo.resourceID != null) {
String jndiName = "openejb/Resource/" + referenceInfo.resourceID;