[img]http://p.blog.csdn.net/images/p_blog_csdn_net/iamzealotwang/426157/o_pic1.jpg[/img]
[img]http://s17.divshare.com/files/2008/07/10/4917109/pic1.jpg[/img]
图片要是看不到,请刷新尝试一下,因为实在找不到好的外链空间。。。
在业务层定义了2个Server
CatalogService
和
UserService
这两个都好理解,问题出在
servicelocator 这个server 上面
public interface ServiceLocator
Interface needs to be implemented by ServiceLocator.
ServiceLocator is used to lookup for business services.
Method Summary
getCatalogService()
Get the CatalogService.
getUserService()
Get the UserService.
我想问一下定义这个servicelocator有什么用处么?
比如
UserBean里面的loginAction()
调用还需要:
User user = this.serviceLocator.getUserService().login(this.username, this.password);
要是不要servicelocator的话 直接this.userservice.login(this.username, this.password);不是挺好的么?
你说要是为了以后的扩充用,可是里面定义的接口就两个
getCatalogService() 和 getUserService() 感觉完全没有用处啊。
[b]问题补充:[/b]
====================补充========================
您好,您的意思我明白。
我是不是可以这样理解,如果使用了loc 这个Server也就没有存在的意义了,是这个样子的么?
要是这样的话,是使用loc好一些 还是手工编写这个Server好呢?
我看的是Put_JSF_ToWork 在他里面给出了一个ServiceLocator的impl 实现了
您说的那个方法
public Object lookupService(String serviceBeanName) {
return appContext.getBean(serviceBeanName);
}
按照这个函数,加入我添加了一个ServerA ,其中有一个方法B()
那我在调用的时候
A a = this.serviceLocator.lookupService(ServerA).####
那块####应该怎么写呢?
谢谢。