Uploaded image for project: 'Weld'
  1. Weld
  2. WELD-2807

Cannot add beans through extensions with interception enabled

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not a Bug
    • Icon: Major Major
    • None
    • 5.1.5.Final
    • Extensions
    • None
    • Hide

      I have created a reproducer that contains three modules:

      • `app` - application using the `extension` module
      • `extension` - extension in a separate module
      • `single-module` - single module containing an application and an extension

      These modules use `SEContainerInitializer` to start the container.

      When the `Main` class from `single-module` is started, you can see all invocations are intercepted - both from the `CdiBean` (with bean defining annotation) and from the `MyService` (added through extension).

       

      When the `Main` class from `app` module is started, only interception on `CdiBean` works, the `MyService` methods are invoked, but not intercepted.

      Show
      I have created a reproducer that contains three modules: `app` - application using the `extension` module `extension` - extension in a separate module `single-module` - single module containing an application and an extension These modules use `SEContainerInitializer` to start the container. When the `Main` class from `single-module` is started, you can see all invocations are intercepted - both from the `CdiBean` (with bean defining annotation) and from the `MyService` (added through extension).   When the `Main` class from `app` module is started, only interception on `CdiBean` works, the `MyService` methods are invoked, but not intercepted.

      I need to add beans in "After Bean Discovery" that are created outside of CDI (and they do not have bean defining annotations).

      These beans may have methods or classes annotated with a annotation that is an `InterceptorBinding` and that has a proper interceptor available in CDI.

      According to my understanding of the documentation, this should be achievable by using `BeanManager.createInterceptionFactory` and this indeed works, as long as the extension is created in the same module that hosts the types being added.

      When I move the Extension to its own modules (without changing a single line of code), it stops working and interception does not happen on my types.

              Unassigned Unassigned
              tomas.langer@gmail.com Tomas Langer (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: