Package org.jboss.weld.bootstrap.spi

Examples of org.jboss.weld.bootstrap.spi.BeanDeploymentArchive


        }
        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});
View Full Code Here


    public String toString() {
        StringBuffer valBuff = new StringBuffer();
        List<BeanDeploymentArchive> beanDeploymentArchives = getBeanDeploymentArchives();
        ListIterator<BeanDeploymentArchive> lIter = beanDeploymentArchives.listIterator();
        while (lIter.hasNext()) {
            BeanDeploymentArchive bda = lIter.next();
            valBuff.append(bda.toString());
        }
        return valBuff.toString();
    }
View Full Code Here

        if (libJars != null) {
            String libDir = holder.app.getLibraryDirectory();
            ListIterator<ReadableArchive> libJarIterator = libJars.listIterator();
            while (libJarIterator.hasNext()) {
                ReadableArchive libJarArchive = (ReadableArchive)libJarIterator.next();
                BeanDeploymentArchive bda = new BeanDeploymentArchiveImpl(
                    libJarArchive, ejbs, context,
                    /* use lib/jarname as BDA ID */ libDir + SEPARATOR_CHAR
                    + libJarArchive.getName());
                this.beanDeploymentArchives.add(bda);
                if (libJarBDAs  == null) {
                    libJarBDAs = new ArrayList<BeanDeploymentArchive>();
                }
                libJarBDAs.add(bda);
                this.idToBeanDeploymentArchive.put(bda.getId(), bda);
            }
            //Ensure each library jar in EAR/lib is visible to each other.
            ensureEarLibJarVisibility(libJarBDAs);
        }

View Full Code Here

    }

    private void ensureEarLibJarVisibility(List<BeanDeploymentArchive> earLibBDAs) {
        //ensure all ear/lib JAR BDAs are visible to each other
        for (int i = 0; i < earLibBDAs.size(); i++) {
            BeanDeploymentArchive firstBDA = earLibBDAs.get(i);
            boolean modified = false;
            //loop through the list once more
            for (int j = 0; j < earLibBDAs.size(); j++) {
                BeanDeploymentArchive otherBDA = earLibBDAs.get(j);
                if (!firstBDA.getId().equals(otherBDA.getId())){
                    if ( logger.isLoggable( FINE ) ) {
                        logger.log(FINE, "DeploymentImpl::ensureEarLibJarVisibility - " + firstBDA.getId() + " being associated with " + otherBDA.getId());
                    }
                    firstBDA.getBeanDeploymentArchives().add(otherBDA);
                    modified = true;
                }
            }
View Full Code Here

        if( ejbBundle != null && (!deploymentImpl.getServices().contains(EjbServices.class))) {
            // EJB Services is registered as a top-level service
            deploymentImpl.getServices().add(EjbServices.class, ejbServices);
        }

        BeanDeploymentArchive bda = deploymentImpl.getBeanDeploymentArchiveForArchive(archive.getName());

        WebBundleDescriptor wDesc = context.getModuleMetaData(WebBundleDescriptor.class);
        if( wDesc != null) {
            wDesc.setExtensionProperty(WELD_EXTENSION, "true");
            // Add the Weld Listener if it does not already exist..
            wDesc.addAppListenerDescriptorToFirst(new AppListenerDescriptorImpl(WELD_LISTENER));
            // Add Weld Context Listener - this listener will ensure the WeldELContextListener is used
            // for JSP's..
            wDesc.addAppListenerDescriptor(new AppListenerDescriptorImpl(WELD_CONTEXT_LISTENER));
            // Adding Weld ConverstationFilter if there is filterMapping for it and it doesn't exist already.
            // However, it will be applied only if web.xml has mapping for it.
            // Doing this here to make sure that its done only for CDI enabled web application
            for (ServletFilterMapping sfMapping : wDesc.getServletFilterMappings()) {
                  String displayName = ((ServletFilterMappingDescriptor)sfMapping).getDisplayName();
                  if (WELD_CONVERSATION_FILTER_NAME.equals(displayName)) {
                        ServletFilterDescriptor ref = new ServletFilterDescriptor();
                        ref.setClassName(WELD_CONVERSATION_FILTER_CLASS);
                        ref.setName(WELD_CONVERSATION_FILTER_NAME);
                        wDesc.addServletFilter(ref);  
                        break;
                  }
            }
        }

        BundleDescriptor bundle = (wDesc != null) ? wDesc : ejbBundle;
        if( bundle != null ) {

            // Register EE injection manager at the bean deployment archive level.
            // We use the generic InjectionService service to handle all EE-style
            // injection instead of the per-dependency-type InjectionPoint approach.
            // Each InjectionServicesImpl instance knows its associated GlassFish bundle.

            InjectionManager injectionMgr = services.getService(InjectionManager.class);
            InjectionServices injectionServices = new InjectionServicesImpl(injectionMgr, bundle, deploymentImpl);

            if (logger.isLoggable(Level.FINE)) {
                logger.log(Level.FINE,
                           CDILoggerInfo.ADDING_INJECTION_SERVICES,
                           new Object [] {injectionServices, bda.getId()});
            }
            bda.getServices().add(InjectionServices.class, injectionServices);
           
            if (bda.getBeanDeploymentArchives().size() != 0) {
                //Relevant in WAR BDA - WEB-INF/lib BDA scenarios
                for(BeanDeploymentArchive subBda: bda.getBeanDeploymentArchives()){
                    if (logger.isLoggable(Level.FINE)) {
                        logger.log(Level.FINE,
                                   CDILoggerInfo.ADDING_INJECTION_SERVICES,
                                   new Object [] {injectionServices, subBda.getId()});
                    }
View Full Code Here

        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();
    }
View Full Code Here

        libJarBDAs = scanForLibJars(archive, ejbs, context);
        if ((libJarBDAs != null) && libJarBDAs.size() > 0) {
            return;
        }

        BeanDeploymentArchive bda = new BeanDeploymentArchiveImpl(archive, ejbs, context);
        addBeanDeploymentArchives(bda);
    }
View Full Code Here

            if ((libJarBDAs != null) && libJarBDAs.size() > 0) {
                return;
            }
        }

        BeanDeploymentArchive bda = new BeanDeploymentArchiveImpl(archive, ejbs, context);

        this.context = context;

        if (idToBeanDeploymentArchive == null) {
            idToBeanDeploymentArchive = new HashMap<String, BeanDeploymentArchive>();
View Full Code Here

        if (warBDAs != null) {
            ListIterator<BeanDeploymentArchive> warIter = warBDAs.listIterator();
            boolean modifiedArchive = false;
            while (warIter.hasNext()) {
                BeanDeploymentArchive warBDA = warIter.next();
                if (jarBDAs != null) {
                    for (BeanDeploymentArchive jarBDA : jarBDAs) {
                        warBDA.getBeanDeploymentArchives().add(jarBDA);
                        modifiedArchive = true;
                    }
                }

                // Make /lib jars (application) accessible

                if (libJarBDAs != null) {
                    for (BeanDeploymentArchive libJarBDA : libJarBDAs) {
                        warBDA.getBeanDeploymentArchives().add(libJarBDA);
                        modifiedArchive = true;
                    }
                }

                if (modifiedArchive) {
View Full Code Here

        }
        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);
View Full Code Here

TOP

Related Classes of org.jboss.weld.bootstrap.spi.BeanDeploymentArchive

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.