I'm trying to run ApacheDS instance from my java application.
I use such run()
method of ScriptWrapper class to execute script that is shipped with ApacheDS to run it:
public class ScriptWrapper implements Serializable {
private String scriptPath;
protected Process run(List<String> params) throws IOException {
LOGGER.debug("Executing script="+scriptPath);
params.add(0, scriptPath);
if(workDir != null) {
return Runtime.getRuntime().exec(params.toArray(new String[params.size()]), envp.toArray(new String[envp.size()]), new File(workDir));
} else {
return Runtime.getRuntime().exec(params.toArray(new String[params.size()]));
}
}
}
But the problem is, that when tomcat on which this app runs, is terminated and/or ScriptWrapper is garbage collected, the instance of ApacheDS also terminates. How to keep it alive?
EDIT: Thank you for your answers. I've decided to address the problem in different way and daemonized the process with script comming with binary ApacheDS installation.