3 Replies Latest reply on Mar 21, 2017 4:47 AM by Matej Novotny

    AnnotatedTypeConfigurator: easy recipe for configuring superclass fields?

    Laird Nelson Apprentice

      I am doing horrible and unsightly things with a CDI extension and the Maven dependency resolution project known as maven-resolver.


      The Maven part is uninteresting except that it makes use of an old dependency injection model known as Plexus.


      In Plexus, what CDI would call a bean is annotated with @Component, and what CDI would call an injection point is annotated with @Requirement.


      In the Maven codebase, there is a pattern where a @Component-annotated class will have a superclass whose private fields are annotated with @Requirement.  In the abstract, I'd like to configure these fields to have @Inject on them so that CDI will perform the dependency injection that Plexus used to.


      Using an AnnotatedTypeConfigurator, I can of course get the fields of the @Component-annotated type (via fields() or filterFields()).  But I don't see any clean way to get access to the superclass' fields.


      I am aware that I can take the "hard way" and bypass the configurator and use ProcessAnnotatedType#setAnnotatedType(AnnotatedType) instead, but I was hoping for an easier recipe. :-)  So: is there a way I'm overlooking to get access to the superclass' fields?  Should AnnotatedTypeConfigurator provide access to another AnnotatedTypeConfigurator representing its superclass?