-
Feature Request
-
Resolution: Duplicate
-
Major
-
None
-
1.2.Final
-
None
-
3
- 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.
- duplicates
-
CDI-114 Allow registration of beans at runtime
-
- Closed
-