}
List<BeanDeploymentArchive> beanDeploymentArchives = getBeanDeploymentArchives();
ListIterator<BeanDeploymentArchive> lIter = beanDeploymentArchives.listIterator();
while (lIter.hasNext()) {
BeanDeploymentArchive bda = lIter.next();
if ( logger.isLoggable( FINE ) ) {
logger.log(FINE, "checking for " + beanClass + " in root BDA" + bda.getId());
}
if (((BeanDeploymentArchiveImpl)bda).getModuleBeanClassObjects().contains(beanClass)) {
//don't stuff this Bean Class into the BDA's beanClasses,
//as Weld automatically add theses classes to the BDA's bean Classes
if ( logger.isLoggable( FINE ) ) {
logger.log(FINE, "DeploymentImpl(as part of loadBDA)::An " +
"existing BDA has this class " + beanClass.getName()
+ " and so adding this class as a bean class it to " +
"existing bda: " + bda);
//((BeanDeploymentArchiveImpl)bda).addBeanClass(beanClass.getName());
}
return bda;
}
//XXX: As of now, we handle one-level. Ideally, a bean deployment
//descriptor is a composite and we should be able to search the tree
//and get the right BDA for the beanClass
if (bda.getBeanDeploymentArchives().size() > 0) {
for(BeanDeploymentArchive subBda: bda.getBeanDeploymentArchives()){
Collection<Class<?>> moduleBeanClasses = ((BeanDeploymentArchiveImpl)subBda).getModuleBeanClassObjects();
if ( logger.isLoggable( FINE ) ) {
logger.log(FINE, "checking for " + beanClass + " in subBDA" + subBda.getId());
}
boolean match = moduleBeanClasses.contains(beanClass);
if (match) {
//don't stuff this Bean Class into the BDA's beanClasses,
//as Weld automatically add theses classes to the BDA's bean Classes
if ( logger.isLoggable( FINE ) ) {
logger.log(FINE, "DeploymentImpl(as part of loadBDA)::" +
"An existing BDA has this class "
+ beanClass.getName() + " and so adding this " +
"class as a bean class to existing bda:" + subBda);
}
//((BeanDeploymentArchiveImpl)subBda).addBeanClass(beanClass.getName());
return subBda;
}
}
}
}
// If the BDA was not found for the Class, create one and add it
if ( logger.isLoggable( FINE ) ) {
logger.log(FINE, "+++++ DeploymentImpl(as part of loadBDA):: beanClass "
+ beanClass + " not found in the BDAs of this deployment. " +
"Hence creating a new BDA");
}
List<Class<?>> beanClasses = new ArrayList<Class<?>>();
List<URL> beanXMLUrls = new CopyOnWriteArrayList<URL>();
Set<EjbDescriptor> ejbs = new HashSet<EjbDescriptor>();
beanClasses.add(beanClass);
// Workaround for WELD-1182
// TODO: The workaround will be removed once the defect is addressed.
WeldGFExtension gfExtension = beanClass.getAnnotation(WeldGFExtension.class);
if(gfExtension != null)
beanClasses.addAll(java.util.Arrays.asList(gfExtension.beans()));
BeanDeploymentArchive newBda =
new BeanDeploymentArchiveImpl(beanClass.getName(),
beanClasses, beanXMLUrls, ejbs, context);
if ( logger.isLoggable( FINE ) ) {
logger.log(FINE, "DeploymentImpl(as part of loadBDA):: new BDA "
+ newBda + "created. Now adding this new BDA to " +
"all root BDAs of this deployment");
}
lIter = beanDeploymentArchives.listIterator();
while (lIter.hasNext()) {
BeanDeploymentArchive bda = lIter.next();
bda.getBeanDeploymentArchives().add(newBda);
}
if ( logger.isLoggable( FINE ) ) {
logger.log(FINE, "DeploymentImpl(as part of loadBDA):: for beanClass "
+ beanClass + " finally returning the " +
"newly created BDA " + newBda);