aicas logo Jamaica 3.4 release 8

com.sun.jndi.ldap
Class LdapCtx

java.lang.Object
  extended by com.sun.jndi.toolkit.ctx.PartialCompositeContext
      extended by com.sun.jndi.toolkit.ctx.ComponentContext
          extended by com.sun.jndi.toolkit.ctx.AtomicContext
              extended by com.sun.jndi.toolkit.ctx.PartialCompositeDirContext
                  extended by com.sun.jndi.toolkit.ctx.ComponentDirContext
                      extended by com.sun.jndi.ldap.LdapCtx
All Implemented Interfaces:
Context, DirContext, EventContext, EventDirContext, LdapContext, Resolver

public final class LdapCtx
extends ComponentDirContext
implements EventDirContext, LdapContext

The LDAP context implementation. Implementation is not thread-safe. Caller must sync as per JNDI spec. Members that are used directly or indirectly by internal worker threads (Connection, EventQueue, NamingEventNotifier) must be thread-safe. Connection - calls LdapClient.processUnsolicited(), which in turn calls LdapCtx.convertControls() and LdapCtx.fireUnsolicited(). convertControls() - no sync; reads envprops and 'this' fireUnsolicited() - sync on eventSupport for all references to 'unsolicited' (even those in other methods); don't sync on LdapCtx in case caller is already sync'ing on it - this would prevent Unsol events from firing and the Connection thread to block (thus preventing any other data from being read from the connection) References to 'eventSupport' need not be sync'ed because these methods can only be called after eventSupport has been set first (via addNamingListener()). EventQueue - no direct or indirect calls to LdapCtx NamingEventNotifier - calls newInstance() to get instance for run() to use; no sync needed for methods invoked on new instance; LdapAttribute links to LdapCtx in order to process getAttributeDefinition() and getAttributeSyntaxDefinition() calls. It invokes LdapCtx.getSchema(), which uses schemaTrees (a Hashtable - already sync). Potential conflict of duplicating construction of tree for same subschemasubentry but no inconsistency problems. NamingEnumerations link to LdapCtx for the following: 1. increment/decrement enum count so that ctx doesn't close the underlying connection 2. LdapClient handle to get next batch of results 3. Sets LdapCtx's response controls 4. Process return code 5. For narrowing response controls (using ctx's factories) Since processing of NamingEnumeration by client is treated the same as method invocation on LdapCtx, caller is responsible for locking.


Field Summary
static String DEFAULT_HOST
           
static int DEFAULT_PORT
           
static int DEFAULT_SSL_PORT
           
 
Fields inherited from class com.sun.jndi.toolkit.ctx.ComponentContext
TERMINAL_COMPONENT, TERMINAL_NNS_COMPONENT, USE_CONTINUATION
 
Fields inherited from class com.sun.jndi.toolkit.ctx.PartialCompositeContext
_ATOMIC, _COMPONENT, _contextType, _PARTIAL
 
Fields inherited from interface javax.naming.event.EventContext
OBJECT_SCOPE, ONELEVEL_SCOPE, SUBTREE_SCOPE
 
Fields inherited from interface javax.naming.ldap.LdapContext
CONTROL_FACTORIES
 
Fields inherited from interface javax.naming.directory.DirContext
ADD_ATTRIBUTE, REMOVE_ATTRIBUTE, REPLACE_ATTRIBUTE
 
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
LdapCtx(String dn, String host, int port_number, Hashtable props, boolean useSsl)
           
 
Method Summary
 void addNamingListener(Name nm, int scope, NamingListener l)
           
 void addNamingListener(Name nm, String filter, Object[] filterArgs, SearchControls ctls, NamingListener l)
           
 void addNamingListener(Name nm, String filter, SearchControls ctls, NamingListener l)
           
 void addNamingListener(String nm, int scope, NamingListener l)
           
 void addNamingListener(String nm, String filterExpr, Object[] filterArgs, SearchControls ctls, NamingListener l)
           
 void addNamingListener(String nm, String filter, SearchControls ctls, NamingListener l)
           
 Object addToEnvironment(String propName, Object propVal)
           
