JSR-299 (CDI) はリソースの (残念ながら命名された) 概念を導入します: http://docs.jboss.org/weld/reference/1.0.0/en-US/html/resources.html#d0e4373
You can think of a resource in this nomenclature as a bridge between the Java EE 6 brand of dependency injection (@EJB, @Resource, @PersistenceContext and the like) and CDI's brand of dependency injection.
The general gist seems to be that somewhere (and this will be the root of my question) you declare what amounts to a bridge class: it contains fields annotated both with Java EE's @EJB or @PersistenceContext or @Resource annotations and with CDI's @Produces annotations. The net effect is that Java EE 6 injects a persistence context, say, where it's called for, and CDI recognizes that injected PersistenceContext as a source for future injections down the line (handled by @Inject).
My question is: what is the community's consensus--or is there one--on:
- what this bridge class should be named
- where this bridge class should live
- whether it's best to localize all this stuff into one class or make several of them
...?
Left to my own devices, I was thinking of declaring a single class called CDIResources
and using that as the One True Place to link Java EE's DI with CDI's DI. Many examples do something similar, but I'm not clear on whether they're "just" examples or whether that's a good way to do it.
Thanks.