Difference between SPI and API?

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

    The difference between API and SPI comes when an API additionally provides some concrete implementations. In that case, the service provider has to implement a few APIs (called SPI)

    An example is JNDI:

    JNDI provides interfaces & some classes for context lookup. The default way to lookup a context is provided in IntialContext. This class internally will use SPI interfaces (using NamingManager) for provider specific implementations.

    See the JNDI Architecture below for better understanding.

    Enter image description here

提交回复
热议问题