Skip to content

GRAILS-8279 - #118

Merged
graemerocher merged 1 commit into
apache:2.0.xfrom
twasink:GRAILS-8279
Nov 11, 2011
Merged

graemerocher merged 1 commit into
apache:2.0.xfrom
twasink:GRAILS-8279

Conversation

@twasink

@twasink twasink commented Nov 9, 2011

Copy link
Copy Markdown
Contributor

GRAILS-8279: Added 'addQualifier' methods to the DefaultBeanConfiguration to make qualifiers a 'first-level citizen' of the Spring DSL

See http://jira.grails.org/browse/GRAILS-8279

(No unit tests included as there do not appear to be any for the BeanConfiguration classes at this time)

…tion to make qualifiers a 'first-level citizen' of the Spring DSL
@graemerocher

Copy link
Copy Markdown
Contributor

Did you reformat the code? It is hard to see what changed because the diff shows that the some of the classes contents have been completely replaced.

@twasink

twasink commented Nov 9, 2011

Copy link
Copy Markdown
Contributor Author

Doh! Should have noticed that. Looks like the end-of-line characters all got swapped out.

git diff -w shows the changes without the whitespace differences:


$ git diff -w 11882d3632c06dc33f50ab7d8c205a6905caacc2 dc335df961dc9d81cd785c6773287803b9fa7253
diff --git a/grails-spring/src/main/groovy/org/codehaus/groovy/grails/commons/spring/BeanConfiguration.java b/grails-spring/src/main/groovy/org/codehaus/groovy/grails/commons/sprin
index f3544db..05bf0d7 100644
--- a/grails-spring/src/main/groovy/org/codehaus/groovy/grails/commons/spring/BeanConfiguration.java
+++ b/grails-spring/src/main/groovy/org/codehaus/groovy/grails/commons/spring/BeanConfiguration.java
@@ -138,4 +138,11 @@ public interface BeanConfiguration {
     void setParent(Object name);

     void setBeanDefinition(BeanDefinition definition);
+    
+    /** Add a qualifier to the bean definition. */
+    public void addQualifier(String name);
+
+    /** A qualifier, using a custom annotation, to the bean definition. */
+    public void addQualifier(Class qualifierClass, String name);
+    
 }
diff --git a/grails-spring/src/main/groovy/org/codehaus/groovy/grails/commons/spring/DefaultBeanConfiguration.java b/grails-spring/src/main/groovy/org/codehaus/groovy/grails/common
index 6ecf4ff..03d7885 100644
--- a/grails-spring/src/main/groovy/org/codehaus/groovy/grails/commons/spring/DefaultBeanConfiguration.java
+++ b/grails-spring/src/main/groovy/org/codehaus/groovy/grails/commons/spring/DefaultBeanConfiguration.java
@@ -25,11 +25,13 @@ import java.util.List;
 import org.springframework.beans.BeanWrapper;
 import org.springframework.beans.BeanWrapperImpl;
 import org.springframework.beans.PropertyValue;
+import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
 import org.springframework.beans.factory.config.BeanDefinition;
 import org.springframework.beans.factory.config.ConstructorArgumentValues;
 import org.springframework.beans.factory.config.RuntimeBeanReference;
 import org.springframework.beans.factory.support.AbstractBeanDefinition;
+import org.springframework.beans.factory.support.AutowireCandidateQualifier;
 import org.springframework.beans.factory.support.GenericBeanDefinition;
 import org.springframework.util.Assert;

@@ -305,4 +307,12 @@ public class DefaultBeanConfiguration extends GroovyObjectSupport implements Bea
         getBeanDefinition().setParentName(parentName);
         setAbstract(false);
     }
+    
+    public void addQualifier(String name) { 
+        addQualifier(Qualifier.class, name);
+    }
+
+    public void addQualifier(Class qualifierClass, String name) {
+        getBeanDefinition().addQualifier(new AutowireCandidateQualifier(qualifierClass, name));
+    }
 }

@twasink

twasink commented Nov 9, 2011

Copy link
Copy Markdown
Contributor Author

I should also point out that qualifiers can still be used without this patch, because Spring falls back to using the name of the bean as a qualifier. This means custom qualifiers are probably a bit more of an "advanced" or specialised technique.

graemerocher added a commit that referenced this pull request Nov 11, 2011
@graemerocher
graemerocher merged commit 1d9525f into apache:2.0.x Nov 11, 2011
rainboyan referenced this pull request in rainboyan/Apache-Grails Nov 4, 2022
…7.2 (#118)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
jdaugherty pushed a commit to jdaugherty/grails-core that referenced this pull request Jan 15, 2025
…gradle-plugin-5.x

Update dependency org.grails:grails-gradle-plugin to v5.0.0.RC1
jdaugherty pushed a commit to jdaugherty/grails-core that referenced this pull request Feb 9, 2025
jdaugherty pushed a commit that referenced this pull request Apr 17, 2025
jdaugherty pushed a commit to jdaugherty/grails-core that referenced this pull request Apr 19, 2025
apache#118)

* fix: disable recording container

Closes apachegh-117

* refactor: set recording mode directly on created container
codeconsole pushed a commit to codeconsole/grails-core that referenced this pull request Jul 10, 2025
* Update micronautVersion to v3.9.1

* Remove schema-generate configuration of liquibase

See micronaut-projects/micronaut-starter#1524

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Puneet Behl <[email protected]>
jdaugherty pushed a commit to jdaugherty/grails-core that referenced this pull request Jun 29, 2026
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants