开发者

Is it allowed to pass-through an ejb references to a used class of an ejb?

I have an EJB3 stateless session bean that uses some other ejbs to do its work. As I do not want to have all the logic in the ejb class itself, I created some classes which solve the problems. These classes are called by the ejb. To have the referenced ejbs in t开发者_如何学编程hese classes I created a context object that holds the injected ejb references which is passed to the classes.

My question: is this allowed to store ejb references in simple object fields or must I use some special ejb reference fields? At first glance I can't see a reason why because everything is handled in one thread an transaction.


You can pass these EJB references and store them in these auxiliar classes without any risk.

Nevertheless, EJB specification encourages you to implement all the logic of your system through EJBs. So, from EJB design philosofy, you should declare these "auxiliar" classes as EJBs also (they perform business logic in the end) and inject into them the needed EJBs references to reduce the coupling (specially if the former EJB doesn't even use the injected EJBs).

Again, if you don't do it and just pass the references manually, no technicall issue should arise.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