use of org.sakuli.datamodel.properties.SahiProxyProperties in project sakuli by ConSol.
the class ModifySahiTimerAspect method modifySahiTimer.
void modifySahiTimer(JoinPoint joinPoint, boolean beforeMethod) {
BaseActionLoader loader = BeanLoader.loadBaseActionLoader();
SahiProxyProperties sahiProxyProperties = loader.getSahiProxyProperties();
if (sahiProxyProperties != null && sahiProxyProperties.isRequestDelayActive()) {
RhinoScriptRunner rhinoScriptRunner = loader.getRhinoScriptRunner();
if (rhinoScriptRunner != null && rhinoScriptRunner.getSession() != null) {
getLogger(joinPoint).debug("MODIFY SAHI-TIMER for {}", getClassAndMethodAsString(joinPoint));
Session session = rhinoScriptRunner.getSession();
if (beforeMethod) {
Integer delay = determineDelay(joinPoint, loader);
session.setVariable(SahiProxyProperties.SAHI_REQUEST_DELAY_TIME_VAR, delay.toString());
//short sleep to ensure that browser context can read out the value
try {
logger.info("wait {}ms for sahi refresh", sahiProxyProperties.getRequestDelayRefreshMs());
Thread.sleep(sahiProxyProperties.getRequestDelayRefreshMs());
} catch (InterruptedException e) {
BeanLoader.loadBaseActionLoader().getExceptionHandler().handleException(e, true);
}
logger.info("sahi-proxy-timer modified to {} ms", delay.toString());
} else {
logger.info("reset sahi-proxy-timer");
session.setVariable(SahiProxyProperties.SAHI_REQUEST_DELAY_TIME_VAR, null);
}
}
}
}
Aggregations