问题描述
什么是的?
更具体地,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 是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.
有时,他们不过重叠。 的连接
接口一>为两个 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之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!