Grails
  1. Grails
  2. GRAILS-8279

Add support for qualifiers into the Spring DSL

    Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.3.7
    • Fix Version/s: None
    • Component/s: Configuration

      Description

      Qualifiers are a powerful concept in Spring, but not supported by the DSL despite being a first-class citizen in the XML configuration. Thus, an XML snippet like this:

      <bean class="org.example.MyBean">
      <qualifier value="a_bean">
      </bean>

      becomes messy DSL code like this (imports assumed for readability):
      myBean(MyBean)

      { bean -> bean.beanDefinition.addQualifier(new AutowireCandidateQualifier(Qualifier, 'a_bean ')) }

      I suggest adding a method to org.codehaus.groovy.grails.commons.spring.DefaultBeanConfiguration to streamline this process. Something like this:

      public void addQualifier(String name)

      { addQualifier(Qualifier.class, name) }

      public void addQualifier(Class qualifierClass, name)

      { getBeanDefinition.addQualifier(new AutowireCandidateQualifier(qualifierClass, name)) }

      Which would then allow the DSL code to be:

      myBean(MyBean)

      { bean -> bean.addQualifier('a_bean ') }

      or (for typed-base qualifiers):

      myBean(MyBean)

      { bean -> bean.addQualifier(MyQualifierMarker, 'a_bean') }

        Activity

        Hide
        Robert Watkins added a comment -
        Show
        Robert Watkins added a comment - Pull Request for patch: https://github.com/grails/grails-core/pull/118

          People

          • Assignee:
            Unassigned
            Reporter:
            Robert Watkins
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Last Reviewed:

              Development