I've just started to learn JNDI. As I understood it's an INTERFACE for different naming services.
I decided to use it as a registry for objects I have. For example, I have object configuration and I want to get it from another object by JNDI. Of course I could use some static ways for example Registry.get("configuration")
but I want to start using JNDI. And I need it for java se application.
Important - objects mustn't be persisted to db/files etc.
But what implementation of naming service should I use? If someone provided an example it would be great.
JNDI is a naming provider. Usual registries (besides JavaEE, will come later to that) are LDAP or DNS. Both systems are organized with hierarchies and provide lookup of data.
In the Java Enterprise world, JNDI is used to retrieve ConnectionFactories, EJB's, DataSources, configuration objects and many more, which are configured within the application server container.
The JNDI starting point in Java is the InitialContext
. There are implementations which allow use within JavaSE (like SimpleNamingContextBuilder within tests) but in general, building an own InitialContextFactory is an advanced topic.