use of org.structr.core.Services in project structr by structr.
the class StructrUiTest method start.
@BeforeClass
public static void start() throws Exception {
final long timestamp = System.currentTimeMillis();
basePath = "/tmp/structr-test-" + timestamp + "-" + System.nanoTime();
Settings.Services.setValue("NodeService HttpService SchemaService DirectoryWatchService");
Settings.ConnectionUrl.setValue(Settings.TestingConnectionUrl.getValue());
// example for new configuration setup
Settings.BasePath.setValue(basePath);
Settings.DatabasePath.setValue(basePath + "/db");
Settings.FilesPath.setValue(basePath + "/files");
Settings.RelationshipCacheSize.setValue(1000);
Settings.NodeCacheSize.setValue(1000);
Settings.SuperUserName.setValue("superadmin");
Settings.SuperUserPassword.setValue("sehrgeheim");
Settings.ApplicationTitle.setValue("structr unit test app" + timestamp);
Settings.ApplicationHost.setValue(host);
Settings.HttpPort.setValue(httpPort);
Settings.Servlets.setValue("JsonRestServlet WebSocketServlet HtmlServlet");
Settings.NodeCacheSize.setValue(10000);
Settings.RelationshipCacheSize.setValue(10000);
// Settings.LogSchemaOutput.setValue(true);
final Services services = Services.getInstance();
// wait for service layer to be initialized
do {
try {
Thread.sleep(100);
} catch (Throwable t) {
}
} while (!services.isInitialized());
securityContext = SecurityContext.getSuperUserInstance();
app = StructrApp.getInstance(securityContext);
graphDbCommand = app.command(GraphDatabaseCommand.class);
}
use of org.structr.core.Services in project structr by structr.
the class StructrApiModuleTest method startSystem.
@BeforeClass
public static void startSystem() {
final Date now = new Date();
final long timestamp = now.getTime();
basePath = "/tmp/structr-test-" + timestamp;
Settings.Services.setValue("NodeService LogService SchemaService HttpService");
Settings.ConnectionUrl.setValue(Settings.TestingConnectionUrl.getValue());
// example for new configuration setup
Settings.BasePath.setValue(basePath);
Settings.DatabasePath.setValue(basePath + "/db");
Settings.FilesPath.setValue(basePath + "/files");
Settings.RelationshipCacheSize.setValue(1000);
Settings.NodeCacheSize.setValue(1000);
Settings.SuperUserName.setValue("superadmin");
Settings.SuperUserPassword.setValue("sehrgeheim");
Settings.ApplicationTitle.setValue("structr unit test app" + timestamp);
Settings.ApplicationHost.setValue(host);
Settings.HttpPort.setValue(httpPort);
Settings.Servlets.setValue("JsonRestServlet");
final Services services = Services.getInstance();
// wait for service layer to be initialized
do {
try {
Thread.sleep(100);
} catch (Throwable t) {
}
} while (!services.isInitialized());
securityContext = SecurityContext.getSuperUserInstance();
app = StructrApp.getInstance(securityContext);
}
use of org.structr.core.Services in project structr by structr.
the class CronService method run.
@Override
public void run() {
final Services servicesInstance = Services.getInstance();
// wait for service layer to be initialized
while (!servicesInstance.isInitialized()) {
try {
Thread.sleep(1000);
} catch (InterruptedException iex) {
}
}
// sleep 5 seconds more
try {
Thread.sleep(5000);
} catch (InterruptedException iex) {
}
while (doRun) {
// sleep for some time
try {
Thread.sleep(GRANULARITY_UNIT.toMillis(GRANULARITY));
} catch (InterruptedException iex) {
}
for (CronEntry entry : cronEntries) {
if (entry.getDelayToNextExecutionInMillis() < GRANULARITY_UNIT.toMillis(GRANULARITY)) {
final String taskClassName = entry.getName();
final Class taskClass = instantiate(taskClassName);
try {
if (taskClass != null) {
Task task = (Task) taskClass.newInstance();
logger.debug("Starting task {}", taskClassName);
StructrApp.getInstance().processTasks(task);
} else {
try (final Tx tx = StructrApp.getInstance().tx()) {
// check for schema method with the given name
Actions.callAsSuperUser(taskClassName, Collections.EMPTY_MAP);
tx.success();
}
}
} catch (Throwable t) {
logger.warn("Exception while executing cron task {}: {}", taskClassName, t.getMessage());
}
}
}
}
}
use of org.structr.core.Services in project structr by structr.
the class TextSearchModuleTest method startSystem.
@BeforeClass
public static void startSystem() {
final Date now = new Date();
final long timestamp = now.getTime();
basePath = "/tmp/structr-test-" + timestamp;
Settings.Services.setValue("NodeService LogService SchemaService HttpService AgentService");
Settings.ConnectionUrl.setValue(Settings.TestingConnectionUrl.getValue());
// example for new configuration setup
Settings.BasePath.setValue(basePath);
Settings.DatabasePath.setValue(basePath + "/db");
Settings.FilesPath.setValue(basePath + "/files");
Settings.RelationshipCacheSize.setValue(1000);
Settings.NodeCacheSize.setValue(1000);
Settings.SuperUserName.setValue("superadmin");
Settings.SuperUserPassword.setValue("sehrgeheim");
Settings.ApplicationTitle.setValue("structr unit test app" + timestamp);
Settings.ApplicationHost.setValue(host);
Settings.HttpPort.setValue(httpPort);
Settings.Servlets.setValue("JsonRestServlet");
final Services services = Services.getInstance();
// wait for service layer to be initialized
do {
try {
Thread.sleep(100);
} catch (Throwable t) {
}
} while (!services.isInitialized());
securityContext = SecurityContext.getSuperUserInstance();
app = StructrApp.getInstance(securityContext);
}
use of org.structr.core.Services in project structr by structr.
the class StructrODFModuleTest method startSystem.
@BeforeClass
public static void startSystem() {
final Date now = new Date();
final long timestamp = now.getTime();
basePath = "/tmp/structr-test-" + timestamp;
Settings.Services.setValue("NodeService LogService SchemaService HttpService AgentService");
Settings.ConnectionUrl.setValue(Settings.TestingConnectionUrl.getValue());
// example for new configuration setup
Settings.BasePath.setValue(basePath);
Settings.DatabasePath.setValue(basePath + "/db");
Settings.FilesPath.setValue(basePath + "/files");
Settings.RelationshipCacheSize.setValue(1000);
Settings.NodeCacheSize.setValue(1000);
Settings.SuperUserName.setValue("superadmin");
Settings.SuperUserPassword.setValue("sehrgeheim");
Settings.ApplicationTitle.setValue("structr unit test app" + timestamp);
Settings.ApplicationHost.setValue(host);
Settings.HttpPort.setValue(httpPort);
Settings.Servlets.setValue("JsonRestServlet");
// Settings.LogSchemaOutput.setValue(true);
final Services services = Services.getInstance();
// wait for service layer to be initialized
do {
try {
Thread.sleep(100);
} catch (Throwable t) {
}
} while (!services.isInitialized());
securityContext = SecurityContext.getSuperUserInstance();
app = StructrApp.getInstance(securityContext);
}
Aggregations