Difference between SPI and API?

前端 未结 9 1125
旧巷少年郎
旧巷少年郎 2020-11-28 00:21

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

More specifically, for Java libraries, what makes them a

9条回答
  •  眼角桃花
    2020-11-28 00:36

    Service provider interface is the service interface which all providers must implement. If none of the existing provider implementations work for you, you need to write your own service provider (implementing the service interface) and register somewhere (see the useful post by Roman).

    If you're reusing the existing provider implementation of the service interface, you're basically using the API of that particular provider, which include all the methods of service interface plus a few public methods of its own. If you're using methods of provider API outside the SPI, you're using provider specific features.

提交回复
热议问题