protected  void c_bind(Name name, Object obj, Attributes attrs, Continuation cont)
           
protected  void c_bind(Name name, Object obj, Continuation cont)
           
protected  DirContext c_createSubcontext(Name name, Attributes attrs, Continuation cont)
           
protected  Context c_createSubcontext(Name name, Continuation cont)
           
protected  void c_destroySubcontext(Name name, Continuation cont)
           
protected  Attributes c_getAttributes(Name name, String[] attrIds, Continuation cont)
           
protected  NameParser c_getNameParser(Name name, Continuation cont)
           
protected  DirContext c_getSchema(Name name, Continuation cont)
           
protected  DirContext c_getSchemaClassDefinition(Name name, Continuation cont)
           
protected  NamingEnumeration c_list(Name name, Continuation cont)
           
protected  NamingEnumeration c_listBindings(Name name, Continuation cont)
           
protected  Object c_lookup(Name name, Continuation cont)
           
protected  Object c_lookupLink(Name name, Continuation cont)
           
protected  void c_modifyAttributes(Name name, int mod_op, Attributes attrs, Continuation cont)
           
protected  void c_modifyAttributes(Name name, ModificationItem[] mods, Continuation cont)
           
protected  void c_rebind(Name name, Object obj, Attributes attrs, Continuation cont)
           
protected  void c_rebind(Name name, Object obj, Continuation cont)
           
protected  void c_rename(Name oldName, Name newName, Continuation cont)
           
protected  NamingEnumeration c_search(Name name, Attributes matchingAttributes, Continuation cont)
           
protected  NamingEnumeration c_search(Name name, Attributes matchingAttributes, String[] attributesToReturn, Continuation cont)
           
protected  NamingEnumeration c_search(Name name, String filterExpr, Object[] filterArgs, SearchControls cons, Continuation cont)
           
protected  NamingEnumeration c_search(Name name, String filter, SearchControls cons, Continuation cont)
           
protected  void c_unbind(Name name, Continuation cont)
           
 void close()
           
 Name composeName(Name name, Name prefix)
          This default implementation simply concatenates the two names.
 ExtendedResponse extendedOperation(ExtendedRequest request)
           
protected  void finalize()
          finalize may be called by the memory management of the virtual machine when it determined that this instance's memory is unreachable and can be reclaimed.
 Control[] getConnectControls()
           
 Hashtable getEnvironment()
           
 String getNameInNamespace()
           
 Control[] getRequestControls()
           
 Control[] getResponseControls()
           
static NamingException mapErrorCode(int errorCode, String errorMessage)
          Maps an LDAP error code to an appropriate NamingException. %%% public; used by controls
 LdapContext newInstance(Control[] reqCtls)
           
protected  Hashtable p_getEnvironment()
          Override with noncloning version.
protected  void processReturnCode(LdapResult answer)
           
protected  void processReturnCode(LdapResult res, Name resolvedName, Object resolvedObj, Name remainName, Hashtable envprops, String fullDN)
           
 void reconnect(Control[] connCtls)
           
 Object removeFromEnvironment(String propName)
           
 void removeNamingListener(NamingListener l)
           
 void setRequestControls(Control[] reqCtls)
           
 boolean targetMustExist()
           
 
Methods inherited from class com.sun.jndi.toolkit.ctx.ComponentDirContext
c_bind_nns, c_createSubcontext_nns, c_getAttributes_nns, c_getSchema_nns, c_getSchemaClassDefinition_nns, c_modifyAttributes_nns, c_modifyAttributes_nns, c_rebind_nns, c_search_nns, c_search_nns, c_search_nns, p_bind, p_createSubcontext, p_getAttributes, p_getSchema, p_getSchemaClassDefinition, p_modifyAttributes, p_modifyAttributes, p_rebind, p_search, p_search, p_search
 
