Class JndiExamples

java.lang.Object
net.jrodolfo.java_evolution.java03.jndi.JndiExamples

public class JndiExamples extends Object
Demonstrates Java Naming and Directory Interface (JNDI), included in J2SE 1.3.

Production JNDI providers often point to LDAP, DNS, RMI registries, or application-server resources. This example uses a tiny in-memory provider so the provider model, names, contexts, bindings, and lookups can be exercised without external infrastructure.

  • Constructor Details

    • JndiExamples

      public JndiExamples()
  • Method Details

    • createContext

      public Context createContext() throws NamingException
      Creates an InitialContext configured with the in-memory provider used by this example.
      Returns:
      configured initial context
      Throws:
      NamingException - when the context cannot be created
    • bindAndLookup

      public Object bindAndLookup(String name, Object value) throws NamingException
      Binds a name and looks it up again through the JNDI API.
      Parameters:
      name - object name
      value - object to bind
      Returns:
      object returned by lookup
      Throws:
      NamingException - when binding or lookup fails