SPI和API的区别? [英] Difference between SPI and API?

查看:47
本文介绍了SPI和API的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

服务提供者接口 (SPI)应用程序编程接口 (API)?

更具体地说,对于 Java 库,是什么使它们成为 API 和/或 SPI?

More specifically, for Java libraries, what makes them an API and/or SPI?

推荐答案

  • API 是对您调用和使用以实现目标的类/接口/方法/...的描述,以及
  • SPI 是对您扩展和实现以实现目标的类/接口/方法/...的描述.
    • The API is the description of classes/interfaces/methods/... that you call and use to achieve a goal, and
    • the SPI is the description of classes/interfaces/methods/... that you extend and implement to achieve a goal.
    • 换句话说,API 会告诉您特定的类/方法为您做什么,而 SPI 会告诉您必须做什么才能符合要求.

      Put differently, the API tells you what a specific class/method does for you, and the SPI tells you what you must do to conform.

      通常 API 和 SPI 是分开的.例如,在 JDBC Driver class 是 SPI 的一部分:如果您只是想使用 JDBC,则不需要直接使用它,但是每个实现 JDBC 驱动程序的人都必须实现该类.

      Usually API and SPI are separate. For example, in JDBC the Driver class is part of the SPI: If you simply want to use JDBC, you don't need to use it directly, but everyone who implements a JDBC driver must implement that class.

      然而,有时它们会重叠.Connection 接口SPI 和 API:您在使用 JDBC 驱动程序时经常使用它,它需要由 JDBC 驱动程序的开发人员实现.

      Sometimes they overlap, however. The Connection interface is both SPI and API: You use it routinely when you use a JDBC driver and it needs to be implemented by the developer of the JDBC driver.

      这篇关于SPI和API的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