public void embeddedServerProgrammatic() throws Exception {
File homeDir = util.createTempDir("orientdb-home").getCanonicalFile();
System.setProperty("orient.home", homeDir.getPath());
System.setProperty(Orient.ORIENTDB_HOME, homeDir.getPath());
OServer server = new OServer();
OServerConfiguration config = new OServerConfiguration();
// Unsure what this is used for, its apparently assigned to xml location, but forcing it here
config.location = "DYNAMIC-CONFIGURATION";
File databaseDir = new File(homeDir, "db");
config.properties = new OServerEntryConfiguration[] {
new OServerEntryConfiguration("server.database.path", databaseDir.getPath())
};
config.handlers = Lists.newArrayList();
config.hooks = Lists.newArrayList();
config.network = new OServerNetworkConfiguration();
config.network.protocols = Lists.newArrayList(
new OServerNetworkProtocolConfiguration("binary", ONetworkProtocolBinary.class.getName())
);
OServerNetworkListenerConfiguration binaryListener = new OServerNetworkListenerConfiguration();
binaryListener.ipAddress = "0.0.0.0";
binaryListener.portRange = "2424-2430";
binaryListener.protocol = "binary";
binaryListener.socket = "default";
config.network.listeners = Lists.newArrayList(
binaryListener
);
config.storages = new OServerStorageConfiguration[] {};
config.users = new OServerUserConfiguration[] {
new OServerUserConfiguration("admin", "admin", "*")
};
config.security = new OServerSecurityConfiguration();
config.security.users = Lists.newArrayList();
config.security.resources = Lists.newArrayList();
server.startup(config);
// Dump config to log stream
StringWriter buff = new StringWriter();
OGlobalConfiguration.dumpConfiguration(new PrintStream(new WriterOutputStream(buff), true));
log("Global configuration:\n{}", buff);
server.activate();
server.shutdown();
}