The usage of Nonbinding on Qualifiers
meetoblivion Jan 9, 2010 6:57 PMI'm trying to understand a bit better the usage of Nonbinding. From what I can tell, we're supposed to use it when we don't want to take the value of an annotation into consideration when resolving a producer/bean instance.
The reason I'm asking is that I have the following qualifier:
@Qualifier @Target({TYPE, METHOD, PARAMETER, FIELD}) @Retention(RUNTIME) public @interface LoadedProperties { @Nonbinding public boolean classpathAware() default false; @Nonbinding public boolean xml() default false; @Nonbinding public String filename(); }
Now, this works fine, as long as the usage of the qualifier is classpathAware=false (so default), however, when I set it to try I get ambiguous resolution errors. The complication is that I've created producer methods for Map<String,String> and java.util.Properties for this object, and if it means I have to create a new producer for each value in the annotation, it'll get very redundant. This is the stack trace, but it's the generic ambiguous resolution exception.
Caused by: javax.enterprise.inject.AmbiguousResolutionException: Cannot resolve an ambiguous dependency between [org.jboss.weld.bean-//PropTestWeb/-ProducerMethod-com.tad.weld.comps.propertyconfigurator.producers.PropertyProducer.produceProperties(javax.enterprise.inject.spi.InjectionPoint), org.jboss.weld.bean-//PropTestWeb/-ProducerMethod-com.tad.weld.comps.propertyconfigurator.producers.UtilPropertiesProducer.produceUtilProperties(javax.enterprise.inject.spi.InjectionPoint) at org.jboss.weld.BeanManagerImpl.resolve(BeanManagerImpl.java:1491) at org.jboss.weld.BeanManagerImpl.getBean(BeanManagerImpl.java:1071) at org.jboss.weld.BeanManagerImpl.getInjectableReference(BeanManagerImpl.java:1040) at org.jboss.weld.injection.FieldInjectionPoint.inject(FieldInjectionPoint.java:92) at org.jboss.weld.util.Beans.injectBoundFields(Beans.java:727) at org.jboss.weld.util.Beans.injectFieldsAndInitializers(Beans.java:739) at org.jboss.weld.SimpleInjectionTarget$1.proceed(SimpleInjectionTarget.java:115) at org.glassfish.weld.services.InjectionServicesImpl.aroundInject(InjectionServicesImpl.java:130) at org.jboss.weld.injection.InjectionContextImpl.run(InjectionContextImpl.java:47) at org.jboss.weld.SimpleInjectionTarget.inject(SimpleInjectionTarget.java:109) at org.glassfish.weld.services.JCDIServiceImpl.createManagedObject(JCDIServiceImpl.java:180) at org.glassfish.weld.services.JCDIServiceImpl.createManagedObject(JCDIServiceImpl.java:154) at com.sun.enterprise.container.common.impl.managedbean.ManagedBeanManagerImpl.createManagedBean(ManagedBeanManagerImpl.java:456) at com.sun.enterprise.container.common.impl.managedbean.ManagedBeanManagerImpl.createManagedBean(ManagedBeanManagerImpl.java:423) at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.createManagedObject(InjectionManagerImpl.java:295)