> Am 05.03.2015 um 02:00 schrieb Bill Shannon <bill.shannon_at_oracle.com>:
>
> I guess we're reading the spec differently. I read section 3.7 of the CDI
> spec to be describing how to use the existing Java EE resource injection
> capabilities to make those resources available to the rest of CDI using
> CDI dependency injection.
That’s how it is intended. Let’s look at one sample from the spec
@Resource(lookup="java:global/env/jdbc/CustomerDatasource")
@Produces
@CustomerDatabase
private Datasource customerDatabase;
EE will take the resource from the given JNDI location and inject it into the customerDatabase field when the containing contextual instance gets created.
CDI will later treat this field as „Producer Field“. @CustomerDatabase is just a random @Qualifier.
This allows to have a much easier to read code without having to copy the jndi location string all over the place:
@ApplicationScoped
public class MyCustomerService {
@Inject
@CustomerDatabase
private DataSource ds;
…
}
LieGrue,
strub