}
}
}
public static void addEJBLocalRefs(EARContext earContext, URI uri, EjbLocalRefType[] ejbLocalRefs, Map ejbLocalRefMap, ClassLoader cl, ComponentContextBuilder builder) throws DeploymentException {
RefContext refContext = earContext.getRefContext();
J2eeContext j2eeContext = earContext.getJ2eeContext();
for (int i = 0; i < ejbLocalRefs.length; i++) {
EjbLocalRefType ejbLocalRef = ejbLocalRefs[i];
String ejbRefName = ejbLocalRef.getEjbRefName().getStringValue();
String local = ejbLocalRef.getLocal().getStringValue();
assureEJBLocalObjectInterface(local, cl);
String localHome = ejbLocalRef.getLocalHome().getStringValue();
assureEJBLocalHomeInterface(localHome, cl);
boolean isSession = "Session".equals(ejbLocalRef.getEjbRefType().getStringValue());
String ejbLink = null;
GerEjbLocalRefType localRef = (GerEjbLocalRefType) ejbLocalRefMap.get(ejbRefName);
if (localRef != null && localRef.isSetEjbLink()) {
ejbLink = localRef.getEjbLink();
} else if (ejbLocalRef.isSetEjbLink()) {
ejbLink = getJ2eeStringValue(ejbLocalRef.getEjbLink());
}
Reference ejbReference;
if (ejbLink != null) {
ejbReference = refContext.getEJBLocalRef(uri, ejbLink, isSession, localHome, local);
} else if (localRef != null) {
if (localRef.isSetTargetName()) {
ejbReference = refContext.getEJBLocalRef(localRef.getTargetName(), isSession, localHome, local);
} else {
String containerId = null;
try {
containerId = NameFactory.getEjbComponentNameString(localRef.getDomain(),
localRef.getServer(),
localRef.getApplication(),
localRef.getModule(),
localRef.getName(),
localRef.getType(),
j2eeContext);
} catch (MalformedObjectNameException e) {
throw new DeploymentException("Could not construct ejb object name: " + localRef.getName(), e);
}
ejbReference = refContext.getEJBLocalRef(containerId, isSession, localHome, local);
}
} else {
ejbReference = refContext.getImplicitEJBLocalRef(uri, ejbLink, isSession, localHome, local);
}
try {
builder.bind(ejbRefName, ejbReference);
} catch (NamingException e) {
throw new DeploymentException("Unable to to bind ejb-local-ref: ejb-ref-name=" + ejbRefName);