Hi!
We have a @Produces method that produces dependent CDI beans. The objects
we produce are depenend since we need to use InjectionPoint to get to the
annotations at the injection point.
Depending on which annotations are present and their attribute values we
choose which implementation to return.
Pseudocode, TestImpl1/2 both implement Test ofcourse, we use Provider<...>
since we do not want to init both 1 and 2 when we only will return one of
them. The implementations both injects other beans, thats why we not create
them using "new".
@Produces
public static Test createTest(Provider<TestImpl1> testImpl1,
Provider<TestImpl2> testImpl2, InjectionPoint injectionPoint) {
if
(injectionPoint.getAnnotated().getAnnotation(TestAnnotation.class).getAttribute().equals(....))
{
return testImpl1.get();
}
else {
return testImpl2.get();
}
}
Question:
1. What is the overhead of using the above approach with Provider<...> and
get() on the implementation we eventually will use compared to e.g.
DeltaSpikes BeanProvider.getContextualReference ?
2. In OWB can someone explain the process that OWB uses internally when
getBeans() is called?
Regards
LF
--
Med vänlig hälsning / Best regards
Lars-Fredrik Smedberg
STATEMENT OF CONFIDENTIALITY:
The information contained in this electronic message and any
attachments to this message are intended for the exclusive use of the
address(es) and may contain confidential or privileged information. If
you are not the intended recipient, please notify Lars-Fredrik Smedberg
immediately at [email protected], and destroy all copies of this
message and any attachments.