I've added some logging to UpperBoundTypedResource:
public UpperBoundTypedResource()
{
System.out.println("UpperBoundTypedResource<?>(): " + this);
}
public UpperBoundTypedResource(Class<?> clazz)
{
this.clazz = clazz;
System.out.println("UpperBoundTypedResource(" + clazz + "): " + this);
}
and I've done some more experiments in which I varied the placement of the @ResourceBinding qualifier:
* no qualifer on producer, decorator injection point:
Eclipse: complains that multiple beans are eligible for injection
Execution: There was no call to UpperBoundTypedResource(Class<?> clazz) to populate the producer field, an instance of UpperBoundTypedResource, created by the no-arg constructor, was injected into UpperBoundDecorator, and UpperBoundDecorator.execute() ran :
21:05:30,561 INFO [stdout] (http--127.0.0.1-8080-4) UpperBoundTypedResource<?>(): org.jboss.resteasy.cdi.generic.UpperBoundTypedResource$Proxy$_$$_WeldSubclass@5c0b8e42
21:05:30,562 INFO [stdout] (http--127.0.0.1-8080-4) UpperBoundTypedResource<?>(): org.jboss.resteasy.cdi.generic.UpperBoundTypedResource$Proxy$_$$_Weld$Proxy$@7aa8be43
21:05:30,562 INFO [stdout] (http--127.0.0.1-8080-4) UpperBoundDecorator got delegate: org.jboss.resteasy.cdi.generic.UpperBoundTypedResource$Proxy$_$$_WeldSubclass@5c0b8e42
21:05:30,564 INFO [org.jboss.resteasy.cdi.generic.UpperBoundDecorator] (http--127.0.0.1-8080-4) entering UpperBoundDecorator.execute()
* qualifier on producer, no qualifier on decorator injection point
Eclipse: no complaint
Execution: There was no call to UpperBoundTypedResource(Class<?> clazz) to populate the producer field, an instance of UpperBoundTypedResource, created by the no-arg constructor, was injected into UpperBoundDecorator, and UpperBoundDecorator.execute() ran:
21:08:24,352 INFO [stdout] (http--127.0.0.1-8080-4) UpperBoundTypedResource<?>(): org.jboss.resteasy.cdi.generic.UpperBoundTypedResource$Proxy$_$$_WeldSubclass@5578cce2
21:08:24,352 INFO [stdout] (http--127.0.0.1-8080-4) UpperBoundTypedResource<?>(): org.jboss.resteasy.cdi.generic.UpperBoundTypedResource$Proxy$_$$_Weld$Proxy$@6dd33544
21:08:24,353 INFO [stdout] (http--127.0.0.1-8080-4) UpperBoundDecorator got delegate: org.jboss.resteasy.cdi.generic.UpperBoundTypedResource$Proxy$_$$_WeldSubclass@5578cce2
21:08:24,355 INFO [org.jboss.resteasy.cdi.generic.UpperBoundDecorator] (http--127.0.0.1-8080-4) entering UpperBoundDecorator.execute()
* no qualifier on producer, qualifier on decorator injection point
Eclipse: complains that no bean is eligible for injection
Execution: test failed to run, with exception:
Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [UpperBoundTypedResource<T>] with qualifiers [@ResourceBinding] at injection point [[parameter 1] of [constructor] @Inject public org.jboss.resteasy.cdi.generic.UpperBoundDecorator(UpperBoundTypedResource<T>)]
* qualifier on producer and decorator injection point:
Eclipse: no complaint
Execution: There was a call to UpperBoundTypedResource(Class<?> clazz) to populate producer field, but no injection was performed on the decorator and UpperBoundDecorator.execute() did not run
21:13:47,017 INFO [stdout] (http--127.0.0.1-8080-3) UpperBoundTypedResource<?>(): org.jboss.resteasy.cdi.generic.UpperBoundTypedResource@58b8dfdf
21:13:47,018 INFO [stdout] (http--127.0.0.1-8080-3) UpperBoundTypedResource(class org.jboss.resteasy.cdi.generic.Primate): org.jboss.resteasy.cdi.generic.UpperBoundTypedResource@5171d6fa
============================================================================================
As another experiment, I exchanged the GenericsProducer producer field for a producer method, with or without the @ResourceBinding qualifier:
@Produces
private UpperBoundTypedResource<HierarchyHolder<Primate>> producer()
{
UpperBoundTypedResource<HierarchyHolder<Primate>> ubhhr = new UpperBoundTypedResource<HierarchyHolder<Primate>>(Primate.class);
System.out.println("GenericsProducer.producer() created: " + ubhhr);
return ubhhr;
}
With these results:
* no qualifer on producer, decorator injection point:
Eclipse: complains that multiple beans are eligible for injection
Execution: The producer method didn't run, an instance of UpperBoundTypedResource, created by the no-arg constructor, was injected into UpperBoundDecorator, and UpperBoundDecorator.execute() ran:
21:42:27,997 INFO [stdout] (http--127.0.0.1-8080-4) UpperBoundTypedResource<?>(): org.jboss.resteasy.cdi.generic.UpperBoundTypedResource$Proxy$_$$_WeldSubclass@6f6a719e
21:42:27,997 INFO [stdout] (http--127.0.0.1-8080-4) UpperBoundTypedResource<?>(): org.jboss.resteasy.cdi.generic.UpperBoundTypedResource$Proxy$_$$_Weld$Proxy$@35497537
21:42:27,998 INFO [stdout] (http--127.0.0.1-8080-4) UpperBoundDecorator got delegate: org.jboss.resteasy.cdi.generic.UpperBoundTypedResource$Proxy$_$$_WeldSubclass@6f6a719e
21:42:28,000 INFO [org.jboss.resteasy.cdi.generic.UpperBoundDecorator] (http--127.0.0.1-8080-4) entering UpperBoundDecorator.execute()
* qualifier on producer, no qualifier on decorator injection point
Eclipse: no complaint
Execution: The producer method didn't run, an instance of UpperBoundTypedResource, created by the no-arg constructor, was injected into UpperBoundDecorator, and UpperBoundDecorator.execute() ran:
21:40:12,589 INFO [stdout] (http--127.0.0.1-8080-4) UpperBoundTypedResource<?>(): org.jboss.resteasy.cdi.generic.UpperBoundTypedResource$Proxy$_$$_WeldSubclass@21d8baaf
21:40:12,590 INFO [stdout] (http--127.0.0.1-8080-4) UpperBoundTypedResource<?>(): org.jboss.resteasy.cdi.generic.UpperBoundTypedResource$Proxy$_$$_Weld$Proxy$@1bc84885
21:40:12,590 INFO [stdout] (http--127.0.0.1-8080-4) UpperBoundDecorator got delegate: org.jboss.resteasy.cdi.generic.UpperBoundTypedResource$Proxy$_$$_WeldSubclass@21d8baaf
21:40:12,594 INFO [org.jboss.resteasy.cdi.generic.UpperBoundDecorator] (http--127.0.0.1-8080-4) entering UpperBoundDecorator.execute()
* no qualifier on producer, qualifier on decorator injection point
Eclipse: complains that no bean is eligible for injection
Execution: test failed to run, with exception:
Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [UpperBoundTypedResource<T>] with qualifiers [@ResourceBinding] at injection point [[parameter 1] of [constructor] @Inject public org.jboss.resteasy.cdi.generic.UpperBoundDecorator(UpperBoundTypedResource<T>)]
* qualifier on producer and decorator injection point:
Eclipse: no complaint
Execution: The producer method didn't run, no injection was performed on the decorator, and UpperBoundDecorator.execute() did not run
21:33:13,861 INFO [stdout] (http--127.0.0.1-8080-4) UpperBoundTypedResource<?>(): org.jboss.resteasy.cdi.generic.UpperBoundTypedResource@4f9078ed
I haven't come up with a consistent explanation. What do you think?
Thanks,
Ron