Class NamingEntry

Direct Known Subclasses:
EnvEntry, Link, Resource, Transaction

public abstract class NamingEntry extends Object

Base class for all jndi related entities. Instances of subclasses of this class are declared in jetty.xml or in a webapp's WEB-INF/jetty-env.xml file.

NOTE: that all NamingEntries will be bound in a single namespace. The "global" level is just in the top level context. The "local" level is a context specific to a webapp.

  • Field Details

    • __contextName

      public static final String __contextName
      See Also:
    • _scope

      protected final Object _scope
    • _jndiName

      protected final String _jndiName
    • _namingEntryNameString

      protected String _namingEntryNameString
    • _objectNameString

      protected String _objectNameString
  • Constructor Details

    • NamingEntry

      protected NamingEntry(Object scope, String jndiName) throws NamingException
      Create a naming entry.
      scope - an object representing the scope of the name to be bound into jndi, where null means jvm scope.
      jndiName - the name that will be associated with an object bound into jndi
      NamingException - if jndiName is null
    • NamingEntry

      protected NamingEntry(String jndiName) throws NamingException
      Create a NamingEntry. A NamingEntry is a name associated with a value which can later be looked up in JNDI by a webapp. We create the NamingEntry and put it into JNDI where it can be linked to the webapp's env-entry, resource-ref etc entries.
      jndiName - the name of the object which will eventually be in java:comp/env
      NamingException - if unable to create naming entry
  • Method Details

    • bindToENC

      public void bindToENC(String localName) throws NamingException
      Add a java:comp/env binding for the object represented by this NamingEntry, but bind it as the name supplied
      localName - the local name to bind
      NamingException - if unable to bind
    • unbindENC

      public void unbindENC()
      Unbind this NamingEntry from a java:comp/env
    • release

      public void release()
      Unbind this NamingEntry entirely
    • getJndiName

      public String getJndiName()
      Get the unique name of the object relative to the scope
      the unique jndi name of the object
    • getJndiNameInScope

      public String getJndiNameInScope()
      Get the name of the object, fully qualified with the scope
      the name of the object, fully qualified with the scope
    • save

      protected void save(Object object) throws NamingException
      Save the NamingEntry for later use.

      Saving is done by binding both the NamingEntry itself, and the value it represents into JNDI. In this way, we can link to the value it represents later, but also still retrieve the NamingEntry itself too.

      The object is bound at scope/jndiName and the NamingEntry is bound at scope/__/jndiName.


       jdbc/foo    : DataSource
       __/jdbc/foo : NamingEntry
      object - the object to save
      NamingException - if unable to save
      See Also:
    • toStringMetaData

      protected String toStringMetaData()
    • toString

      public String toString()
      toString in class Object