use of org.apache.openejb.assembler.classic.EjbResolver in project tomee by apache.
the class JndiEncInfoBuilder method buildDependsOnRefs.
public void buildDependsOnRefs(final EnterpriseBean enterpriseBean, final EnterpriseBeanInfo beanInfo, final String moduleId) throws OpenEJBException {
if (!(enterpriseBean instanceof SessionBean)) {
return;
}
final SessionBean sessionBean = (SessionBean) enterpriseBean;
final URI moduleUri;
if (moduleId == null) {
moduleUri = null;
} else {
moduleUri = URLs.uri(moduleId);
}
final EjbResolver ejbResolver = getEjbResolver(moduleId);
if (sessionBean.getDependsOn() != null) {
for (final String ejbName : sessionBean.getDependsOn()) {
final String deploymentId = ejbResolver.resolve(new SimpleRef(ejbName), moduleUri);
if (deploymentId != null) {
beanInfo.dependsOn.add(deploymentId);
}
}
}
}
use of org.apache.openejb.assembler.classic.EjbResolver 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<>(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