Spring LDAP

org.springframework.ldap.transaction.compensating.manager
Class TransactionAwareContextSourceProxy

java.lang.Object
  extended by org.springframework.ldap.core.support.DelegatingBaseLdapPathContextSourceSupport
      extended by org.springframework.ldap.transaction.compensating.manager.TransactionAwareContextSourceProxy
All Implemented Interfaces:
ContextSource, BaseLdapPathSource

public class TransactionAwareContextSourceProxy
extends DelegatingBaseLdapPathContextSourceSupport
implements ContextSource

A proxy for ContextSource to make sure that the returned DirContext objects are aware of the surrounding transactions. This makes sure that the DirContext is not closed during the transaction and that all modifying operations are recorded, keeping track of the corresponding rollback operations. All returned DirContext instances will be of the type TransactionAwareDirContextInvocationHandler.

Since:
1.2
Author:
Mattias Hellborg Arthursson

Constructor Summary
TransactionAwareContextSourceProxy(ContextSource target)
          Constructor.
 
Method Summary
 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.
 ContextSource getTarget()
          Get the target ContextSource.
 
Methods inherited from class org.springframework.ldap.core.support.DelegatingBaseLdapPathContextSourceSupport
getBaseLdapName, getBaseLdapPath, getBaseLdapPathAsString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TransactionAwareContextSourceProxy

public TransactionAwareContextSourceProxy(ContextSource target)
Constructor.

Parameters:
target - the target ContextSource.
Method Detail

getTarget

public ContextSource getTarget()
Description copied from class: DelegatingBaseLdapPathContextSourceSupport
Get the target ContextSource.

Specified by:
getTarget in class DelegatingBaseLdapPathContextSourceSupport
Returns:
the target ContextSource.

getReadOnlyContext

public DirContext getReadOnlyContext()
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.

getReadWriteContext

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

Specified by:
getReadWriteContext in interface ContextSource
Returns:
A DirContext instance, never null.

getContext

public DirContext getContext(String principal,
                             String credentials)
Description copied from interface: ContextSource
Gets a DirContext instance authenticated using the supplied principal and credentials. Typically to be used for plain authentication purposes. Note that this method will never make use of native Java LDAP pooling, even though this instance is configured to do so. This is to force password changes in the target directory to take effect as soon as possible.

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.

Spring LDAP