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

Decorators are Groovy-unfriendly

    XMLWordPrintable

Details

    Description

      If you have a decorator as Groovy class like this:

      @Decorator
      class TestDecorator implements DecoratedBeanInterface {
          @Inject
          @Delegate
          DecoratedBeanInterface delegate
      
          @Override
          String ping() {
              TestDecorator.toString() + delegate.ping()
          }
      }
      

      you get a complaint as this:

      org.jboss.weld.exceptions.DefinitionException: WELD-000061: The delegate type does not extend or implement the decorated type. 
        Decorated type: interface groovy.lang.GroovyObject
        Decorator: Decorator [class org.jboss.weld.spock.auto.interceptorAndDecorator.TestDecorator] decorates [DecoratedBeanInterface, GroovyObject] with delegate type [DecoratedBeanInterface] and delegate qualifiers [@Default]
      

      As a work-around you have to add @Typed(DecoratedBeanInterface) to the decorator class, but I think for better Groovy usability, GroovyObject should be ignored here by Weld.

      Attachments

        Activity

          People

            manovotn Matěj Novotný
            Vampire0 Björn Kautler (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: