use of org.apache.openejb.jee.EjbReference in project tomee by apache.
the class JndiEncInfoBuilder method buildEjbRefs.
private void buildEjbRefs(final JndiConsumer jndiConsumer, final URI moduleUri, final String moduleId, final String ejbName, final JndiEncInfo moduleJndiEnc, final JndiEncInfo compJndiEnc) throws OpenEJBException {
final Collection<EjbRef> ejbRefs = jndiConsumer.getEjbRef();
final Collection<EjbLocalRef> ejbLocalRefs = jndiConsumer.getEjbLocalRef();
final List<EjbReference> references = new ArrayList<EjbReference>(ejbRefs.size() + ejbLocalRefs.size());
references.addAll(ejbRefs);
references.addAll(ejbLocalRefs);
for (final EjbReference ref : references) {
final EjbReferenceInfo info = new EjbReferenceInfo();
info.homeClassName = ref.getHome();
info.interfaceClassName = ref.getInterface();
info.referenceName = ref.getName();
info.link = ref.getEjbLink();
info.location = buildLocationInfo(ref);
info.targets.addAll(buildInjectionInfos(ref));
info.localbean = isIntefaceLocalBean(info.interfaceClassName);
if (info.location != null) {
if (ref.getRefType() == EjbReference.Type.LOCAL) {
insert(toLocal(info), appInfo.globalJndiEnc.ejbLocalReferences, appInfo.appJndiEnc.ejbLocalReferences, moduleJndiEnc.ejbLocalReferences, compJndiEnc.ejbLocalReferences);
} else {
insert(info, appInfo.globalJndiEnc.ejbReferences, appInfo.appJndiEnc.ejbReferences, moduleJndiEnc.ejbReferences, compJndiEnc.ejbReferences);
}
continue;
}
final EjbResolver ejbResolver = getEjbResolver(moduleId);
final String deploymentId = ejbResolver.resolve(new Ref(ref), moduleUri);
info.ejbDeploymentId = deploymentId;
if (info.ejbDeploymentId == null) {
if (info.link != null) {
logger.warning("config.noBeanFoundEjbLink", ref.getName(), ejbName, ref.getEjbLink());
} else {
logger.warning("config.noBeanFound", ref.getName(), ejbName, ref.getEjbLink());
}
} else {
final EjbResolver.Scope scope = ejbResolver.getScope(deploymentId);
info.externalReference = scope != EAR && scope != EJBJAR;
if (ref.getRefType() == EjbReference.Type.UNKNOWN) {
final EnterpriseBeanInfo otherBean = ejbResolver.getEnterpriseBeanInfo(deploymentId);
if (otherBean != null) {
if (otherBean.businessLocal.contains(ref.getInterface()) || otherBean.ejbClass.equals(ref.getInterface())) {
ref.setRefType(EjbReference.Type.LOCAL);
ejbRefs.remove(ref);
ejbLocalRefs.add(new EjbLocalRef(ref));
} else {
ref.setRefType(EjbReference.Type.REMOTE);
}
}
}
}
if (ref.getRefType() == EjbReference.Type.LOCAL) {
insert(toLocal(info), appInfo.globalJndiEnc.ejbLocalReferences, appInfo.appJndiEnc.ejbLocalReferences, moduleJndiEnc.ejbLocalReferences, compJndiEnc.ejbLocalReferences);
} else {
insert(info, appInfo.globalJndiEnc.ejbReferences, appInfo.appJndiEnc.ejbReferences, moduleJndiEnc.ejbReferences, compJndiEnc.ejbReferences);
}
}
}
Aggregations