Web 服务中的服务层
我对服务层必须包含什么(Web 服务上下文)有点困惑。 在我的应用程序中,服务层仅具有将操作委托给域层的接口及其实现(这里是 POJO 和执行域逻辑的所有类)。
事实上,我只有一个接口和一个实现,如下所示:
接口:
package org.myapp.services;
import org.myapp.domain.entities.User;
public interface IServices {
public User getUserInfo(String userId);
}
和实现:
package org.myapp.services;
import org.myapp.domain.entities.User;
import org.myapp.domain.usermanagement.UserManager;
public class Services implements IServices{
UserManager userManager;
public Services() {
userManager = new UserManager();
}
public User getUserInfo(String userId) {
return userManager.getUserInfo(userId);
}
}
(UserManager 类属于域层)。
客户端可以使用以下 url 访问 Web 服务: http://address/axis2/services/myapp/getUserInfo
这是正确的方法吗?
I'm a little confused about what service layer must contain (Web Services context).
In my application the service layer only has interfaces and their implementations that delegate operations to the domain layer (here are POJO'S and all the classes that do the domain logic).
In fact I have only one interface and one implementation like this:
The interface :
package org.myapp.services;
import org.myapp.domain.entities.User;
public interface IServices {
public User getUserInfo(String userId);
}
And the implementation:
package org.myapp.services;
import org.myapp.domain.entities.User;
import org.myapp.domain.usermanagement.UserManager;
public class Services implements IServices{
UserManager userManager;
public Services() {
userManager = new UserManager();
}
public User getUserInfo(String userId) {
return userManager.getUserInfo(userId);
}
}
(The UserManager class is belongs to the domain layer).
And the clients can access the web service using the url:
http://address/axis2/services/myapp/getUserInfo
Is this a correct approach?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论