【转】好文章之服务提供者框架(Service Provider Framework)

关于JDBC

在《Maven实战》中关于依赖范围scope中的runtime中提到过

//运行时依赖范围。使用此依赖范围的Maven依赖,对于测试和运行classpath有效,但在编译主代码时无效。典型的例子是JDBC驱动实现,项目主代码的编译只需要JDK提供的JDBC接口,只有在执行测试或者运行项目的时候才需要实现上述接口的具体JDBC驱动。

在《Effective Java》中有关静态工厂方法替代构造函数的优点中也提到过:

Such flexible static factory methods  form the basis of service provider frameworks, like the Java  Database Connectivity API (JDBC). A service provider framework  is a system in which providers 
implement a service, and the system  makes the implementations available to clients, decoupling the  clients from the implementations.

一直不怎么理解JDBC究竟有什么神奇之处。

下面这篇文章讲解的挺清楚,转载一下。

服务提供者框架(Service Provider Framework)

说说关于我的理解吧:

服务提供者框架好处相当于现在比较火的 前后端分离 一样,服务提供者按照规定的接口,实现服务必须有的的功能,服务使用者,按照指定的接口使用这些功能。而中间的桥梁便是这个框架,这个框架必须包含4个模块分别对接给服务提供者和服务使用者。

具体的大家看看文章的连接吧

posted @ 2018-05-02 15:28  胖毛  阅读(232)  评论(0)    收藏  举报