use of org.jumpmind.symmetric.web.SymmetricEngineHolder in project symmetric-ds by JumpMind.
the class SymmetricWebServer method getEngine.
public ISymmetricEngine getEngine() {
ISymmetricEngine engine = null;
ServletContext servletContext = getServletContext();
if (servletContext != null) {
SymmetricEngineHolder engineHolder = ServletUtils.getSymmetricEngineHolder(servletContext);
if (engineHolder != null) {
if (engineHolder.getEngines().size() == 1) {
return engineHolder.getEngines().values().iterator().next();
} else {
throw new IllegalStateException("Could not choose a single engine to return. There are " + engineHolder.getEngines().size() + " engines configured.");
}
}
}
return engine;
}
use of org.jumpmind.symmetric.web.SymmetricEngineHolder in project symmetric-ds by JumpMind.
the class SymmetricWebServer method getEngine.
public ISymmetricEngine getEngine(String name) {
ISymmetricEngine engine = null;
ServletContext servletContext = getServletContext();
if (servletContext != null) {
SymmetricEngineHolder engineHolder = ServletUtils.getSymmetricEngineHolder(servletContext);
if (engineHolder != null) {
return engineHolder.getEngines().get(name);
}
}
return engine;
}
use of org.jumpmind.symmetric.web.SymmetricEngineHolder in project symmetric-ds by JumpMind.
the class SymmetricWebServer method waitForEnginesToComeOnline.
public void waitForEnginesToComeOnline(long maxWaitTimeInMs) throws InterruptedException {
long startTime = System.currentTimeMillis();
ServletContext servletContext = getServletContext();
if (servletContext != null) {
SymmetricEngineHolder engineHolder = ServletUtils.getSymmetricEngineHolder(servletContext);
while (engineHolder.areEnginesStarting()) {
AppUtils.sleep(500);
if ((System.currentTimeMillis() - startTime) > maxWaitTimeInMs) {
throw new InterruptedException("Timed out waiting for engines to start");
}
}
}
}
use of org.jumpmind.symmetric.web.SymmetricEngineHolder in project symmetric-ds by JumpMind.
the class RestService method getSymmetricEngine.
protected ISymmetricEngine getSymmetricEngine() {
ISymmetricEngine engine = null;
SymmetricEngineHolder holder = getSymmetricEngineHolder();
if (holder.getEngines().size() > 0) {
engine = holder.getEngines().values().iterator().next();
}
if (engine == null) {
throw new NotAllowedException();
} else if (!engine.getParameterService().is(ParameterConstants.REST_API_ENABLED)) {
throw new NotAllowedException("The REST API was not enabled for %s", engine.getEngineName());
} else {
return engine;
}
}
use of org.jumpmind.symmetric.web.SymmetricEngineHolder in project symmetric-ds by JumpMind.
the class RestService method getSymmetricEngine.
protected ISymmetricEngine getSymmetricEngine(String engineName) {
SymmetricEngineHolder holder = getSymmetricEngineHolder();
ISymmetricEngine engine = null;
if (StringUtils.isNotBlank(engineName)) {
engine = holder.getEngines().get(engineName);
}
if (engine == null) {
throw new NotFoundException();
} else if (!engine.getParameterService().is(ParameterConstants.REST_API_ENABLED)) {
throw new NotAllowedException("The REST API was not enabled for %s", engine.getEngineName());
} else {
MDC.put("engineName", engine.getEngineName());
return engine;
}
}
Aggregations