* @param deploymentReflectionIndex The reflection index
* @param applicationClasses @return The bindings for the environment entries
*/
protected List<BindingConfiguration> processDescriptorEntries(DeploymentUnit deploymentUnit, DeploymentDescriptorEnvironment environment, ResourceInjectionTarget resourceInjectionTarget, final ComponentDescription componentDescription, ClassLoader classLoader, DeploymentReflectionIndex deploymentReflectionIndex, final EEApplicationClasses applicationClasses) throws DeploymentUnitProcessingException {
final RemoteEnvironment remoteEnvironment = environment.getEnvironment();
final DeploymentClassIndex index = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.CLASS_INDEX);
List<BindingConfiguration> bindingDescriptions = new ArrayList<BindingConfiguration>();
EJBReferencesMetaData ejbRefs = remoteEnvironment.getEjbReferences();
if (ejbRefs != null) {
for (EJBReferenceMetaData ejbRef : ejbRefs) {
String name = ejbRef.getEjbRefName();
String ejbName = ejbRef.getLink();
String lookup = ejbRef.getLookupName() != null ? ejbRef.getLookupName() : ejbRef.getMappedName();
String remoteInterface = ejbRef.getRemote();
String home = ejbRef.getHome();
Class<?> remoteInterfaceType = null;
//if a home is specified this is the type that is bound
if (!isEmpty(home)) {
try {
remoteInterfaceType = index.classIndex(home).getModuleClass();
} catch (ClassNotFoundException e) {
throw MESSAGES.failedToLoadViewClass(e, home);
}
} else if (!isEmpty(remoteInterface)) {
try {
remoteInterfaceType = index.classIndex(remoteInterface).getModuleClass();
} catch (ClassNotFoundException e) {
throw MESSAGES.failedToLoadViewClass(e, remoteInterface);
}
}
if (!name.startsWith("java:")) {
name = environment.getDefaultContext() + name;
}
// our injection (source) comes from the local (ENC) lookup, no matter what.
LookupInjectionSource injectionSource = new LookupInjectionSource(name);
//add any injection targets
remoteInterfaceType = processInjectionTargets(resourceInjectionTarget, injectionSource, classLoader, deploymentReflectionIndex, ejbRef, remoteInterfaceType);
final BindingConfiguration bindingConfiguration;
EjbInjectionSource ejbInjectionSource = null;
if (!isEmpty(lookup)) {
if (!lookup.startsWith("java:")) {
bindingConfiguration = new BindingConfiguration(name, new EjbLookupInjectionSource(lookup, remoteInterfaceType));
} else {
bindingConfiguration = new BindingConfiguration(name, new LookupInjectionSource(lookup));
}
} else {
if (remoteInterfaceType == null) {
throw MESSAGES.couldNotDetermineEjbRefForInjectionTarget(name, resourceInjectionTarget);
}
if (!isEmpty(ejbName)) {
bindingConfiguration = new BindingConfiguration(name, ejbInjectionSource = new EjbInjectionSource(ejbName, remoteInterfaceType.getName(), name, deploymentUnit, appclient));
} else {
bindingConfiguration = new BindingConfiguration(name, ejbInjectionSource = new EjbInjectionSource(remoteInterfaceType.getName(), name, deploymentUnit, appclient));
}
}
if (ejbInjectionSource != null) {
deploymentUnit.addToAttachmentList(EjbDeploymentAttachmentKeys.EJB_INJECTIONS, ejbInjectionSource);
}
bindingDescriptions.add(bindingConfiguration);
}
}
if (remoteEnvironment instanceof Environment && !appclient) {
EJBLocalReferencesMetaData ejbLocalRefs = ((Environment) remoteEnvironment).getEjbLocalReferences();
if (ejbLocalRefs != null) {
for (EJBLocalReferenceMetaData ejbRef : ejbLocalRefs) {
String name = ejbRef.getEjbRefName();
String ejbName = ejbRef.getLink();
String lookup = ejbRef.getLookupName() != null ? ejbRef.getLookupName() : ejbRef.getMappedName();
String localInterface = ejbRef.getLocal();
String localHome = ejbRef.getLocalHome();
Class<?> localInterfaceType = null;
//if a home is specified this is the type that is bound
if (!isEmpty(localHome)) {
try {
localInterfaceType = index.classIndex(localHome).getModuleClass();
} catch (ClassNotFoundException e) {
throw MESSAGES.failedToLoadViewClass(e, localHome);
}
} else if (!isEmpty(localInterface)) {
try {
localInterfaceType = index.classIndex(localInterface).getModuleClass();
} catch (ClassNotFoundException e) {
throw MESSAGES.failedToLoadViewClass(e, localInterface);
}
}