petstore 中为什么有两个ServiceLocator?

03-10-23 hhquan
sun的解释如下,我没有看懂

For an enterprise bean lookup, the Service Locator needs a class as a parameter to the PortableRemoteObject.narrow() method. The Service Locator can provide a getHome() method, which accepts as arguments the JNDI service name and the EJBHome class object for the enterprise bean. Using this method of passing in JNDI service names and EJBHome class objects can lead to client errors. Another approach is to statically define the services in the ServiceLocator, and instead of passing in string names, the client passes in a constant.

链接:http://java.sun.com/blueprints/corej2eepatterns/Patterns/ServiceLocator.html

哪位大侠能够给解释解释

banq
2003-11-03 12:10
以前解释过,分别是给Web层和EJB层使用,前者可以是Singlton模式,但是在Singleton在EJB中就失效了,因为EJB是分布式的,可能在几台机器的几个JVM中运行,那这个Singleton就只是一个JVM中的单态了。

猜你喜欢