The declarative JNDI solution leverages the Eclipse extension point registry to provide a means to declare a list of objects that should be bound in JNDI if/when a client application attempts to locate them. In order to provide an extensible mechanism for this the declarative JNDI component makes use of the JNDI ObjectFactory
interface as a way of abstracting the JNDI provider from the specific implementation code needed to instantiate different objects to be bound in JNDI. The javax.naming.spi.ObjectFactory
interface is very simple and contains only one method getObjectInstance()
is called by the lookup()
method of our JNDI provider implementation if it is unable to locate the object requested in it’s current registry of JNDI objects. The JNDI provider will first read the list of object factories from an Eclipse extension point. It will then read the list of descriptions of objects to be bound into JNDI. With this information, the JNDI provider will determine if the name that is attempting to be located is in the list of names to be lazily bound, if it is, it will instantiate the ObjectFactory
based on the id provided in the extension point registry for that name and call getObjectInstance()
with a null object, the current name and context. The returned object from this method invocation will then be bound into the JNDI object registry and returned from the lookup method of the JNDI provider.
In the WebSphere
® Deployment runtime Object factories are registered via the Eclipse extension point registry which allows for any number of ObjectFactory
implementations to be registered and available to the JNDI Provider.
This extension point is com.ibm.pvc.jndi.provider.java.objectfactory
and an example of the usage of this extension point would be similar to the following:
Parent topic: Configuring enterprise definitions (JNDI)