3 Replies Latest reply on May 27, 2009 11:13 AM by alrubinger

    Injecting into the Containers

    alrubinger

      Are we still without a mechanism to inject into the Containers?

      Containers are installed into MC by way of Ejb3Deployment.registerEJBContainer > MCKernelAbstraction:

      AbstractBeanMetaData bean = new AbstractBeanMetaData(name, service.getClass().getName());
       bean.setConstructor(new AlreadyInstantiated(service));
       MCDependencyPolicy policy = (MCDependencyPolicy) dependencies;
       bean.setDepends(policy.getDependencies());
       bean.setDemands(policy.getDemands());
       bean.setSupplies(policy.getSupplies());


      What's missing from this piece is a mechanism to do:

      final BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder(bean);
       builder.createInject(beanToInject, fieldNameToInjectTo);


      I don't really want to add this support to DependencyPolicy as that interface is the union of the MC and JMX Kernels.

      Presently we're manually setting all sorts of stuff into the Containers via Ejb3JBoss5Deployment, like in the Ejb3Deployer:

      deployment.setCacheFactoryRegistry(this.getCacheFactoryRegistry());
       // TODO: if the deployment becomes a proper MC bean, it'll get injected by MC.
       deployment.setMessageDestinationReferenceResolver(messageDestinationReferenceResolver);
       deployment.setPersistenceManagerFactoryRegistry(this.getPersistenceManagerFactoryRegistry());
       // TODO: if the deployment becomes a proper MC bean, it'll get injected by MC.
       deployment.setPersistenceUnitDependencyResolver(persistenceUnitDependencyResolver);
       deployment.setPoolFactoryRegistry(this.getPoolFactoryRegistry());


      I want to add a new field to the containers to support EJB3 Metrics as a POJO. I guess for the time being I have to do this manually at the deployer level, ie:

      * New Deployer to Create a Metrics POJO, then attach it to the DeploymentUnit
      * Ejb3Deployer picks up the attachment and sets it upon the Ejb3JBoss5Deployment.
      * Containers get at the Metrics POJO via getDeployment().

      Lots of wiring.

      S,
      ALR

        • 1. Re: Injecting into the Containers
          alrubinger

           

          "ALRubinger" wrote:
          * New Deployer to Create a Metrics POJO, then attach it to the DeploymentUnit
          * Ejb3Deployer picks up the attachment and sets it upon the Ejb3JBoss5Deployment.
          * Containers get at the Metrics POJO via getDeployment().


          Alternatively I can:

          * Have Ejb3MetricsDeployer come along *after* Ejb3Deployer
          * Pick out all Containers created from the Deployment
          * Inject Metrics POJOs into each of them

          ...thus adding metrics becomes a concern atop EJB3. ejb3-core then relies only upon ejb3-metrics-spi, and ejb3-metrics-impl can be a JAR which includes the Ejb3MetricsDeployer definition in a jboss-beans.xml.

          But ejb3-core still needs to make the calls to the underlying metrics collectors, so we still mix concerns unless we start intercepting things like createSession and destroySession via AOP.

          S,
          ALR

          • 2. Re: Injecting into the Containers
            wolfc

            You're collecting session metrics from the wrong spot. You should be collecting those metrics from pool and cache. Only call metrics should come from container.

            The pool and cache should actually be deployed by a separate deployer before the container gets deployed. So that these are MC beans which are injected into the container.

            Injection on the containers does work, however:
            A lot of stuff gets set on the container, because we use it for dependency resolving, which is done before the container is started. This needs the new deployers and a proper dependency resolving framework to work. https://jira.jboss.org/jira/browse/RELOADED-8

            • 3. Re: Injecting into the Containers
              alrubinger

               

              wolfc" wrote:
              You're collecting session metrics from the wrong spot. You should be collecting those metrics from pool and cache. Only call metrics should come from container.

              The pool and cache should actually be deployed by a separate deployer before the container gets deployed. So that these are MC beans which are injected into the container.


              OK. It's worth noting that this has become a high priority, so I'm hesitant to go down the road of separate cache/pool deployers for this first stab.

              wolfc" wrote:
              Injection on the containers does work


              ...how, where? Currently I don't see a mechanism to inject a known bean name. Injection via autowiring is simple as @Inject on a setter method.

              S,
              ALR