[cdi-dev] [JBoss JIRA] (CDI-615) provide API to register new beans to the context after deployment (at runtime)

Samba Siva Rao Kolusu (JIRA) issues at jboss.org
Tue Jun 7 08:35:00 EDT 2016

Samba Siva Rao Kolusu created CDI-615:

             Summary: provide API to register new beans to the context after deployment (at runtime)
                 Key: CDI-615
                 URL: https://issues.jboss.org/browse/CDI-615
             Project: CDI Specification Issues
          Issue Type: Feature Request
          Components: Beans
    Affects Versions: 1.2.Final
         Environment: N/A
            Reporter: Samba Siva Rao Kolusu

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) { 
        Set<Class<?>> klasses=get classes from from some non-jee-classpath
        AnnotatedType<?> annotatedType;
        for(Class<?> klass : klasses ) {
            annotatedType = bm.createAnnotatedType(klass);

 something like the following will be of great use:


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


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

This message was sent by Atlassian JIRA

More information about the cdi-dev mailing list