log.debug("addEJB(): <ejb-ref> found");
String remoteRefName = getName(annotation.name(), method, field);
EjbRef ejbRef = annotatedApp.getEjbRefMap().get(getJndiName(remoteRefName));
if (ejbRef == null) {
try {
log.debug("addEJB(): Does not exist in DD: " + remoteRefName);
// Doesn't exist in deployment descriptor -- add new
ejbRef = new EjbRef();
//------------------------------------------------------------------------------
// <ejb-ref> required elements:
//------------------------------------------------------------------------------
// ejb-ref-name
ejbRef.setEjbRefName(remoteRefName);
//------------------------------------------------------------------------------
// <ejb-ref> optional elements:
//------------------------------------------------------------------------------
// remote
if (interfce != null) {
String remoteAnnotation = interfce.getName();
if (!remoteAnnotation.isEmpty()) {
ejbRef.setRemote(remoteAnnotation);
}
}
// ejb-link
String beanName = annotation.beanName();
if (!beanName.isEmpty()) {
ejbRef.setEjbLink(beanName);
}
// mappedName
String mappdedNameAnnotation = annotation.mappedName();
if (!mappdedNameAnnotation.isEmpty()) {
ejbRef.setMappedName(mappdedNameAnnotation);
}
// lookup
String lookupName = annotation.lookup();
if (!lookupName.isEmpty()) {
ejbRef.setLookupName(lookupName);
}
// description
String descriptionAnnotation = annotation.description();
if (!descriptionAnnotation.isEmpty()) {
ejbRef.setDescriptions(new Text[] {new Text(null, descriptionAnnotation) });
}
ejbRef.setRefType(EjbReference.Type.REMOTE);
annotatedApp.getEjbRef().add(ejbRef);
}
catch (Exception e) {
log.debug("EJBAnnotationHelper: Exception caught while processing <ejb-ref>", e);
}
}
// injectionTarget
if (method != null || field != null) {
Set<InjectionTarget> targets = ejbRef.getInjectionTarget();
if (!hasTarget(method, field, targets)) {
ejbRef.getInjectionTarget().add(configureInjectionTarget(method, field));
}
}
} // end if remote
else { // ambiguous
//--------------------------------------------------------------------------------------
// 3. <UNKNOWN>
//--------------------------------------------------------------------------------------
log.debug("addEJB(): <UNKNOWN> found");
String remoteRefName = getName(annotation.name(), method, field);
EjbRef ejbRef = annotatedApp.getEjbRefMap().get(getJndiName(remoteRefName));
if (ejbRef == null) {
try {
log.debug("addEJB(): Does not exist in DD: " + remoteRefName);
// Doesn't exist in deployment descriptor -- add as an <ejb-ref> to the
// ambiguous list so that it can be resolved later
ejbRef = new EjbRef();
//------------------------------------------------------------------------------
// <ejb-ref> required elements:
//------------------------------------------------------------------------------
// ejb-ref-name
ejbRef.setEjbRefName(remoteRefName);
//------------------------------------------------------------------------------
// <ejb-ref> optional elements:
//------------------------------------------------------------------------------
// remote
if (interfce != null) {
String remoteAnnotation = interfce.getName();
if (!remoteAnnotation.isEmpty()) {
ejbRef.setRemote(remoteAnnotation);
}
}
// ejb-link
String beanName = annotation.beanName();
if (!beanName.isEmpty()) {
ejbRef.setEjbLink(beanName);
}
// mappedName
String mappdedNameAnnotation = annotation.mappedName();
if (!mappdedNameAnnotation.isEmpty()) {
ejbRef.setMappedName(mappdedNameAnnotation);
}
// lookup
String lookupName = annotation.lookup();
if (!lookupName.isEmpty()) {
ejbRef.setLookupName(lookupName);
}
// description
String descriptionAnnotation = annotation.description();
if (!descriptionAnnotation.isEmpty()) {
ejbRef.setDescriptions(new Text[] {new Text(null, descriptionAnnotation) });
}
ejbRef.setRefType(EjbReference.Type.UNKNOWN);
//openejb sorts out ambiguous ejb refs.
annotatedApp.getEjbRef().add(ejbRef);
}
catch (Exception e) {
log.debug("EJBAnnotationHelper: Exception caught while processing <UNKNOWN>", e);
}
}
// injectionTarget
if (method != null || field != null) {
Set<InjectionTarget> targets = ejbRef.getInjectionTarget();
if (!hasTarget(method, field, targets)) {
ejbRef.getInjectionTarget().add(configureInjectionTarget(method, field));
}
}
}
log.debug("addEJB(): Exit");