views:

306

answers:

0

In JBoss 4.x, @EJB / @Resource annotations can only be used in EJBs. If you use a stateless bean or an MDB as an entry point, you can inject your resources using the annotations. However, if you have Pojo's that perform business logic and need to use these resources, they can not be injected via annotations.

I am passing the references into the Pojo via the constructor for use by the Pojo to call other EJBs or access resources. This enables me to use the EJB3 injection facilities without having to perform JNDI lookups in the Pojo. Thoughts on this approach? It seems reasonable to me and I don't believe there are any lifecycle concerns related to passing these references.

If you know of a reason I shouldn't do this or have a different approach, let me know.

Thanks,

Bret