[jboss-dev-forums] [JBoss Microcontainer Development] - Re: Web beans on top of Microcontainer deployment order

kabir.khan@jboss.com do-not-reply at jboss.com
Fri Aug 28 05:33:22 EDT 2009


Reply from Pete Muir:
"kabir.khan at jboss.com" wrote : 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.
  | 
This is fine, you can access the BeanManager after Bootstrap.startContainer() is called, or after Bootstrap.startInitialization(). Beans aren't deployed until Bootstrap.deployBeans().

Though assuming you are in a container lifecycle event doing @Current BeanManager beanManager; will give you the correct manager (afaik this works).
"kabir.khan at jboss.com" wrote : 
  | 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?
  | 

You need to determine which BeanDeploymentArchive the bean you want to access belongs to. Until Ales and I write the non-flat deployment strucutre for JBoss AS, this is a moot point really, as there is only one. Then you call

BeanManager manager = bootstrap.getManager(beanDeploymentArchive);

Note that normally MC beans can't access stuff inside deployments tho.

I would assume we will end up with a structure like this in JBoss AS:

EAR Deployment
  EJB JAR BDA
     -> Server lib/ virtual BDA
  WAR BDA
     -> Server lib/ virtual BDA
     -> EJB JAR BDA

(where -> denotes accessibility).

So you would *always* put the MC beans in the Server lib/ virtual BDA.


View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4252253#4252253

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4252253




More information about the jboss-dev-forums mailing list