Methods inherited from class com.sun.jndi.toolkit.ctx.PartialCompositeDirContext
a_bind, a_createSubcontext, a_destroySubcontext, a_getNameParser, a_list, a_listBindings, a_lookup, a_lookupLink, a_rebind, a_rename, a_unbind, bind, bind, c_parseComponent, createSubcontext, createSubcontext, getAttributes, getAttributes, getAttributes, getAttributes, getPCDirContext, getSchema, getSchema, getSchemaClassDefinition, getSchemaClassDefinition, modifyAttributes, modifyAttributes, modifyAttributes, modifyAttributes, rebind, rebind, search, search, search, search, search, search, search, search
 
Methods inherited from class com.sun.jndi.toolkit.ctx.AtomicContext
a_bind_nns, a_createSubcontext_nns, a_destroySubcontext_nns, a_getNameParser_nns, a_list_nns, a_listBindings_nns, a_lookup_nns, a_lookupLink_nns, a_processJunction_nns, a_processJunction_nns, a_rebind_nns, a_rename_nns, a_resolveIntermediate_nns, a_unbind_nns, c_bind_nns, c_createSubcontext_nns, c_destroySubcontext_nns, c_getNameParser_nns, c_list_nns, c_listBindings_nns, c_lookup_nns, c_lookupLink_nns, c_rebind_nns, c_rename_nns, c_resolveIntermediate_nns, c_unbind_nns, isEmpty, resolve_to_context, resolve_to_nns_and_continue, resolve_to_penultimate_context_nns, resolve_to_penultimate_context
 
Methods inherited from class com.sun.jndi.toolkit.ctx.ComponentContext
c_processJunction_nns, isAllEmpty, p_bind, p_createSubcontext, p_destroySubcontext, p_getNameParser, p_list, p_listBindings, p_lookup, p_lookupLink, p_parseComponent, p_rebind, p_rename, p_resolveIntermediate, p_resolveToClass, p_unbind
 
Methods inherited from class com.sun.jndi.toolkit.ctx.PartialCompositeContext
allEmpty, bind, bind, composeName, createSubcontext, createSubcontext, destroySubcontext, destroySubcontext, getNameParser, getNameParser, getPCContext, list, list, listBindings, listBindings, lookup, lookup, lookupLink, lookupLink, rebind, rebind, rename, rename, resolveToClass, resolveToClass, unbind, unbind
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.naming.directory.DirContext
bind, bind, createSubcontext, createSubcontext, getAttributes, getAttributes, getAttributes, getAttributes, getSchema, getSchema, getSchemaClassDefinition, getSchemaClassDefinition, modifyAttributes, modifyAttributes, modifyAttributes, modifyAttributes, rebind, rebind, search, search, search, search, search, search, search, search
 
Methods inherited from interface javax.naming.Context
bind, bind, composeName, createSubcontext, createSubcontext, destroySubcontext, destroySubcontext, getNameParser, getNameParser, list, list, listBindings, listBindings, lookup, lookup, lookupLink, lookupLink, rebind, rebind, rename, rename, unbind, unbind
 
Methods inherited from interface javax.naming.spi.Resolver
resolveToClass, resolveToClass
 

Field Detail

DEFAULT_PORT

public static final int DEFAULT_PORT
See Also:
Constant Field Values

DEFAULT_SSL_PORT

public static final int DEFAULT_SSL_PORT
See Also:
Constant Field Values

DEFAULT_HOST

public static final String DEFAULT_HOST
See Also:
Constant Field Values
Constructor Detail

LdapCtx

public LdapCtx(String dn,
               String host,
               int port_number,
               Hashtable props,
               boolean useSsl)
        throws NamingException
Throws:
NamingException
Method Detail

newInstance

public LdapContext newInstance(Control[] reqCtls)
                        throws NamingException
Specified by:
newInstance in interface LdapContext
Throws:
NamingException

