确切地说,将在j2ee应用程序中使用服务定位器模式 [英] Exactly when the service locator pattern will be used in j2ee application

查看:77
本文介绍了确切地说,将在j2ee应用程序中使用服务定位器模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

伙计们,



我是一名j2ee开发人员。我想知道在开发j2ee应用程序时将遵循何种服务定位器设计模式。你能告诉我一些想法吗? --- Rakesh

Guys,

I am a j2ee developer. I want to know when exactly service locator design pattern will be followed for developing a j2ee application. Could you please give me certain idea ? --- Rakesh

推荐答案

当我们想要使用JNDI查找并使用业务组件如EJB bean和JMS组件和服务时,使用服务定位器设计模式。数据源。考虑到为服务查找JNDI的高成本,Service Locator模式使用缓存技术。第一次在JNDI中查找服务定位器并对其进行缓存。通过Service Locator在同一服务上进一步查找在其缓存中完成,从而提高了性能。

如果您使用像Spring这样的DI容器,那么您不需要实现服务定位器模式。如果您正在使用任何JNDI查找,那么最好使用服务定位器模式。
The service locator design pattern is used when we want to use JNDI lookup and use business component such an EJB beans and JMS component and services such as datasources. Considering high cost of looking up JNDI for a service, Service Locator pattern makes use of caching technique. For the first time Service locator lookup in JNDI and cache it. Further lookup on the same service via Service Locator is done in its cache which improves performance.
If you using a DI container like Spring then you don’t need to implement service locator pattern. If you are using any JNDI lookup then it is better to use service locator pattern.


这篇关于确切地说,将在j2ee应用程序中使用服务定位器模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