}
List<BeanDeploymentArchive> beanDeploymentArchives = getBeanDeploymentArchives();
ListIterator<BeanDeploymentArchive> lIter = beanDeploymentArchives.listIterator();
while (lIter.hasNext()) {
BeanDeploymentArchive bda = lIter.next();
if ( logger.isLoggable( FINE ) ) {
logger.log(FINE,
CDILoggerInfo.LOAD_BEAN_DEPLOYMENT_ARCHIVE_CHECKING,
new Object[] { beanClass, 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,
CDILoggerInfo.LOAD_BEAN_DEPLOYMENT_ARCHIVE_ADD_TO_EXISTING,
new Object[] {beanClass.getName(), 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,
CDILoggerInfo.LOAD_BEAN_DEPLOYMENT_ARCHIVE_CHECKING_SUBBDA,
new Object[] {beanClass, 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,
CDILoggerInfo.LOAD_BEAN_DEPLOYMENT_ARCHIVE_ADD_TO_EXISTING,
new Object[]{ beanClass.getName(), subBda});
}
//((BeanDeploymentArchiveImpl)subBda).addBeanClass(beanClass.getName());
return subBda;
}
}
}
}
BeanDeploymentArchive extensionBDA = extensionBDAMap.get(beanClass.getClassLoader());
if ( extensionBDA != null ) {
return extensionBDA;
}
// If the BDA was not found for the Class, create one and add it
if ( logger.isLoggable( FINE ) ) {
logger.log(FINE, CDILoggerInfo.LOAD_BEAN_DEPLOYMENT_ARCHIVE_CREATE_NEW_BDA, new Object []{beanClass});
}
List<Class<?>> beanClasses = new ArrayList<Class<?>>();
List<URL> beanXMLUrls = new CopyOnWriteArrayList<URL>();
Set<EjbDescriptor> ejbs = new HashSet<EjbDescriptor>();
beanClasses.add(beanClass);
BeanDeploymentArchive newBda =
new BeanDeploymentArchiveImpl(beanClass.getName(),
beanClasses, beanXMLUrls, ejbs, context);
if ( logger.isLoggable( FINE ) ) {
logger.log(FINE,
CDILoggerInfo.LOAD_BEAN_DEPLOYMENT_ARCHIVE_ADD_NEW_BDA_TO_ROOTS,
new Object[] {} );
}
lIter = beanDeploymentArchives.listIterator();
while (lIter.hasNext()) {
BeanDeploymentArchive bda = lIter.next();
bda.getBeanDeploymentArchives().add(newBda);
}
if ( logger.isLoggable( FINE ) ) {
logger.log(FINE,
CDILoggerInfo.LOAD_BEAN_DEPLOYMENT_ARCHIVE_RETURNING_NEWLY_CREATED_BDA,
new Object[]{beanClass, newBda});