## org.mortbay.jetty.plus.naming
Class NamingEntry

    java.lang.Object
      org.mortbay.jetty.plus.naming.NamingEntry

Direct Known Subclasses:
  EnvEntry, Resource, Transaction

    public abstract class NamingEntry

extends Object

NamingEntry 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 Summary
`protected String` `absoluteObjectNameString`
`protected Context` `context`
`protected boolean` `isGlobal`
`protected String` `jndiName`
`protected String` `namingEntryNameString`
`protected String` `objectNameString`
`protected Object` `objectToBind`
`protected static ThreadLocal` `scope`
`static int` `SCOPE_GLOBAL`
`static int` `SCOPE_LOCAL`

Constructor Summary
`NamingEntry(String jndiName, Object object)` Create a NamingEntry.

Method Summary
`void` `bindToENC()` Add a java:comp/env binding for the object represented by this NamingEntry
`void` `bindToENC(String overrideName)` Add a java:comp/env binding for the object represented by this NamingEntry, but bind it as a different name to the one supplied
`static void` `bindToENC(String name, String overrideName, Class namingEntryType)` Bind a NamingEntry into JNDI.
`static boolean` `exists(int scopeType, Class namingEntryType, String jndiName)` Check to see if a NamingEntry exists in the given scope (local or global).
`String` `getJndiName()` Get the unique name of the object
`Object` `getObjectToBind()` Get the object that is to be bound
`static int` `getScope()`
`boolean` `isGlobal()` Check if this naming entry was global or locally scoped to a webapp
`boolean` `isLocal()`
`static List` `lookupNamingEntries(int scopeType, Class clazz)` Get all NameEntries of a certain type in either the local or global namespace.
`static NamingEntry` `lookupNamingEntry(int scopeType, Class clazz, String jndiName)` Find a NamingEntry of the given scope.
`void` `release()` Unbind this NamingEntry entirely
`static void` `setScope(int scopeType)`
`void` `unbindENC()` Unbind this NamingEntry from a java:comp/env

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### SCOPE_GLOBAL

    public static final int SCOPE_GLOBAL

See Also:
  Constant Field Values

### SCOPE_LOCAL

    public static final int SCOPE_LOCAL

See Also:
  Constant Field Values

### jndiName

    protected String jndiName

### objectToBind

    protected Object objectToBind

### absoluteObjectNameString

    protected String absoluteObjectNameString

### namingEntryNameString

    protected String namingEntryNameString

### objectNameString

    protected String objectNameString

### context

    protected Context context

### isGlobal

    protected boolean isGlobal

### scope

    protected static ThreadLocal scope

Constructor Detail

### NamingEntry

    public NamingEntry(String jndiName,
                       Object object)
                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.

  Parameters:
    `jndiName` - the name of the object which will eventually be in java:comp/env
    `object` - the object to be bound
  Throws:
    `NamingException`

Method Detail

### setScope

    public static void setScope(int scopeType)

### getScope

    public static int getScope()

### bindToENC

    public static void bindToENC(String name,
                                 String overrideName,
                                 Class namingEntryType)
                          throws NamingException

  Bind a NamingEntry into JNDI. Locally scoped entries take precedence over globally scoped ones to allow webapps to override.

  Parameters:
    `name` - the name of the NamingEntry from the runtime environment
    `overrideName` - the name it should be bound as into java:comp/env
    `namingEntryType` -
  Throws:
    `NamingException`

### exists

    public static boolean exists(int scopeType,
                                 Class namingEntryType,
                                 String jndiName)

  Check to see if a NamingEntry exists in the given scope (local or global).

  Parameters:
    `scopeType` - local or global
    `namingEntryType` - the type of the NamingEntry
    `jndiName` - the name in jndi
  Returns:

### lookupNamingEntry

    public static NamingEntry lookupNamingEntry(int scopeType,
                                                Class clazz,
                                                String jndiName)
                                         throws NamingException

  Find a NamingEntry of the given scope.

  Parameters:
    `scopeType` - local or global
    `clazz` - the type of the value stored by the NamingEntry
    `jndiName` - the name in jndi
  Returns:
  Throws:
    `NamingException`

### lookupNamingEntries

    public static List lookupNamingEntries(int scopeType,
                                           Class clazz)
                                    throws NamingException

  Get all NameEntries of a certain type in either the local or global namespace.

  Parameters:
    `scopeType` - local or global
    `clazz` - the type of the entry
  Returns:
  Throws:
    `NamingException`

### bindToENC

    public void bindToENC()
                   throws NamingException

  Add a java:comp/env binding for the object represented by this NamingEntry

  Throws:
    `NamingException`

### bindToENC

    public void bindToENC(String overrideName)
                   throws NamingException

  Add a java:comp/env binding for the object represented by this NamingEntry, but bind it as a different name to the one supplied

  Throws:
    `NamingException`

### 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

  Returns:

### getObjectToBind

    public Object getObjectToBind()
                           throws NamingException

  Get the object that is to be bound

  Returns:
  Throws:
    `NamingException`

### isGlobal

    public boolean isGlobal()

  Check if this naming entry was global or locally scoped to a webapp

  Returns:
    true if naming entry was bound at global scope, false otherwise

### isLocal

    public boolean isLocal()

Copyright © 2008 Mort Bay Consulting. All Rights Reserved.