Uploaded image for project: 'CDI Specification Issues'
  1. CDI Specification Issues
  2. CDI-615

provide API to register new beans to the context after deployment (at runtime)

    XMLWordPrintable

Details

    • Feature Request
    • Resolution: Duplicate
    • Major
    • None
    • 1.2.Final
    • Beans
    • None
    • 3

    Description

      1. CDI provides API to listen/observe for various stages of bean discovery and deployment, during which we can add additional types to be registered as managed CDI beans/interceptors/etc. however, there is no way to do the same (i.e.) register new types as CDI managed beans/interceptors/etc once the application is deployed (i.e. during runtime).

      it would be very useful if the spec is enhanced to also provide a runtime API to register new types as Beans or Interceptors.

      this is what we do currently:

      public void beforeBeanDiscovery(@Observes BeforeBeanDiscovery event, BeanManager beanManager) { 
              this.bm=beanManager;
              Set<Class<?>> klasses=get classes from from some non-jee-classpath
              AnnotatedType<?> annotatedType;
              for(Class<?> klass : klasses ) {
                  annotatedType = bm.createAnnotatedType(klass);
                  event.addAnnotatedType(annotatedType,klass.getName());
              }
          }
      

      something like the following will be of great use:

      @Inject BeanManager bm;
      AnnotatedType<?> annotatedType = bm.createAnnotatedType(klass);
       bm.addAnnotatedType(annotatedType,klass.getName());
      
      

      this simple API will help discover beans after deployment or from non-jee classpaths.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              saasira_jira Samba Kolusu (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: