OpenWebBeans
  1. OpenWebBeans
  2. OWB-622

beanmanager injection in afterBeanDiscovery method parameter

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Not a Problem
    • Affects Version/s: 1.1.1
    • Fix Version/s: 1.1.2
    • Component/s: None
    • Labels:
      None

      Description

      The problem is reading the spec we don't know if BeanManager can be injected through method parameter in producer/observer so it should probably be done.

      here an extract of an IRC conversation with more details:

      <rmannibucau> hi, is it possible to inject the bean manager in a method (like beforebeandiscovery) ?
      <bergmark> Specifically a lifecycle method, or a method in a CDI manager bean?
      <bergmark> I ask because you can certainly inject method params into methods in a managed bean. I don't think you can add a bean manager param to your afterBeanDiscovery event listener, but I might be wrong.
      <bergmark> Spec seems to prove me wrong though
      <bergmark> 11.5 says that service providers can obtain an injected BeanManager
      <bergmark> Presumably as a field though, not as a parameter into the observer method.
      <rmannibucau> ah
      <rmannibucau> i ask because seams does it
      <rmannibucau> so it doesnt work with oprnwebbeans just because of it
      <bergmark> seam injects the BeanManager as a parameter of the method with @Observes?
      <rmannibucau> yep
      <rmannibucau> in solder-impl-3.1.0.Beta3
      <bergmark> Might be a bug then, its not clear to me what 11.5 means when it says "and obtain an injected BeanManager reference". That isn't very clear about how.
      <bergmark> I just assumed it meant via an injected field in the service provider, but perhaps they intended that statment to apply to observer method injection as well inside service providers.

        Issue Links

          Activity

          Hide
          Mark Struberg added a comment -

          injecting a BeanManager as additional parameter in any lifecycle event (or any other event) is perfectly fine and we use this already in lots of extensions [1]. Maybe there is a certain specific problem which is different than what it seems at the first glance?

          [1] https://svn.apache.org/repos/asf/myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/scope/conversation/GroupedConversationContextExtension.java

          Show
          Mark Struberg added a comment - injecting a BeanManager as additional parameter in any lifecycle event (or any other event) is perfectly fine and we use this already in lots of extensions [1] . Maybe there is a certain specific problem which is different than what it seems at the first glance? [1] https://svn.apache.org/repos/asf/myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/scope/conversation/GroupedConversationContextExtension.java
          Hide
          Mark Struberg added a comment -

          Romain, I now added a unit test (see ExternalTestScopeExtension) which demonstrates that OWB works as expected.
          Of course I'm sure there is an error somewhere, but we need to take a deeper look to find the root cause...

          Show
          Mark Struberg added a comment - Romain, I now added a unit test (see ExternalTestScopeExtension) which demonstrates that OWB works as expected. Of course I'm sure there is an error somewhere, but we need to take a deeper look to find the root cause...
          Hide
          Mark Struberg added a comment -

          Tested the example and it crashes with a few other issues first. So I cannot test this because the used interceptors do not have the correct signature, thus OWB detects this problem and treats it as deployment exception

          Show
          Mark Struberg added a comment - Tested the example and it crashes with a few other issues first. So I cannot test this because the used interceptors do not have the correct signature, thus OWB detects this problem and treats it as deployment exception
          Hide
          Mark Struberg added a comment -

          shipped in OpenWebBeans-1.1.2

          Show
          Mark Struberg added a comment - shipped in OpenWebBeans-1.1.2

            People

            • Assignee:
              Mark Struberg
              Reporter:
              Romain Manni-Bucau
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development