public static void fire(
     BeanManagerImpl beanManager,
     Deployment deployment,
     BeanDeploymentArchiveMapping bdaMapping,
     Collection<ContextHolder<? extends Context>> contexts) {
   final AfterBeanDiscoveryImpl event =
       new AfterBeanDiscoveryImpl(beanManager, deployment, bdaMapping, contexts);
   event.fire();
   event.finish();
 }
Ejemplo n.º 2
0
  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);
  }