c_bind

protected void c_bind(Name name,
                      Object obj,
                      Continuation cont)
               throws NamingException
Overrides:
c_bind in class AtomicContext
Throws:
NamingException

c_bind

protected void c_bind(Name name,
                      Object obj,
                      Attributes attrs,
                      Continuation cont)
               throws NamingException
Specified by:
c_bind in class ComponentDirContext
Throws:
NamingException

c_rebind

protected void c_rebind(Name name,
                        Object obj,
                        Continuation cont)
                 throws NamingException
Overrides:
c_rebind in class AtomicContext
Throws:
NamingException

c_rebind

protected void c_rebind(Name name,
                        Object obj,
                        Attributes attrs,
                        Continuation cont)
                 throws NamingException
Specified by:
c_rebind in class ComponentDirContext
Throws:
NamingException

c_unbind

protected void c_unbind(Name name,
                        Continuation cont)
                 throws NamingException
Overrides:
c_unbind in class AtomicContext
Throws:
NamingException

c_rename

protected void c_rename(Name oldName,
                        Name newName,
                        Continuation cont)
                 throws NamingException
Overrides:
c_rename in class AtomicContext
Throws:
NamingException

c_createSubcontext

protected Context c_createSubcontext(Name name,
                                     Continuation cont)
                              throws NamingException
Overrides:
c_createSubcontext in class AtomicContext
Throws:
NamingException

c_createSubcontext

protected DirContext c_createSubcontext(Name name,
                                        Attributes attrs,
                                        Continuation cont)
                                 throws NamingException
Specified by:
c_createSubcontext in class ComponentDirContext
Throws:
NamingException

c_destroySubcontext

protected void c_destroySubcontext(Name name,
                                   Continuation cont)
                            throws NamingException
Overrides:
c_destroySubcontext in class AtomicContext
Throws:
NamingException

c_lookupLink

protected Object c_lookupLink(Name name,
                              Continuation cont)
                       throws NamingException
Overrides:
c_lookupLink in class AtomicContext
Throws:
NamingException

c_lookup

protected Object c_lookup(Name name,
                          Continuation cont)
                   throws NamingException
Overrides:
c_lookup in class AtomicContext
Throws:
NamingException

c_list

protected NamingEnumeration c_list(Name name,
                                   Continuation cont)
                            throws NamingException
Overrides:
c_list in class AtomicContext
Throws:
NamingException

c_listBindings

protected NamingEnumeration c_listBindings(Name name,
                                           Continuation cont)
                                    throws NamingException
Overrides:
c_listBindings in class AtomicContext
Throws:
NamingException

c_getNameParser

protected NameParser c_getNameParser(Name name,
                                     Continuation cont)
                              throws NamingException
Overrides:
c_getNameParser in class AtomicContext
Throws:
NamingException

getNameInNamespace

public String getNameInNamespace()
Specified by:
getNameInNamespace in interface Context

composeName

public Name composeName(Name name,
                        Name prefix)
                 throws NamingException
Description copied from class: PartialCompositeContext
This default implementation simply concatenates the two names. There's one twist when the "java.naming.provider.compose.elideEmpty" environment setting is set to "true": if each name contains a nonempty component, and if 'prefix' ends with an empty component or 'name' starts with one, then one empty component is dropped. For example:
                            elideEmpty=false     elideEmpty=true
 {"a"} + {"b"}          =>  {"a", "b"}           {"a", "b"}
 {"a"} + {""}           =>  {"a", ""}            {"a", ""}
 {"a"} + {"", "b"}      =>  {"a", "", "b"}       {"a", "b"}
 {"a", ""} + {"b", ""}  =>  {"a", "", "b", ""}   {"a", "b", ""}
 {"a", ""} + {"", "b"}  =>  {"a", "", "", "b"}   {"a", "", "b"}
 

Specified by:
composeName in interface Context
Overrides:
composeName in class PartialCompositeContext
Throws:
NamingException

