2 Replies Latest reply on Aug 27, 2009 6:41 PM by Pete Muir

    Binding the CDI BeanManager into JNDI

    Pete Muir Master

      The CDI spec requires us to make the BeanManager available in JNDI at java:comp/BeanManager.

      I understand java:comp/ has special meaning, so I'm wondering how best to bind the BeanManager there?

      Furthermore, the BeanManager instance to return depends on which module of the application the call is made from. Currently we provide an ObjectFactory in Web Beans, which can locate the application in use, but not the module in use. One way to locate the module, would be for the object factory to request the container, via an SPI, identify which module (or BeanDeploymentArchive in Web Beans parlance) is currently being accessed. For example

      interface JndiServices {
       BeanDeploymentArchive getBeanDeploymentArchive(HashTable environment);

      An alternative approach would be to pass the responsibility for attaching the correct BeanManager to JNDI depending on module. In that case, we would need to add an API like:

      interface DeploymentServices {
       BeanManager getBeanManager(BeanDeploymentArchive bda);

      which the container could query. We would require that, for each BeanDeploymentArchive, java:comp/BeanManager is made available, with the return value specified by DeploymentServices.

      I also believe an API like this would be useful in general.

      I favor the latter approach (I'll code this up tomorrow), but what do our JNDI experts think?