}
static void addEJBRefs(NamingContext earContext, NamingContext ejbContext, RefContext refContext, URI moduleURI, EjbRefType[] ejbRefs, Map ejbRefMap, ClassLoader cl, ComponentContextBuilder builder) throws DeploymentException {
J2eeContext j2eeContext = ejbContext.getJ2eeContext();
for (int i = 0; i < ejbRefs.length; i++) {
EjbRefType ejbRef = ejbRefs[i];
String ejbRefName = getStringValue(ejbRef.getEjbRefName());
String remote = getStringValue(ejbRef.getRemote());
try {
assureEJBObjectInterface(remote, cl);
} catch (DeploymentException e) {
throw new DeploymentException("Error processing 'remote' element for EJB Reference '"+ejbRefName+"' for module '"+moduleURI+"': "+e.getMessage());
}
String home = getStringValue(ejbRef.getHome());
try {
assureEJBHomeInterface(home, cl);
} catch (DeploymentException e) {
throw new DeploymentException("Error processing 'home' element for EJB Reference '"+ejbRefName+"' for module '"+moduleURI+"': "+e.getMessage());
}
Reference ejbReference;
boolean isSession = "Session".equals(getStringValue(ejbRef.getEjbRefType()));
if (isSession && remote.equals("javax.management.j2ee.Management") && home.equals("javax.management.j2ee.ManagementHome")) {
String mejbName = refContext.getMEJBName();
ejbReference = refContext.getEJBRemoteRef(mejbName, isSession, home, remote);
} else {
String ejbLink = null;
GerEjbRefType remoteRef = (GerEjbRefType) ejbRefMap.get(ejbRefName);
if (remoteRef != null && remoteRef.isSetNsCorbaloc()) {
try {
ObjectName cssBean;
if (remoteRef.isSetCssName()) {
cssBean = ObjectName.getInstance(getStringValue(remoteRef.getCssName()));
} else if (remoteRef.isSetCssLink()) {
String cssLink = remoteRef.getCssLink().trim();
//TODO is this correct?
String moduleType = null;
cssBean = refContext.locateComponentName(cssLink, moduleURI, moduleType, NameFactory.CORBA_CSS, earContext.getJ2eeContext(), earContext, "css gbean");
} else {
GerCssType css = remoteRef.getCss();
cssBean = NameFactory.getComponentName(getStringValue(css.getDomain()),
getStringValue(css.getServer()),
getStringValue(css.getApplication()),
getStringValue(css.getModule()),
getStringValue(css.getName()),
getStringValue(NameFactory.CORBA_CSS),
earContext.getJ2eeContext());
}
ejbReference = refContext.getCORBARemoteRef(new URI(getStringValue(remoteRef.getNsCorbaloc())),
getStringValue(remoteRef.getName()),
ObjectName.getInstance(cssBean),
home);
} catch (URISyntaxException e) {
throw new DeploymentException("Could not construct CORBA NameServer URI: " + remoteRef.getNsCorbaloc(), e);
} catch (MalformedObjectNameException e) {
throw new DeploymentException("Could not construct CSS container name: " + remoteRef.getCssName(), e);
}
} else {
if (remoteRef != null && remoteRef.isSetEjbLink()) {
ejbLink = remoteRef.getEjbLink();
} else if (ejbRef.isSetEjbLink()) {
ejbLink = getStringValue(ejbRef.getEjbLink());
}
if (ejbLink != null) {
ejbReference = refContext.getEJBRemoteRef(moduleURI, ejbLink, isSession, home, remote, ejbContext);
} else if (remoteRef != null) {