if (plan == null) {
return;
}
XmlObject[] gbeanRefsUntyped = plan.selectChildren(GBEAN_REF_QNAME_SET);
for (XmlObject gbeanRefUntyped : gbeanRefsUntyped) {
GerGbeanRefType gbeanRef = (GerGbeanRefType) gbeanRefUntyped.copy().changeType(GerGbeanRefType.type);
if (gbeanRef == null) {
throw new DeploymentException("Could not read gbeanRef " + gbeanRefUntyped + " as the correct xml type");
}
GerPatternType[] gbeanLocatorArray = gbeanRef.getPatternArray();
String[] interfaceTypesArray = gbeanRef.getRefTypeArray();
Set<String> interfaceTypes = new HashSet<String>(Arrays.asList(interfaceTypesArray));
Set<AbstractNameQuery> queries = new HashSet<AbstractNameQuery>();
for (GerPatternType patternType : gbeanLocatorArray) {
AbstractNameQuery abstractNameQuery = ENCConfigBuilder.buildAbstractNameQuery(patternType, null, null, interfaceTypes);
queries.add(abstractNameQuery);
}
GBeanData gBeanData;
try {
gBeanData = module.getEarContext().getConfiguration().findGBeanData(queries);
} catch (GBeanNotFoundException e) {
throw new DeploymentException("Could not resolve reference at deploy time for queries " + queries, e);
}
if (interfaceTypes.isEmpty()) {
interfaceTypes.add(gBeanData.getGBeanInfo().getClassName());
}
Bundle bundle = module.getEarContext().getDeploymentBundle();
Class gBeanType;
try {
gBeanType = ClassLoading.loadClass(gBeanData.getGBeanInfo().getClassName(), bundle);
} catch (ClassNotFoundException e) {
throw new DeploymentException("Cannot load GBean class", e);
}
String refName = gbeanRef.getRefName();
put(refName, new GBeanReference(module.getConfigId(), queries, gBeanType), ReferenceType.GBEAN, module.getJndiContext(), Collections.<InjectionTarget> emptySet(), sharedContext);
}
}