use of net.sf.sahi.Proxy in project sakuli by ConSol.
the class SahiProxy method startProxy.
/**
* Starts a seperate Thread for the sahi proxy.
* You can do a shutdown with
*
* @param asyncron init if a separate thread should started
* @throws SakuliInitException if the specified files in the sahi.properties are not valid
*/
public void startProxy(boolean asyncron) throws SakuliInitException, FileNotFoundException {
sahiProxy = new Proxy(props.getProxyPort());
if (Files.exists(props.getSahiHomeFolder()) && Files.exists(props.getSahiConfigFolder())) {
logger.info("START Sahi-PROXY: Sahi-Home folder '{}', Sahi-Configuration folder '{}'", props.getSahiHomeFolder().toAbsolutePath().toString(), props.getSahiConfigFolder().toAbsolutePath().toString());
try {
injectCustomJavaScriptFiles();
//set the custom paths to the sahi environment
Configuration.init(props.getSahiHomeFolder().toAbsolutePath().toString(), props.getSahiConfigFolder().toAbsolutePath().toString());
Configuration.setUnmodifiedTrafficLogging(false);
Configuration.setModifiedTrafficLogging(false);
//Starts the sahi proxy as asynchron Thread
sahiProxy.start(asyncron);
Thread.sleep(200);
} catch (RuntimeException e) {
logger.error("RUNTIME EXCEPTION");
throw new SakuliInitException(e);
} catch (Throwable e) {
logger.error("THROWABLE EXCEPTION");
throw new SakuliInitException(e.getMessage());
}
} else {
throw new FileNotFoundException("the path to '" + SahiProxyProperties.PROXY_HOME_FOLDER + "=" + props.getSahiHomeFolder().toAbsolutePath().toString() + "' or '" + SahiProxyProperties.PROXY_CONFIG_FOLDER + "=" + props.getSahiConfigFolder().toAbsolutePath().toString() + "' is not valid, please check the properties files!");
}
}
Aggregations