现在的位置: 首页 > 技术文章 > 正文

API是什么,什么是SPI,API与SPI的关系

2013年11月18日 技术文章 ⁄ 共 525字 ⁄ 字号 API是什么,什么是SPI,API与SPI的关系已关闭评论 ⁄ 阅读 4,034 次

API就是Application Programming Interface应用程序接口,而SPI是Service Provider Interface服务商提供接口。

在JDK是有如下描述:

· 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关系

API与SPI关系

因此,可清楚知道,API是你可以引用来达成某个目标的对象,它清楚地告诉你它可以完成什么目标,用户可以即插即用;而SPI则指定了你要达成某个目标你必须要继承或实现它,它一般只供某些特殊用途的接口开发商使用(当然,有些公司或个人也可以自己继承或实现SPI来完成特定功能)。

有时候,API和SPI是分不清的,比如Connection接口,Driver接口等。

×