Removed package dependency cycle.

This commit is contained in:
Ulrik Sandberg
2008-10-11 11:03:33 +00:00
parent 4b3c4aaad0
commit 8b99097cb1
4 changed files with 21 additions and 23 deletions

View File

@@ -14,7 +14,6 @@ import org.springframework.ldap.NamingException;
import org.springframework.ldap.core.ContextSource;
import org.springframework.ldap.core.DirContextProxy;
import org.springframework.ldap.support.LdapUtils;
import org.springframework.ldap.transaction.compensating.LdapTransactionUtils;
/**
* A {@link ContextSource} implementation using returning
@@ -104,7 +103,7 @@ public class SingleContextSource implements ContextSource {
private DirContext getNonClosingDirContextProxy(DirContext context) {
return (DirContext) Proxy.newProxyInstance(DirContextProxy.class
.getClassLoader(), new Class[] {
LdapTransactionUtils.getActualTargetClass(context),
LdapUtils.getActualTargetClass(context),
DirContextProxy.class },
new SingleContextSource.NonClosingDirContextInvocationHandler(
context));

View File

@@ -17,6 +17,7 @@
package org.springframework.ldap.support;
import javax.naming.directory.DirContext;
import javax.naming.ldap.LdapContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -206,4 +207,21 @@ public final class LdapUtils {
// fallback
return new org.springframework.ldap.UncategorizedLdapException(ex);
}
/**
* Get the actual class of the supplied DirContext instance; LdapContext or
* DirContext.
*
* @param context
* the DirContext instance to check.
* @return LdapContext.class if context is an LdapContext, DirContext.class
* otherwise.
*/
public static Class getActualTargetClass(DirContext context) {
if (context instanceof LdapContext) {
return LdapContext.class;
}
return DirContext.class;
}
}

View File

@@ -17,8 +17,6 @@
package org.springframework.ldap.transaction.compensating;
import javax.naming.Name;
import javax.naming.directory.DirContext;
import javax.naming.ldap.LdapContext;
import org.apache.commons.lang.StringUtils;
import org.springframework.ldap.core.DistinguishedName;
@@ -101,21 +99,4 @@ public final class LdapTransactionUtils {
.equals(methodName, UNBIND_METHOD_NAME));
}
/**
* Get the actual class of the supplied DirContext instance; LdapContext or
* DirContext.
*
* @param context
* the DirContext instance to check.
* @return LdapContext.class if context is an LdapContext, DirContext.class
* otherwise.
*/
public static Class getActualTargetClass(DirContext context) {
if (context instanceof LdapContext) {
return LdapContext.class;
}
return DirContext.class;
}
}

View File

@@ -22,7 +22,7 @@ import javax.naming.directory.DirContext;
import org.springframework.ldap.NamingException;
import org.springframework.ldap.core.ContextSource;
import org.springframework.ldap.core.DirContextProxy;
import org.springframework.ldap.transaction.compensating.LdapTransactionUtils;
import org.springframework.ldap.support.LdapUtils;
import org.springframework.transaction.support.TransactionSynchronizationManager;
/**
@@ -70,7 +70,7 @@ public class TransactionAwareContextSourceProxy implements ContextSource {
return (DirContext) Proxy
.newProxyInstance(DirContextProxy.class.getClassLoader(),
new Class[] {
LdapTransactionUtils
LdapUtils
.getActualTargetClass(context),
DirContextProxy.class },
new TransactionAwareDirContextInvocationHandler(