use of org.glassfish.weld.services.ResourceInjectionServicesImpl in project Payara by payara.
the class DeploymentImpl method loadBeanDeploymentArchive.
@Override
public BeanDeploymentArchive loadBeanDeploymentArchive(Class<?> beanClass) {
if (logger.isLoggable(FINE)) {
logger.log(FINE, CDILoggerInfo.LOAD_BEAN_DEPLOYMENT_ARCHIVE, new Object[] { beanClass });
}
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).getModuleBeanClasses().contains(beanClass.getName())) {
// 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 });
}
return bda;
}
// and get the right BDA for the beanClass
if (!bda.getBeanDeploymentArchives().isEmpty()) {
for (BeanDeploymentArchive subBda : bda.getBeanDeploymentArchives()) {
Collection<String> moduleBeanClassNames = ((BeanDeploymentArchiveImpl) subBda).getModuleBeanClasses();
if (logger.isLoggable(FINE)) {
logger.log(FINE, CDILoggerInfo.LOAD_BEAN_DEPLOYMENT_ARCHIVE_CHECKING_SUBBDA, new Object[] { beanClass, subBda.getId() });
}
boolean match = moduleBeanClassNames.contains(beanClass.getName());
if (match) {
// 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 });
}
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<>();
List<URL> beanXMLUrls = new CopyOnWriteArrayList<>();
Set<EjbDescriptor> ejbs = new HashSet<>();
beanClasses.add(beanClass);
BeanDeploymentArchive newBda = new BeanDeploymentArchiveImpl(beanClass.getName(), beanClasses, beanXMLUrls, ejbs, context);
// have to create new InjectionServicesImpl for each new BDA so injection context is propagated for the correct bundle
newBda.getServices().add(InjectionServices.class, new InjectionServicesImpl(injectionManager, DOLUtils.getCurrentBundleForContext(context), this));
newBda.getServices().add(ResourceInjectionServices.class, new ResourceInjectionServicesImpl());
BeansXml beansXml = newBda.getBeansXml();
if (beansXml == null || !beansXml.getBeanDiscoveryMode().equals(BeanDiscoveryMode.NONE)) {
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 });
}
beanDeploymentArchives.add(newBda);
// Make all previously found extension BDAs visible to this extension BDA
newBda.getBeanDeploymentArchives().addAll(extensionBDAMap.values());
idToBeanDeploymentArchive.put(newBda.getId(), newBda);
extensionBDAMap.put(beanClass.getClassLoader(), newBda);
return newBda;
}
return null;
}
Aggregations