c_getAttributes

protected Attributes c_getAttributes(Name name,
                                     String[] attrIds,
                                     Continuation cont)
                              throws NamingException
Specified by:
c_getAttributes in class ComponentDirContext
Throws:
NamingException

c_modifyAttributes

protected void c_modifyAttributes(Name name,
                                  int mod_op,
                                  Attributes attrs,
                                  Continuation cont)
                           throws NamingException
Specified by:
c_modifyAttributes in class ComponentDirContext
Throws:
NamingException

c_modifyAttributes

protected void c_modifyAttributes(Name name,
                                  ModificationItem[] mods,
                                  Continuation cont)
                           throws NamingException
Specified by:
c_modifyAttributes in class ComponentDirContext
Throws:
NamingException

c_getSchema

protected DirContext c_getSchema(Name name,
                                 Continuation cont)
                          throws NamingException
Specified by:
c_getSchema in class ComponentDirContext
Throws:
NamingException

c_getSchemaClassDefinition

protected DirContext c_getSchemaClassDefinition(Name name,
                                                Continuation cont)
                                         throws NamingException
Specified by:
c_getSchemaClassDefinition in class ComponentDirContext
Throws:
NamingException

c_search

protected NamingEnumeration c_search(Name name,
                                     Attributes matchingAttributes,
                                     Continuation cont)
                              throws NamingException
Throws:
NamingException

c_search

protected NamingEnumeration c_search(Name name,
                                     Attributes matchingAttributes,
                                     String[] attributesToReturn,
                                     Continuation cont)
                              throws NamingException
Specified by:
c_search in class ComponentDirContext
Throws:
NamingException

c_search

protected NamingEnumeration c_search(Name name,
                                     String filter,
                                     SearchControls cons,
                                     Continuation cont)
                              throws NamingException
Specified by:
c_search in class ComponentDirContext
Throws:
NamingException

c_search

protected NamingEnumeration c_search(Name name,
                                     String filterExpr,
                                     Object[] filterArgs,
                                     SearchControls cons,
                                     Continuation cont)
                              throws NamingException
Specified by:
c_search in class ComponentDirContext
Throws:
NamingException

p_getEnvironment

protected Hashtable p_getEnvironment()
Override with noncloning version.

Overrides:
p_getEnvironment in class PartialCompositeContext
Returns:
The possibly null environment of the context.

getEnvironment

public Hashtable getEnvironment()
                         throws NamingException
Specified by:
getEnvironment 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

finalize

protected void finalize()
Description copied from class: Object
finalize may be called by the memory management of the virtual machine when it determined that this instance's memory is unreachable and can be reclaimed.

NOTE: The use of finalize() is strongly discouraged for realtime or safety-critical code. This method should only be used for debugging purposes. If used as a last resort to reclaim non-memory resouces, finalize() should indicate the resource leak with a loud error message.

There is no guarantee that finalize() will be called, the memory management may decide not to reclaim this object's memory or to delay the call to finalize() to an unspecified point in time. It is therefore recommended never to use the finalize method to release any resources (files, network connections, non-Java memory, etc.) since releasing of these resource may be delayed perpetually.

The order of finalization is not specified, i.e., the finalize method of any two objects that become unreachable may be called in an arbitrary order. It therefore has to be assumed that when finalize() is called on an object, that the finalize() method of any object that is only reachable through this object() has been called as well or is called simultaneously by another thread.

The presence of a finalize-method in any sub-class of Object causes the reclamation of the memory of this object to be delayed until the finalize() method has been executed. The finalize() method is typically executed by the finalizer thread (that may run at a low priority) or by a call to Runtime.runFinalization().

Any code sequence that creates instances of a class that defines a finalize() method must therefore ensure that sufficient CPU time is allocated to the finalizer thread or that Runtime.runFinalization() is called regularly such that the finalize() methods can be executed and the object's memory can be reclaimed.

