public void deployBeans() { for (BeanDeployment deployment : getBeanDeployments()) { deployment.createBeans(environment); } // we must use separate loops, otherwise cyclic specialization would not work for (BeanDeployment deployment : getBeanDeployments()) { deployment.getBeanDeployer().processClassBeanAttributes(); deployment.getBeanDeployer().createProducersAndObservers(); } for (BeanDeployment deployment : getBeanDeployments()) { deployment.getBeanDeployer().processProducerAttributes(); deployment.getBeanDeployer().createNewBeans(); } for (BeanDeployment beanDeployment : getBeanDeployments()) { beanDeployment.deploySpecialized(environment); } // TODO keep a list of new bdas, add them all in, and deploy beans for them, then merge into // existing for (BeanDeployment beanDeployment : getBeanDeployments()) { beanDeployment.deployBeans(environment); } getContainer().setState(ContainerState.DISCOVERED); // Flush caches for BeanManager.getBeans() to be usable in ABD (WELD-1729) flushCaches(); AfterBeanDiscoveryImpl.fire(deploymentManager, deployment, bdaMapping, contexts); // Extensions may have registered beans / observers. We need to flush caches. flushCaches(); // If needed, recreate enablement once again - extensions may have registered interceptors, // decorators and alternatives if (deployment.getServices().getRequired(GlobalEnablementBuilder.class).isDirty()) { for (BeanDeployment beanDeployment : getBeanDeployments()) { beanDeployment.createEnablement(); } } // Re-read the deployment structure, bdaMapping will be the physical // structure, extensions, classes, and any beans added using addBean // outside the physical structure deploymentVisitor.visit(); for (BeanDeployment beanDeployment : getBeanDeployments()) { beanDeployment.getBeanManager().getServices().get(InjectionTargetService.class).initialize(); beanDeployment.afterBeanDiscovery(environment); } getContainer().putBeanDeployments(bdaMapping); getContainer().setState(ContainerState.DEPLOYED); }
public void startInitialization() { if (deploymentManager == null) { throw BootstrapLogger.LOG.managerNotInitialized(); } Set<BeanDeployment> physicalBeanDeploymentArchives = new HashSet<BeanDeployment>(getBeanDeployments()); ExtensionBeanDeployer extensionBeanDeployer = new ExtensionBeanDeployer(deploymentManager, deployment, bdaMapping, contexts); extensionBeanDeployer.addExtensions(extensions); extensionBeanDeployer.deployBeans(); installFastProcessAnnotatedTypeResolver(deploymentManager.getServices()); // Add the Deployment BeanManager Bean to the Deployment BeanManager deploymentManager.addBean(new BeanManagerBean(deploymentManager)); deploymentManager.addBean(new BeanManagerImplBean(deploymentManager)); // Re-Read the deployment structure, bdaMapping will be the physical // structure, and will add in BDAs for any extensions outside a // physical BDA deploymentVisitor.visit(); BeforeBeanDiscoveryImpl.fire(deploymentManager, deployment, bdaMapping, contexts); // for each physical BDA transform its classes into AnnotatedType instances for (BeanDeployment beanDeployment : physicalBeanDeploymentArchives) { beanDeployment.createClasses(); } // Re-Read the deployment structure, bdaMapping will be the physical // structure, extensions and any classes added using addAnnotatedType // outside the physical BDA deploymentVisitor.visit(); for (BeanDeployment beanDeployment : getBeanDeployments()) { beanDeployment.createTypes(); } AfterTypeDiscoveryImpl.fire(deploymentManager, deployment, bdaMapping, contexts); for (BeanDeployment beanDeployment : getBeanDeployments()) { beanDeployment.createEnablement(); } }