} else {
String jndiName = "openejb/Deployment/" + JndiBuilder.format(referenceInfo.ejbDeploymentId, referenceInfo.interfaceClassName, InterfaceType.BUSINESS_REMOTE);
if (useCrossClassLoaderRef && referenceInfo.externalReference) {
reference = new CrossClassLoaderJndiReference(jndiName);
} else {
reference = new IntraVmJndiReference(jndiName);
}
}
bindings.put(normalize(referenceInfo.referenceName), reference);
}
for (EjbReferenceInfo referenceInfo : jndiEnc.ejbLocalReferences) {
Reference reference = null;
if (referenceInfo.location != null) {
reference = buildReferenceLocation(referenceInfo.location);
} else if (referenceInfo.ejbDeploymentId == null){
reference = new LazyEjbReference(new Ref(referenceInfo), moduleUri, false);
} else {
String jndiName = "openejb/Deployment/" + JndiBuilder.format(referenceInfo.ejbDeploymentId, referenceInfo.interfaceClassName, referenceInfo.localbean ? InterfaceType.LOCALBEAN : InterfaceType.BUSINESS_LOCAL);
reference = new IntraVmJndiReference(jndiName);
}
bindings.put(normalize(referenceInfo.referenceName), reference);
}
for (EnvEntryInfo entry : jndiEnc.envEntries) {
if (entry.location != null) {
Reference reference = buildReferenceLocation(entry.location);
bindings.put(normalize(entry.name), reference);
continue;
}
try {
Class type = Class.forName(entry.type.trim());
Object obj = null;
if (type == String.class)
obj = new String(entry.value);
else if (type == Double.class) {
obj = new Double(entry.value);
} else if (type == Integer.class) {
obj = new Integer(entry.value);
} else if (type == Long.class) {
obj = new Long(entry.value);
} else if (type == Float.class) {
obj = new Float(entry.value);
} else if (type == Short.class) {
obj = new Short(entry.value);
} else if (type == Boolean.class) {
obj = new Boolean(entry.value);
} else if (type == Byte.class) {
obj = new Byte(entry.value);
} else if (type == Character.class) {
StringBuilder sb = new StringBuilder(entry.value + " ");
obj = new Character(sb.charAt(0));
} else if (type == URL.class) {
obj = new URL(entry.value);
} else {
throw new IllegalArgumentException("Invalid env-ref-type " + type);
}
bindings.put(normalize(entry.name), obj);
} catch (ClassNotFoundException e) {
throw new IllegalArgumentException("Invalid environment entry type: " + entry.type.trim() + " for entry: " + entry.name, e);
} catch (NumberFormatException e) {
throw new IllegalArgumentException("The env-entry-value for entry " + entry.name + " was not recognizable as type " + entry.type + ". Received Message: " + e.getLocalizedMessage(), e);
} catch (MalformedURLException e) {
throw new IllegalArgumentException("URL for reference " + entry.name + " was not a valid URL: " + entry.value, e);
}
}
for (ResourceReferenceInfo referenceInfo : jndiEnc.resourceRefs) {
Reference reference = null;
if ("java.net.URL".equals(referenceInfo.referenceType)) {
if (referenceInfo.location != null) {
reference = buildReferenceLocation(referenceInfo.location);
} else {
reference = new URLReference(referenceInfo.resourceID);
}
} else if (referenceInfo.location != null) {
reference = buildReferenceLocation(referenceInfo.location);
} 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) {
LinkRef linkRef = null;
try {
Class<?> type = Class.forName(referenceInfo.resourceEnvRefType, true, EJBContext.class.getClassLoader());
if (EJBContext.class.isAssignableFrom(type)) {
String jndiName = "java:comp/EJBContext";
linkRef = new LinkRef(jndiName);
bindings.put(normalize(referenceInfo.resourceEnvRefName), linkRef);
continue;
} else if (WebServiceContext.class.equals(type)) {
String jndiName = "java:comp/WebServiceContext";
linkRef = new LinkRef(jndiName);
bindings.put(normalize(referenceInfo.resourceEnvRefName), linkRef);
continue;
} else if (TimerService.class.equals(type)) {
String jndiName = "java:comp/TimerService";
linkRef = new LinkRef(jndiName);
bindings.put(normalize(referenceInfo.resourceEnvRefName), linkRef);
continue;
}
} catch (ClassNotFoundException e) {
}
Object reference = null;
if (UserTransaction.class.getName().equals(referenceInfo.resourceEnvRefType)) {
reference = userTransaction;
} else if (referenceInfo.location != null){
reference = buildReferenceLocation(referenceInfo.location);
} else if (referenceInfo.resourceID != null) {
String jndiName = "openejb/Resource/" + referenceInfo.resourceID;
reference = new IntraVmJndiReference(jndiName);
} else {
String jndiName = "openejb/Resource/" + referenceInfo.resourceEnvRefName;
reference = new IntraVmJndiReference(jndiName);
}
if (reference != null) {
bindings.put(normalize(referenceInfo.resourceEnvRefName), reference);
}
}
for (PersistenceUnitReferenceInfo referenceInfo : jndiEnc.persistenceUnitRefs) {
if (referenceInfo.location != null){
Reference reference = buildReferenceLocation(referenceInfo.location);
bindings.put(normalize(referenceInfo.referenceName), reference);
continue;
}
String jndiName = "openejb/PersistenceUnit/" + referenceInfo.unitId;
Reference reference = new IntraVmJndiReference(jndiName);
bindings.put(normalize(referenceInfo.referenceName), reference);
}
for (PersistenceContextReferenceInfo contextInfo : jndiEnc.persistenceContextRefs) {
if (contextInfo.location != null){