[英]Technical architecture : Service layer or not?
we have a platform composed of few applications. 我们有一个由少量应用程序组成的平台。
We have to develop an API which must factorize all interaction to a database. 我们必须开发一个API,该API必须将与数据库的所有交互都分解为因素。 In this API, we will too have a version of the database in XML format.
在此API中,我们还将拥有XML格式的数据库版本。 The XML format will be used just by one application.
XML格式将仅由一个应用程序使用。
Our application are developped in a classic architectural : dao - service layer - presentation layer. 我们的应用程序是在经典的体系结构中开发的:dao-服务层-表示层。
The DAO layer will be moved into API. DAO层将移入API。 No problem on that point.
在这一点上没有问题。 In many application, the service layer is just a gateway between presentation & dao layer without specific business code.
在许多应用程序中,服务层只是表示层和导引层之间的网关,而没有特定的业务代码。
So my questions are : 所以我的问题是:
Need help ! 需要帮忙 ! :p I'm lost...
:p我迷路了...
FYI, we are in Java 1.6 with Spring 3.1.1. 仅供参考,我们在Java 1.6和Spring 3.1.1中。 JDBC Template in DAO for moment.
DAO中的JDBC模板暂时。 We are looking informations about spring data jdbc to replace JDBC Template.
我们正在寻找有关Spring数据jdbc的信息,以替换JDBC模板。 Any suggestion about that can be appreciated ^^ [ No Hibernate - JPA solution ]
对此的任何建议都值得赞赏^^ [No Hibernate-JPA solution]
Thank you. 谢谢。
[edit 1] [编辑1]
In other word, keep a service layer in application & in the API is a way for me to have an abstraction layer. 换句话说,在应用程序和API中保留服务层是我拥有抽象层的一种方式。 If we have to modify the database structure, maybe we don't have to edit all applications if we can make some changes directly in the service layer of API too.
如果我们必须修改数据库结构,那么如果我们也可以直接在API的服务层中进行一些更改,那么也许不必编辑所有应用程序。
Imagine 3 possibilities : 想象3种可能性:
What solution do you choose ? 您选择什么解决方案?
[edit 2] [编辑2]
Is it interesting to create an unique class to call the API ? 创建一个唯一的类来调用API有趣吗? like in a Facade design Pattern.
就像在立面设计模式中一样。
Use the Service Layer for what is meant to do: provide real world services, by using one ore more DAOs per service offered (and other stuff like managing transactions, sanitizing String
s and other things like that). 使用服务层实现目的:通过提供的每项服务使用一个或多个DAO来提供真实的服务(以及其他诸如管理事务,清理
String
等之类的东西)。
If you (together with a more experienced coworker) think you don't need this service layer, then do not put it into your architecture. 如果您(与经验丰富的同事一起)认为您不需要此服务层,则不要将其放入体系结构中。 But make sure to create a proof of concept of your architecture (this may contain the implementation of a somewhat complex functionality of the system or part of it) so you can evaluate it later to demonstrate if you really don't need such layer (or if you do).
但是请确保创建您的体系结构的概念证明(其中可能包含系统或部分系统的某种复杂功能的实现),以便稍后进行评估以证明您是否真的不需要这种层(或如果您这样做)。
My understanding is that you need to decouple and reuse the business layer from the presentation layer, having multiple client applications using the same business implementation. 我的理解是,您需要使业务层与表示层脱钩并重用,使多个客户端应用程序使用同一业务实现。
In this case you need to implement the service layer in the API. 在这种情况下,您需要在API中实现服务层。 Some advantages:
一些优点:
In this API, we will too have a version of the database in XML format.
在此API中,我们还将拥有XML格式的数据库版本。 The XML format will be used just by one application.
XML格式将仅由一个应用程序使用。
By providing this implementation via the API more client applications will be able to use it in the future, if needed. 通过API提供此实现,如果需要,将来更多的客户端应用程序将能够使用它。
Spring remoting is offering excellent tools for such a design (RMI, HTTP invoker etc) Spring远程处理为此类设计提供了出色的工具(RMI,HTTP调用程序等)
I don't see any added value in proving an API for DAOs. 在证明DAO的API方面,我没有看到任何附加价值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.