aicas logo Jamaica 3.4 release 8

com.sun.jndi.toolkit.url
Class GenericURLContext

java.lang.Object
  extended by com.sun.jndi.toolkit.url.GenericURLContext
All Implemented Interfaces:
Context
Direct Known Subclasses:
GenericURLDirContext

public abstract class GenericURLContext
extends Object
implements Context

This abstract class is a generic URL context that accepts as the name argument either a string URL or a Name whose first component is a URL. It resolves the URL to a target context and then continues the operation using the remaining name in the target context as if the first component names a junction. A subclass must define getRootURLContext() to process the URL into head/tail pieces. If it wants to control how URL strings are parsed and compared for the rename() operation, then it should override getNonRootURLSuffixes() and urlEquals().


Field Summary
protected  Hashtable myEnv
           
 
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
GenericURLContext(Hashtable env)
           
 
Method Summary
 Object addToEnvironment(String propName, Object propVal)
           
 void bind(Name name, Object obj)
           
 void bind(String name, Object obj)
           
 void close()
           
 Name composeName(Name name, Name prefix)
           
 String composeName(String name, String prefix)
           
 Context createSubcontext(Name name)
           
 Context createSubcontext(String name)
           
 void destroySubcontext(Name name)
           
 void destroySubcontext(String name)
           
protected  Context getContinuationContext(Name n)
          Gets the context in which to continue the operation.
 Hashtable getEnvironment()
           
 String getNameInNamespace()
           
 NameParser getNameParser(Name name)
           
 NameParser getNameParser(String name)
           
protected abstract  ResolveResult getRootURLContext(String url, Hashtable env)
          Resolves 'name' into a target context with remaining name.
protected  String getURLPrefix(String url)
          Finds the prefix of a URL.
protected  Name getURLSuffix(String prefix, String url)
          Returns the suffix of the url.
  list(Name name)
           
  list(String name)
           
  listBindings(Name name)
           
  listBindings(String name)
           
 Object lookup(Name name)
           
 Object lookup(String name)
           
 Object lookupLink(Name name)
           
 Object lookupLink(String name)
           
 void rebind(Name name, Object obj)
           
 void rebind(String name, Object obj)
           
 Object removeFromEnvironment(String propName)
           
 void rename(Name name, Name newName)
           
 void rename(String oldName, String newName)
           
 void unbind(Name name)
           
 void unbind(String name)
           
protected  boolean urlEquals(String url1, String url2)
          Determines whether two URLs are the same.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

myEnv

protected Hashtable myEnv
Constructor Detail

GenericURLContext

public GenericURLContext(Hashtable env)
Method Detail

close

public void close()
           throws NamingException
Specified by:
close in interface Context
Throws:
NamingException

getNameInNamespace

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

getRootURLContext

protected abstract ResolveResult getRootURLContext(String url,
                                                   Hashtable env)
                                            throws NamingException
Resolves 'name' into a target context with remaining name. For example, with a JNDI URL "jndi://dnsname/rest_name", this method resolves "jndi://dnsname/" to a target context, and returns the target context with "rest_name". The definition of "root URL" and how much of the URL to consume is implementation specific. If rename() is supported for a particular URL scheme, getRootURLContext(), getURLPrefix(), and getURLSuffix() must be in sync wrt how URLs are parsed and returned.

Throws:
NamingException

getURLSuffix

protected Name getURLSuffix(String prefix,
                            String url)
                     throws NamingException
Returns the suffix of the url. The result should be identical to that of calling getRootURLContext().getRemainingName(), but without the overhead of doing anything with the prefix like creating a context.

This method returns a Name instead of a String because to give the provider an opportunity to return a Name (for example, for weakly separated naming systems like COS naming).

The default implementation uses skips 'prefix', calls UrlUtil.decode() on it, and returns the result as a single component CompositeName. Subclass should override if this is not appropriate. This method is used only by rename(). If rename() is supported for a particular URL scheme, getRootURLContext(), getURLPrefix(), and getURLSuffix() must be in sync wrt how URLs are parsed and returned.

For many URL schemes, this method is very similar to URL.getFile(), except getFile() will return a leading slash in the 2nd, 3rd, and 4th cases. For schemes like "ldap" and "iiop", the leading slash must be skipped before the name is an acceptable format for operation by the Context methods. For schemes that treat the leading slash as significant (such as "file"), the subclass must override getURLSuffix() to get the correct behavior. Remember, the behavior must match getRootURLContext(). URL Suffix foo://host:port foo://host:port/rest/of/name rest/of/name foo:///rest/of/name rest/of/name foo:/rest/of/name rest/of/name foo:rest/of/name rest/of/name

