org.mortbay.jetty.plus.naming
Class NamingEntry

java.lang.Object
  extended by org.mortbay.jetty.plus.naming.NamingEntry
Direct Known Subclasses:
EnvEntry, Link, 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 isContainerScope
           
protected  String jndiName
           
protected  String namingEntryNameString
           
protected  String objectNameString
           
protected  Object objectToBind
           
protected static ThreadLocal scope
           
static int SCOPE_CONTAINER
           
static int SCOPE_WEBAPP
           
 
Constructor Summary
NamingEntry(String jndiName, Object object)
          Create a NamingEntry.
 
Method Summary
 void bindToENC(String localName)
          Add a java:comp/env binding for the object represented by this NamingEntry, but bind it as the name supplied
 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 Name makeNamingEntryName(NameParser parser, String jndiName)
           
 void release()
          Unbind this NamingEntry entirely
protected  void save()
          Save the NamingEntry for later use.
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_CONTAINER

public static final int SCOPE_CONTAINER
See Also:
Constant Field Values

SCOPE_WEBAPP

public static final int SCOPE_WEBAPP
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

isContainerScope

protected boolean isContainerScope

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()

makeNamingEntryName

public static Name makeNamingEntryName(NameParser parser,
                                       String jndiName)
                                throws NamingException
Throws:
NamingException

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

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()

save

protected void save()
             throws NamingException
Save the NamingEntry for later use. Saving is done by binding 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 the jndiName passed in. This NamingEntry is bound at __jndiName. eg /jdbc/foo : DataSource /jdbc/__foo : NamingEntry

Throws:
NamingException


Copyright © 2008 Mort Bay Consulting. All Rights Reserved.