Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between SPI and API?

Tags:

java

api

What is the difference between Service Provider Interface (SPI) and Application Programming Interface (API)?

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

like image 623
kctang Avatar asked Jun 02 '10 01:06

kctang


People also ask

What is an SPI in software?

In a computer, a serial peripheral interface (SPI) is an interface that enables the serial (one bit at a time) exchange of data between two devices, one called a master and the other called a slave . An SPI operates in full duplex mode.

What is service provider API?

The service provider API provides custom connectors. The connectors can be used from the IBM® Security Identity Manager provisioning platform or any other Java-based provisioning platform that supports the same interface.

What is a SPI endpoint?

Service provider interface (SPI) is an API intended to be implemented or extended by a third party. It can be used to enable framework extension and replaceable components.

What is SPI package?

SPI stands for Service Provider Interface and it's a standard Java way to plugin additional functionality as a service discovery mechanism - You can read more about it here SPI basics.


1 Answers

  • 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.

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.

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.

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.

like image 111
Joachim Sauer Avatar answered Oct 20 '22 17:10

Joachim Sauer