The finalize method itself should never block or run for long times since it would otherwise block the finalizer thread or the thread that called Runtime.runFinalization() and prevent the execution other finalize() method and consequently prevent the reclamation of these object's memory.

For objects that are allocated in a javax.realtime.ScopedMemory, the finalize() methods will be called when this scoped memory is exited by the last thread. Unlike HeapMemory, which is controlled by the garbage collector, ScopedMemory provides a defined execution point for the finalize() mehods and it is therefore safer to use finalize() here.

Overrides:
finalize in class Object

close

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

reconnect

public void reconnect(Control[] connCtls)
               throws NamingException
Specified by:
reconnect in interface LdapContext
Throws:
NamingException

processReturnCode

protected void processReturnCode(LdapResult answer)
                          throws NamingException
Throws:
NamingException

processReturnCode

protected void processReturnCode(LdapResult res,
                                 Name resolvedName,
                                 Object resolvedObj,
                                 Name remainName,
                                 Hashtable envprops,
                                 String fullDN)
                          throws NamingException
Throws:
NamingException

mapErrorCode

public static NamingException mapErrorCode(int errorCode,
                                           String errorMessage)
Maps an LDAP error code to an appropriate NamingException. %%% public; used by controls

Parameters:
errorCode - numeric LDAP error code
errorMessage - textual description of the LDAP error. May be null.
Returns:
A NamingException or null if the error code indicates success.

extendedOperation

public ExtendedResponse extendedOperation(ExtendedRequest request)
                                   throws NamingException
Specified by:
extendedOperation in interface LdapContext
Throws:
NamingException

setRequestControls

public void setRequestControls(Control[] reqCtls)
                        throws NamingException
Specified by:
setRequestControls in interface LdapContext
Throws:
NamingException

getRequestControls

public Control[] getRequestControls()
                             throws NamingException
Specified by:
getRequestControls in interface LdapContext
Throws:
NamingException

getConnectControls

public Control[] getConnectControls()
                             throws NamingException
Specified by:
getConnectControls in interface LdapContext
Throws:
NamingException

getResponseControls

public Control[] getResponseControls()
                              throws NamingException
Specified by:
getResponseControls in interface LdapContext
Throws:
NamingException

addNamingListener

public void addNamingListener(Name nm,
                              int scope,
                              NamingListener l)
                       throws NamingException
Specified by:
addNamingListener in interface EventContext
Throws:
NamingException

addNamingListener

public void addNamingListener(String nm,
                              int scope,
                              NamingListener l)
                       throws NamingException
Specified by:
addNamingListener in interface EventContext
Throws:
NamingException

removeNamingListener

public void removeNamingListener(NamingListener l)
                          throws NamingException
Specified by:
removeNamingListener in interface EventContext
Throws:
NamingException

addNamingListener

public void addNamingListener(String nm,
                              String filter,
                              SearchControls ctls,
                              NamingListener l)
                       throws NamingException
Specified by:
addNamingListener in interface EventDirContext
Throws:
NamingException

addNamingListener

public void addNamingListener(Name nm,
                              String filter,
                              SearchControls ctls,
                              NamingListener l)
                       throws NamingException
Specified by:
addNamingListener in interface EventDirContext
Throws:
NamingException

addNamingListener

public void addNamingListener(Name nm,
                              String filter,
                              Object[] filterArgs,
                              SearchControls ctls,
                              NamingListener l)
                       throws NamingException
Specified by:
addNamingListener in interface EventDirContext
Throws:
NamingException

addNamingListener

public void addNamingListener(String nm,
                              String filterExpr,
                              Object[] filterArgs,
                              SearchControls ctls,
                              NamingListener l)
                       throws NamingException
Specified by:
addNamingListener in interface EventDirContext
Throws:
NamingException

targetMustExist

public boolean targetMustExist()
Specified by:
targetMustExist in interface EventContext

aicas logo Jamaica 3.4 release 8

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