[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:38:00 EDT 2016
[ https://issues.jboss.org/browse/CDI-615?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Samba Siva Rao Kolusu updated CDI-615:
--------------------------------------
Description:
# 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:
{code:java}
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());
}
}
{code}
something like the following will be of great use:
{code:java}
@Inject BeanManager bm;
AnnotatedType<?> annotatedType = bm.createAnnotatedType(klass);
bm.addAnnotatedType(annotatedType,klass.getName());
{code}
this simple API will help discover beans after deployment or from non-jee classpaths.
was:
# 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:
{code:java}
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());*_
}
}
{code}
something like the following will be of great use:
{code:java}
@Inject BeanManager bm;
AnnotatedType<?> annotatedType = bm.createAnnotatedType(klass);
_*bm.addAnnotatedType(annotatedType,klass.getName());*_
{code}
this simple API will help discover beans after deployment or from non-jee classpaths.
> 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:
> {code:java}
> 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());
> }
> }
> {code}
> something like the following will be of great use:
> {code:java}
> @Inject BeanManager bm;
> AnnotatedType<?> annotatedType = bm.createAnnotatedType(klass);
> bm.addAnnotatedType(annotatedType,klass.getName());
> {code}
> this simple API will help discover beans after deployment or from non-jee classpaths.
--
This message was sent by Atlassian JIRA
(v6.4.11#64026)
More information about the cdi-dev
mailing list