users@glassfish.java.net

CDI question

From: <glassfish_at_javadesktop.org>
Date: Fri, 11 Jun 2010 10:38:05 PDT

This one is not Glassfish-specific, but a good number of Java EE 6 developers hang out here and nowhere else, so I hope you'll forgive the off-topic post.

Where is the best place, in the community's opinion, to declare CDI resources?

Recall that CDI defines a resource to be a producer field that is also the target of a "native" Java EE 6 dependency injection operation. So, for example:

[code]@Produces
@EJB
private MyBeanInterface myBean;[/code]
Many examples show this sort of thing occurring in one "special" class. That is, you define what amounts to a bridge between the "native" Java EE 6 world and the CDI world, and in that class you put all these producer fields that you're going to make use of down the road in your application. This allows your application to be a simple CDI application without having to drag in javax.ejb.EJB and the like--i.e. there's only one place those annotations end up showing up, and it's here, in this single bridge class.

My question is: is this appropriate? Where do you all define your CDI resources? I was thinking about putting them in a single class per package or deployment module named something like CDIResources.

Any thoughts heartily encouraged. The StackOverflow version of this question is here, if you'd rather not have a non-Glassfish discussion here: http://stackoverflow.com/questions/3024828/where-should-i-declare-my-cdi-resources

Thanks in advance; happy Friday.

Best,
Laird
[Message sent by forum member 'ljnelson']

http://forums.java.net/jive/thread.jspa?messageID=473931