Change LdapServerManager to be BaseLdapPathAware.

This commit is contained in:
Ulrik Sandberg
2008-01-13 21:47:08 +00:00
parent c2b0d538de
commit 9521c9be1f

View File

@@ -35,7 +35,7 @@ import org.apache.directory.server.protocol.shared.store.LdifFileLoader;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.ldap.core.ContextSource;
import org.springframework.ldap.core.DistinguishedName;
import org.springframework.ldap.core.support.DefaultDirObjectFactory;
import org.springframework.ldap.core.support.BaseLdapPathAware;
/**
* Utility class to initialize the apache directory server for use in the
@@ -44,15 +44,21 @@ import org.springframework.ldap.core.support.DefaultDirObjectFactory;
* @author Mattias Arthursson
*
*/
public class LdapServerManager implements DisposableBean {
public class LdapServerManager implements DisposableBean, BaseLdapPathAware {
private static Log log = LogFactory.getLog(LdapServerManager.class);
private ContextSource contextSource;
private DistinguishedName baseLdapPath;
public void setContextSource(ContextSource contextSource) {
this.contextSource = contextSource;
}
public void setBaseLdapPath(DistinguishedName baseLdapPath) {
this.baseLdapPath = baseLdapPath;
}
public void destroy() throws Exception {
Properties env = new Properties();
env.setProperty(Context.INITIAL_CONTEXT_FACTORY,
@@ -75,11 +81,10 @@ public class LdapServerManager implements DisposableBean {
// Different test cases have different base paths. This means that the
// starting point will be different.
if (ctx.getEnvironment().get(
DefaultDirObjectFactory.JNDI_ENV_BASE_PATH_KEY) != null) {
if (baseLdapPath.size() != 0) {
startingPoint = DistinguishedName.EMPTY_PATH;
} else {
startingPoint = new DistinguishedName("dc=jayway,dc=se");
startingPoint = new DistinguishedName(baseLdapPath);
}
try {