use of org.jboss.weld.bootstrap.spi.BeanDeploymentArchive in project Payara by payara.
the class BeanDeploymentArchiveImpl method toString.
// A graphical representation of the BDA hierarchy to aid in debugging
// and to provide a better representation of how Weld treats the deployed
// archive.
@Override
public String toString() {
String beanClassesString = ((getBeanClasses().size() > 0) ? getBeanClasses().toString() : "");
String initVal = "|ID: " + getId() + ", bdaType= " + bdaType + ", accessibleBDAs #:" + getBeanDeploymentArchives().size() + ", " + formatAccessibleBDAs(this) + ", Bean Classes #: " + getBeanClasses().size() + "," + beanClassesString + ", ejbs=" + getEjbs() + "\n";
StringBuffer valBuff = new StringBuffer(initVal);
Collection<BeanDeploymentArchive> bdas = getBeanDeploymentArchives();
Iterator<BeanDeploymentArchive> iter = bdas.iterator();
while (iter.hasNext()) {
BeanDeploymentArchive bda = (BeanDeploymentArchive) iter.next();
BDAType embedBDAType = BDAType.UNKNOWN;
if (bda instanceof BeanDeploymentArchiveImpl) {
embedBDAType = ((BeanDeploymentArchiveImpl) bda).getBDAType();
}
String embedBDABeanClasses = ((bda.getBeanClasses().size() > 0) ? bda.getBeanClasses().toString() : "");
String val = "|---->ID: " + bda.getId() + ", bdaType= " + embedBDAType.toString() + ", accessibleBDAs #:" + bda.getBeanDeploymentArchives().size() + ", " + formatAccessibleBDAs(bda) + ", Bean Classes #: " + bda.getBeanClasses().size() + "," + embedBDABeanClasses + ", ejbs=" + bda.getEjbs() + "\n";
valBuff.append(val);
}
return valBuff.toString();
}
use of org.jboss.weld.bootstrap.spi.BeanDeploymentArchive in project Payara by payara.
the class DeploymentImpl method createLibJarBda.
private void createLibJarBda(RootBeanDeploymentArchive rootLibBda) {
BeanDeploymentArchive libModuleBda = rootLibBda.getModuleBda();
BeansXml moduleBeansXml = libModuleBda.getBeansXml();
if (moduleBeansXml == null || !moduleBeansXml.getBeanDiscoveryMode().equals(BeanDiscoveryMode.NONE)) {
addBdaToDeploymentBdas(rootLibBda);
addBdaToDeploymentBdas(libModuleBda);
if (libJarRootBdas == null) {
libJarRootBdas = new ArrayList<>();
}
for (RootBeanDeploymentArchive existingLibJarRootBda : libJarRootBdas) {
rootLibBda.getBeanDeploymentArchives().add(existingLibJarRootBda);
rootLibBda.getBeanDeploymentArchives().add(existingLibJarRootBda.getModuleBda());
rootLibBda.getModuleBda().getBeanDeploymentArchives().add(existingLibJarRootBda);
rootLibBda.getModuleBda().getBeanDeploymentArchives().add(existingLibJarRootBda.getModuleBda());
existingLibJarRootBda.getBeanDeploymentArchives().add(rootLibBda);
existingLibJarRootBda.getBeanDeploymentArchives().add(rootLibBda.getModuleBda());
existingLibJarRootBda.getModuleBda().getBeanDeploymentArchives().add(rootLibBda);
existingLibJarRootBda.getModuleBda().getBeanDeploymentArchives().add(rootLibBda.getModuleBda());
}
libJarRootBdas.add(rootLibBda);
}
}
use of org.jboss.weld.bootstrap.spi.BeanDeploymentArchive in project Payara by payara.
the class DeploymentImpl method getExtensions.
@Override
public Iterable<Metadata<Extension>> getExtensions() {
if (extensions != null) {
return extensions;
}
List<BeanDeploymentArchive> bdas = getBeanDeploymentArchives();
ArrayList<Metadata<Extension>> extnList = new ArrayList<>();
for (BeanDeploymentArchive bda : bdas) {
if (!(bda instanceof RootBeanDeploymentArchive)) {
ClassLoader moduleClassLoader = ((BeanDeploymentArchiveImpl) bda).getModuleClassLoaderForBDA();
extensions = context.getTransientAppMetaData(WeldDeployer.WELD_BOOTSTRAP, WeldBootstrap.class).loadExtensions(moduleClassLoader);
if (extensions != null) {
for (Metadata<Extension> bdaExtn : extensions) {
extnList.add(bdaExtn);
}
}
}
}
extnList.addAll(dynamicExtensions);
return extnList;
}
use of org.jboss.weld.bootstrap.spi.BeanDeploymentArchive in project Payara by payara.
the class DeploymentImpl method getBeanDeploymentArchive.
/**
* Get a bda for the specified beanClass
*
* @param beanClass The beanClass to get the bda for.
*
* @return If the beanClass is in the archive represented by the bda
* then return that bda. Otherwise if the class loader of the beanClass matches the module class loader
* of any of the root bdas then return that root bda. Otherwise return null.
*/
public BeanDeploymentArchive getBeanDeploymentArchive(Class<?> beanClass) {
if (beanClass == null) {
return null;
}
for (BeanDeploymentArchive oneBda : beanDeploymentArchives) {
BeanDeploymentArchiveImpl beanDeploymentArchiveImpl = (BeanDeploymentArchiveImpl) oneBda;
if (beanDeploymentArchiveImpl.getBeanClassObjects().contains(beanClass)) {
return oneBda;
}
}
// find a root bda
ClassLoader classLoader = beanClass.getClassLoader();
RootBeanDeploymentArchive rootBda = findRootBda(classLoader, ejbRootBdas);
if (rootBda == null) {
rootBda = findRootBda(classLoader, warRootBdas);
if (rootBda == null) {
rootBda = findRootBda(classLoader, libJarRootBdas);
if (rootBda == null) {
rootBda = findRootBda(classLoader, rarRootBdas);
}
}
}
return rootBda;
}
use of org.jboss.weld.bootstrap.spi.BeanDeploymentArchive 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));
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);
idToBeanDeploymentArchive.put(newBda.getId(), newBda);
extensionBDAMap.put(beanClass.getClassLoader(), newBda);
return newBda;
}
return null;
}
Aggregations