use of org.opends.server.types.DirectoryEnvironmentConfig in project OpenAM by OpenRock.
the class EmbeddedOpenDS method startServer.
/**
* Starts the embedded <code>OpenDJ</code> instance.
*
* @param odsRoot File system directory where <code>OpenDJ</code>
* is installed.
* @throws Exception upon encountering errors.
*/
public static void startServer(String odsRoot) throws Exception {
if (isStarted()) {
return;
}
Debug debug = Debug.getInstance(SetupConstants.DEBUG_NAME);
debug.message("EmbeddedOpenDS.startServer(" + odsRoot + ")");
DirectoryEnvironmentConfig config = new DirectoryEnvironmentConfig();
config.setServerRoot(new File(odsRoot));
config.setForceDaemonThreads(true);
config.setConfigClass(ConfigFileHandler.class);
config.setConfigFile(new File(odsRoot + "/config", "config.ldif"));
debug.message("EmbeddedOpenDS.startServer:starting DS Server...");
EmbeddedUtils.startServer(config);
debug.message("...EmbeddedOpenDS.startServer:DS Server started.");
int sleepcount = 0;
while (!EmbeddedUtils.isRunning() && (sleepcount < 60)) {
sleepcount++;
SetupProgress.reportStart("emb.waitingforstarted", null);
Thread.sleep(1000);
}
if (EmbeddedUtils.isRunning()) {
SetupProgress.reportEnd("emb.success", null);
} else {
SetupProgress.reportEnd("emb.failed", null);
}
serverStarted = true;
ShutdownManager shutdownMan = com.sun.identity.common.ShutdownManager.getInstance();
shutdownMan.addShutdownListener(new ShutdownListener() {
public void shutdown() {
try {
shutdownServer("Graceful Shutdown");
} catch (Exception ex) {
Debug debug = Debug.getInstance(SetupConstants.DEBUG_NAME);
debug.error("EmbeddedOpenDS:shutdown hook failed", ex);
}
}
}, ShutdownPriority.LOWEST);
}
use of org.opends.server.types.DirectoryEnvironmentConfig in project midpoint by Evolveum.
the class OpenDJController method start.
/**
* Start the embedded OpenDJ directory server.
*
* Configuration and databases from serverRoot location will be used.
*
* @return
*/
public InternalClientConnection start() {
LOGGER.info("Starting OpenDJ server");
DirectoryEnvironmentConfig envConfig = new DirectoryEnvironmentConfig();
try {
envConfig.setServerRoot(serverRoot);
envConfig.setConfigFile(configFile);
// envConfig.setDisableConnectionHandlers(true);
} catch (InitializationException ex) {
ex.printStackTrace();
throw new RuntimeException("OpenDJ initialization failed", ex);
}
// Check if the server is already running
if (EmbeddedUtils.isRunning()) {
throw new RuntimeException("Server already running");
} else {
try {
EmbeddedUtils.startServer(envConfig);
} catch (ConfigException ex) {
LOGGER.error("Possible OpenDJ misconfiguration: " + ex.getMessage(), ex);
throw new RuntimeException("OpenDJ startup failed", ex);
} catch (InitializationException ex) {
LOGGER.error("OpenDJ startup failed", ex);
throw new RuntimeException("OpenDJ startup failed", ex);
}
}
internalConnection = InternalClientConnection.getRootConnection();
if (internalConnection == null) {
LOGGER.error("OpenDJ cannot get internal connection (null)");
throw new RuntimeException("OpenDS cannot get internal connection (null)");
}
LOGGER.info("OpenDJ server started");
return internalConnection;
}
Aggregations