Throws:
NamingException

getURLPrefix

protected String getURLPrefix(String url)
                       throws NamingException
Finds the prefix of a URL. Default implementation looks for slashes and then extracts prefixes using String.substring(). Subclass should override if this is not appropriate. This method is used only by rename(). If rename() is supported for a particular URL scheme, getRootURLContext(), getURLPrefix(), and getURLSuffix() must be in sync wrt how URLs are parsed and returned.

URL Prefix foo://host:port foo://host:port foo://host:port/rest/of/name foo://host:port foo:///rest/of/name foo:// foo:/rest/of/name foo: foo:rest/of/name foo:

Throws:
NamingException

urlEquals

protected boolean urlEquals(String url1,
                            String url2)
Determines whether two URLs are the same. Default implementation uses String.equals(). Subclass should override if this is not appropriate. This method is used by rename().


getContinuationContext

protected Context getContinuationContext(Name n)
                                  throws NamingException
Gets the context in which to continue the operation. This method is called when this context is asked to process a multicomponent Name in which the first component is a URL. Treat the first component like a junction: resolve it and then use NamingManager.getContinuationContext() to get the target context in which to operate on the remainder of the name (n.getSuffix(1)).

Throws:
NamingException

lookup

public Object lookup(String name)
              throws NamingException
Specified by:
lookup in interface Context
Throws:
NamingException

lookup

public Object lookup(Name name)
              throws NamingException
Specified by:
lookup in interface Context
Throws:
NamingException

bind

public void bind(String name,
                 Object obj)
          throws NamingException
Specified by:
bind in interface Context
Throws:
NamingException

bind

public void bind(Name name,
                 Object obj)
          throws NamingException
Specified by:
bind in interface Context
Throws:
NamingException

rebind

public void rebind(String name,
                   Object obj)
            throws NamingException
Specified by:
rebind in interface Context
Throws:
NamingException

rebind

public void rebind(Name name,
                   Object obj)
            throws NamingException
Specified by:
rebind in interface Context
Throws:
NamingException

unbind

public void unbind(String name)
            throws NamingException
Specified by:
unbind in interface Context
Throws:
NamingException

unbind

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

rename

public void rename(String oldName,
                   String newName)
            throws NamingException
Specified by:
rename in interface Context
Throws:
NamingException

rename

public void rename(Name name,
                   Name newName)
            throws NamingException
Specified by:
rename in interface Context
Throws:
NamingException

list

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

list

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

listBindings

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

listBindings

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

destroySubcontext

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

destroySubcontext

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

createSubcontext

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

createSubcontext

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

lookupLink

public Object lookupLink(String name)
                  throws NamingException
Specified by:
lookupLink in interface Context
Throws:
NamingException

lookupLink

public Object lookupLink(Name name)
                  throws NamingException
Specified by:
lookupLink in interface Context
Throws:
NamingException

getNameParser

public NameParser getNameParser(String name)
                         throws NamingException
Specified by:
getNameParser in interface Context
Throws:
NamingException

getNameParser

public NameParser getNameParser(Name name)
                         throws NamingException
Specified by:
getNameParser in interface Context
Throws:
NamingException

composeName

public String composeName(String name,
                          String prefix)
                   throws NamingException
Specified by:
composeName in interface Context
Throws:
NamingException

composeName

public Name composeName(Name name,
                        Name prefix)
                 throws NamingException
Specified by:
composeName in interface Context
Throws:
NamingException

removeFromEnvironment

public Object removeFromEnvironment(String propName)
                             throws NamingException
Specified by:
removeFromEnvironment in interface Context
Throws:
NamingException

addToEnvironment

public Object addToEnvironment(String propName,
                               Object propVal)
                        throws NamingException
Specified by:
addToEnvironment in interface Context
Throws:
NamingException

getEnvironment

public Hashtable getEnvironment()
                         throws NamingException
Specified by:
getEnvironment in interface Context
Throws:
NamingException

aicas logo Jamaica 3.4 release 8

aicas GmbH, Karlsruhe - Germany    www.aicas.com
Copyright 2001-2009 aicas GmbH. All Rights Reserved.