Well, I think I figured it out. You get the ApacheDSContainer from the context, and call its destroy() (which calls stop and destroys the workingDir). Then you call afterPropertiesSet() (which creates the workingDir and then also calls start()). It appears to work quite well. I do this whenever I see the file changes. I used an org.apache.commons.io.monitor.FileAlterationListener to watch the .ldif file, which fires the onFileChange() at the appropriate time.
import org.springframework.security.config.BeanIds;
import org.springframework.security.ldap.server.ApacheDSContainer;
...
public void onFileChange(File file) {
ApplicationContext ctx = ContextLoader.getCurrentWebApplicationContext();
if (ctx == null)
return;
ApacheDSContainer container = (ApacheDSContainer)ctx.getBean(BeanIds.EMBEDDED_APACHE_DS);
if (container != null) {
try {
container.destroy();
container.afterPropertiesSet();
}
catch(Exception exec) {
// handle error
}
}
}