0 votes
1 view
ago in Java by (2.1k points)

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?

1 Answer

0 votes
ago by (21.7k points)
  • The API is the type of classes/interfaces/methods/... that you call and apply to obtain an aim, and
  • the SPI is the kind of classes/interfaces/methods/... that you reach and perform to reach an object.

Put otherwise, the API shows you what a particular class/method does for you, and the SPI shows you what you must do to conform.

Usually, API and SPI are separate. For example, in JDBC the Driver class is a portion of the SPI: If you completely want to use JDBC, you don't require to use it immediately, but everyone who completes a JDBC driver must implement that class.

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

...