Difference between SPI and API?

前端 未结 9 1118
旧巷少年郎
旧巷少年郎 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:55

    In the Java world, different technologies are meant to be modular and "pluggable" into an application server. There is then a difference between

    • the application server
      • [SPI]
    • the pluggable technology
      • [API]
    • the end user application

    Two examples of such technologies are JTA (the transaction manager) and JCA (adapter for JMS or database). But there are others.

    Implementer of such a pluggable technology must then implement the SPI to be pluggable in the app. server and provide an API to be used by the end-user application. An example from JCA is the ManagedConnection interface which is part of the SPI, and the Connection that is part of the end-user API.

提交回复
热议问题