Uploaded image for project: 'Weld'
  1. Weld
  2. WELD-1372

bean manager should be available in @Observes AfterDeploymentValidation

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 2.0.0.Beta7
    • 2.0.0.Beta6
    • None
    • None

      consider the following startup extension that replicate the ejb @Singleton @Startup behavior :

      public class StartupExtension implements Extension
      {
      private final Set<Bean<?>> startupBeans = new LinkedHashSet<Bean<?>>();

      <X> void processBean(@Observes ProcessBean<X> event)
      {
      if (event.getAnnotated().isAnnotationPresent(Startup.class) &&
      event.getAnnotated().isAnnotationPresent(ApplicationScoped.class))

      { startupBeans.add(event.getBean()); }

      }

      void afterDeploymentValidation(@Observes AfterDeploymentValidation event, BeanManager manager)
      {
      for (Bean<?> bean : startupBeans)

      { // the call to toString() is a cheat to force the bean to be initialized manager.getReference(bean, bean.getBeanClass(), manager.createCreationalContext(bean)).toString(); }

      }

      }

      in weld 2.0.0.Beta6 it will lead in an new IllegalStateException(METHOD_NOT_AVAILABLE_DURING_INITIALIZATION, methodName) exception (BeanManagerProxy::checkContainerInitialized)

      though as https://issues.jboss.org/browse/CDI-315 suggests, it should not.

              rhn-engineering-jharting Jozef Hartinger
              mathieu@mathieulachance.com Mathieu Lachance (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: