org.codehaus.spice.jndikit
Class AbstractURLContext

java.lang.Object
  extended byorg.codehaus.spice.jndikit.AbstractContext
      extended byorg.codehaus.spice.jndikit.AbstractURLContext
All Implemented Interfaces:
Context, NameParser

public abstract class AbstractURLContext
extends AbstractContext
implements NameParser

Abstract JNDI Context that can be inherited from to provide a particular type of Context.

Version:
$Revision: 1.1 $
Author:
Peter Donald

Field Summary
 
Fields inherited from interface javax.naming.Context
APPLET, AUTHORITATIVE, BATCHSIZE, DNS_URL, INITIAL_CONTEXT_FACTORY, LANGUAGE, OBJECT_FACTORIES, PROVIDER_URL, REFERRAL, SECURITY_AUTHENTICATION, SECURITY_CREDENTIALS, SECURITY_PRINCIPAL, SECURITY_PROTOCOL, STATE_FACTORIES, URL_PKG_PREFIXES
 
Constructor Summary
AbstractURLContext(String scheme, Hashtable environment)
           
 
Method Summary
protected  void bind(Name name, Object object, boolean rebind)
          Helper method to bind
 Context createSubcontext(Name name)
          Create a Subcontext.
 void destroySubcontext(Name name)
           
protected  ResolveResult getBaseURLContext(Name name, Hashtable environment)
           
protected  int getEndIndexOfURLPart(String name, int index)
          Find end index of url part in string.
 String getNameInNamespace()
           
protected  NameParser getNameParser()
           
 NamingEnumeration list(Name name)
          Enumerates the names bound in the named context.
 NamingEnumeration listBindings(Name name)
          Enumerates the names bound in the named context, along with the objects bound to them.
 Object lookup(Name name)
          Get the object named.
protected abstract  Context newContext(String urlPart)
          Return a new instance of the base context for a URL.
 Name parse(String name)
           
 void unbind(Name name)
          Unbind a object from a name.
 
Methods inherited from class org.codehaus.spice.jndikit.AbstractContext
addToEnvironment, bind, bind, close, composeName, composeName, createSubcontext, destroySubcontext, getEnvironment, getLeafName, getNameParser, getNameParser, getPathName, getRawEnvironment, isSelf, list, listBindings, lookup, lookupLink, lookupLink, rebind, rebind, removeFromEnvironment, rename, rename, unbind
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractURLContext

public AbstractURLContext(String scheme,
                          Hashtable environment)
Method Detail

parse

public Name parse(String name)
           throws NamingException
Specified by:
parse in interface NameParser
Throws:
NamingException

getNameParser

protected NameParser getNameParser()
                            throws NamingException
Specified by:
getNameParser in class AbstractContext
Throws:
NamingException

bind

protected void bind(Name name,
                    Object object,
                    boolean rebind)
             throws NamingException
Helper method to bind

Specified by:
bind in class AbstractContext
Throws:
NamingException

createSubcontext

public Context createSubcontext(Name name)
                         throws NamingException
Create a Subcontext.

Specified by:
createSubcontext in interface Context
Parameters:
name - the name of subcontext
Returns:
the created context
Throws:
NamingException - if an error occurs (ie context exists, badly formated name etc)

destroySubcontext

public void destroySubcontext(Name name)
                       throws NamingException
Specified by:
destroySubcontext in interface Context
Throws:
NamingException

getNameInNamespace

public String getNameInNamespace()
                          throws NamingException
Specified by:
getNameInNamespace in interface Context
Throws:
NamingException

list

public NamingEnumeration list(Name name)
                       throws NamingException
Enumerates the names bound in the named context.

Specified by:
list in interface Context
Parameters:
name - the name of the context
Returns:
the enumeration
Throws:
NamingException - if an error occurs

listBindings

public NamingEnumeration listBindings(Name name)
                               throws NamingException
Enumerates the names bound in the named context, along with the objects bound to them.

Specified by:
listBindings in interface Context
Parameters:
name - the name of the context
Returns:
the enumeration
Throws:
NamingException - if an error occurs

lookup

public Object lookup(Name name)
              throws NamingException
Get the object named.

Specified by:
lookup in interface Context
Parameters:
name - the name
Returns:
the object
Throws:
NamingException - if an error occurs (ie object name is inavlid or unbound)

unbind

public void unbind(Name name)
            throws NamingException
Unbind a object from a name.

Specified by:
unbind in interface Context
Parameters:
name - the name
Throws:
NamingException - if an error occurs

getBaseURLContext

protected ResolveResult getBaseURLContext(Name name,
                                          Hashtable environment)
                                   throws NamingException
Throws:
NamingException

getEndIndexOfURLPart

protected int getEndIndexOfURLPart(String name,
                                   int index)
                            throws NamingException
Find end index of url part in string. Default implementation looks for //.../[name-part] ///[name-part] //... (no name part) [name-part]

Parameters:
name - the name
index - the index where "scheme:" ends
Returns:
the index where url ends
Throws:
NamingException - if an error occurs

newContext

protected abstract Context newContext(String urlPart)
                               throws NamingException
Return a new instance of the base context for a URL. This must be implemented in particular URLContext.

Parameters:
urlPart - the part of url string not including "scheme:"
Returns:
a base URLContext for urlPart
Throws:
NamingException - if an error occurs


Copyright © 1999-2007 Codehaus. All Rights Reserved.