Spring LDAP Framework

org.springframework.ldap.core.support
Class SingleContextSource

java.lang.Object
  extended by org.springframework.ldap.core.support.SingleContextSource
All Implemented Interfaces:
DisposableBean, ContextSource

public class SingleContextSource
extends Object
implements ContextSource, DisposableBean

A ContextSource to be used as a decorator around a target ContextSource to make sure the target is never actually closed. Useful when working with e.g. paged results, as these require the same target to be used.

Author:
Mattias Hellborg Arthursson

Nested Class Summary
static class SingleContextSource.NonClosingDirContextInvocationHandler
          A proxy for DirContext forwarding all operation to the target DirContext, but making sure that no close operations will be performed.
 
Constructor Summary
SingleContextSource(DirContext ctx)
          Constructor.
 
Method Summary
 void destroy()
          Destroy method that allows the target DirContext to be cleaned up when the SingleContextSource is not going to be used any more.
 DirContext getContext(String principal, String credentials)
          Gets a DirContext instance authenticated using the supplied principal and credentials.
 DirContext getReadOnlyContext()
          Gets a read-only DirContext.
 DirContext getReadWriteContext()
          Gets a read-write DirContext instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SingleContextSource

public SingleContextSource(DirContext ctx)
Constructor.

Parameters:
ctx - the target DirContext.
Method Detail

getReadOnlyContext

public DirContext getReadOnlyContext()
                              throws NamingException
Description copied from interface: ContextSource
Gets a read-only DirContext. The returned DirContext must be possible to perform read-only operations on.

Specified by:
getReadOnlyContext in interface ContextSource
Returns:
A DirContext instance, never null.
Throws:
NamingException - if some error occurs creating an DirContext.

getReadWriteContext

public DirContext getReadWriteContext()
                               throws NamingException
Description copied from interface: ContextSource
Gets a read-write DirContext instance.

Specified by:
getReadWriteContext in interface ContextSource
Returns:
A DirContext instance, never null.
Throws:
NamingException - if some error occurs creating an DirContext.

getContext

public DirContext getContext(String principal,
                             String credentials)
                      throws NamingException
Description copied from interface: ContextSource
Gets a DirContext instance authenticated using the supplied principal and credentials.

Specified by:
getContext in interface ContextSource
Parameters:
principal - The principal (typically a distinguished name of a user in the LDAP tree) to use for authentication.
credentials - The credentials to use for authentication.
Returns:
an authenticated DirContext instance, never null.
Throws:
NamingException

destroy

public void destroy()
Destroy method that allows the target DirContext to be cleaned up when the SingleContextSource is not going to be used any more.

Specified by:
destroy in interface DisposableBean

Spring LDAP Framework

Copyright © 2005-2010 The Spring LDAP Framework. All Rights Reserved.