开发者

Using JNDI to obtain a reference to EJBs from external libraries

We have some external libraries which we use in a J2EE application on Glassfish 3.1. Those libraries allow registering handlers for certain events. The requirement is that those handlers should make use of EJBs in the main application.

Our idea was to make those custom handlers in a way that they use JNDI to fetch references to EJBs, and then ca开发者_如何学JAVAll methods on those EJBs. Is this the proper way to do this?


Without knowing your specific use case, I can affirm that can be an effective way to get access to common resources (EJBs in your case) containing discrete business logic.

A common implementation involves a Service Locator to handle the jndi lookup and return a reference or make a direct call to business logic located in one or more Stateless Session Beans.

This pattern is often used, for instance, to query or persist objects to a database using a shared connection or entity manager, or gain access to a pooled factory which governs pooled resource allotment in a multi-threaded environment.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