I have committed the initial prototype for the web beans integration. It can be found here
https://svn.jboss.org/repos/jbossas/projects/kernel/trunk/webbeans-int.
MC beans that should interact with web beans are wrapped in a
WebBeansKernelControllerContext as mentioned before. It contains additional controller
context actions to instantiate/inject an MC bean with web beans. It also contains an
additional controller context action to store mc beans that should be available for
injection to web beans in a registry. It contains a web beans AfterBeanDiscovery
implementation that is used to add the mc beans to the web beans bean manager. The mc
beans added to web beans are done in a custom web beans Bean implementation that takes the
existing instance from mc, ignoring the calls to create it. When running in AS there will
be a loads and loads of MC beans, which might unintentionally conflict, so we need to find
a good way to narrow down which MC beans are available for injection into web beans.
Currently, I am only registering MC beans that have web beans annotations on them
(ignoring producer methods), but am open for suggestions on how to improve this.
I am unsure how this fits together in the real world though. The
WebBeansKernelControllerContext needs access to a bean manager to be able to call
createCreationalContext(), createInjectionTarget() and createAnnotatedType().
For cases when we want to inject MC->WB, the MC beans need to be deployed and
'registered' before the web beans are deployed, and the actual bean manager to be
used is created during the deployment process. I have hacked around this for now, by
creating a 'bootstrap' bean manager in my tests that is available before web beans
are deployed. Luckily, none of the BeanManager methods needed for this process
(createAnnotatedType()) do anything with the internal state of the bean manager, so they
work.
For WB->MC injection, we need access to the correct bean manager that should be used to
inject the MC beans, so createCreationalContext() and createInjectionTarget() can be
called. I think for this to work we need access to the 'real' BeanManager. So, how
do we determine which BeanManager should be used?
The registry mentioned currently stores the context names and web beans Bean
implementations, but we probably need to take scoped controllers into account there. So
how do we determine which controller should be used for a particular bean manager?
For MC->WB injection, the MC beans need to be deployed first so that they are
registered with the bean manager. For WB->MC injection, the WB beans need to be
deployed first since the MC WebBeansKernelControllerContext gets initialised with the bean
manager on creation. I think the MC beans needing to be deployed first is pretty definite,
but it would be good if the bean manager to be used for WB->MC could be determined
somehow at a later stage.
I am currently ignoring the fact that there are other Bean implementations than
SimpleBean, and also not handling WebBeansKernelControllerContexts for bean factories
View the original post :
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4252251#...
Reply to the post :
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&a...