if (!isEmpty(lookup) && !isEmpty(beanName)) {
logger.debug("Both beanName = " + beanName + " and lookup = " + lookup + " have been specified in @EJB annotation." +
" lookup will be given preference. Class: " + classInfo.name());
}
final EEModuleClassDescription classDescription = eeModuleDescription.addOrGetLocalClassDescription(classInfo.name().toString());
final InjectionSource valueSource;
EjbInjectionSource ejbInjectionSource = null;
//give preference to lookup
if (!isEmpty(lookup)) {
if (!lookup.startsWith("java:")) {
valueSource = new EjbLookupInjectionSource(lookup, targetDescription.getDeclaredValueClassName());
} else {
valueSource = createLookup(lookup, appclient);
}
} else if (!isEmpty(beanName)) {
valueSource = ejbInjectionSource = new EjbInjectionSource(beanName, beanInterface, localContextName, deploymentUnit, appclient);
} else {
valueSource = ejbInjectionSource = new EjbInjectionSource(beanInterface, localContextName, deploymentUnit, appclient);
}
if (ejbInjectionSource != null) {
deploymentUnit.addToAttachmentList(EjbDeploymentAttachmentKeys.EJB_INJECTIONS, ejbInjectionSource);
}
// our injection comes from the local lookup, no matter what.
final ResourceInjectionConfiguration injectionConfiguration = targetDescription != null ?
new ResourceInjectionConfiguration(targetDescription, createLookup(localContextName, appclient)) : null;
// Create the binding from whence our injection comes.
final BindingConfiguration bindingConfiguration = new BindingConfiguration(localContextName, valueSource);
classDescription.getBindingConfigurations().add(bindingConfiguration);
if (injectionConfiguration != null) {
classDescription.addResourceInjection(injectionConfiguration);
}
}