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

    Binding the CDI BeanManager into JNDI

    pmuir

      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?

        • 1. Re: Binding the CDI BeanManager into JNDI
          wolfc

          Right now almost all references bound under java:comp are LinkRefs to global JNDI entries. A container will get the JNDI name via a resolver. (The container deployer will get the MC bean dependency via the same resolver to ensure the container depends upon it.) The container will setup the LinkRef, because it is the only one allowed to write there.

          Alternatively we could go for an ObjectFactory that hooks onto DeploymentServices, but I don't see how get the container from an ObjectFactory (the usual can't get a MC bean from there).

          • 2. Re: Binding the CDI BeanManager into JNDI
            pmuir

            Ok, so concretely, how do we go about the CDI manager there?