Search in sources :

Example 1 with SymmetricEngineHolder

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;
}
Also used : ServletContext(javax.servlet.ServletContext) SymmetricEngineHolder(org.jumpmind.symmetric.web.SymmetricEngineHolder)

Example 2 with SymmetricEngineHolder

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;
}
Also used : ServletContext(javax.servlet.ServletContext) SymmetricEngineHolder(org.jumpmind.symmetric.web.SymmetricEngineHolder)

Example 3 with SymmetricEngineHolder

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");
            }
        }
    }
}
Also used : ServletContext(javax.servlet.ServletContext) SymmetricEngineHolder(org.jumpmind.symmetric.web.SymmetricEngineHolder)

Example 4 with SymmetricEngineHolder

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;
    }
}
Also used : ISymmetricEngine(org.jumpmind.symmetric.ISymmetricEngine) SymmetricEngineHolder(org.jumpmind.symmetric.web.SymmetricEngineHolder)

Example 5 with SymmetricEngineHolder

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;
    }
}
Also used : ISymmetricEngine(org.jumpmind.symmetric.ISymmetricEngine) SymmetricEngineHolder(org.jumpmind.symmetric.web.SymmetricEngineHolder)

Aggregations

SymmetricEngineHolder (org.jumpmind.symmetric.web.SymmetricEngineHolder)5 ServletContext (javax.servlet.ServletContext)3 ISymmetricEngine (org.jumpmind.symmetric.ISymmetricEngine)2