Search code examples
javajndi

JNDI Architecture: JNDI API, Service Provider, SPI?


I have read JNDI online tutorial from oracle using this link.

It has the following diagram:

enter image description here

With respect to this, I have following questions:

1) JNDI API - Is this just a specifications / interfaces which comes as part of J2SE? That is, when we call some method of this API, does this do the real work OR it internally calls someone else, provided by third party?

2) Naming Manager - I didn't get this at all, nor is there any explanation provided? Is this part of the J2SE? Is it API?

3) JNDI SPI - What is this? What is the relationship between JNDI API and JNDI SPI? Do JNDI API call JNDI SPI internally for doing the real work? Who provides these JNDI SPI?

4) What is the meaning of Service Provider?

I am not able to understand this, can anyone help me understand in simple words?


Solution

  • 1) JNDI API - Is this just a specifications / interfaces which comes as part of J2SE?

    Yes.

    That is, when we call some method of this API, does this do the real work

    No.

    OR it internally calls someone else, provided by third party?

    Yes.

    2) Naming Manager - I didn't get this at all, nor is there any explanation provided? Is this part of the J2SE? Is it API?

    It's a bit of behind-the-scenes glue that helps JNDI providers by doing a lot of the boilerplate for them. Or else I don't know what it means.

    3) JNDI SPI - What is this? What is the relationship between JNDI API and JNDI SPI?

    See below.

    Do JNDI API call JNDI SPI internally for doing the real work?

    Yes.

    Who provides these JNDI SPI?

    The container, or in some cases the JRE, such as the RMI provider, the LDAP provider, the DNS provider, the COSNaming provider.

    4) What is the meaning of Service Provider?

    The code that provides the service. I don't think this is such a mystery. The code that implements the interfaces comprising the API.