use of org.apache.jmeter.util.BeanShellServer in project jmeter by apache.
the class JMeter method startOptionalServers.
/**
*
*/
private void startOptionalServers() {
// $NON-NLS-1$
int bshport = JMeterUtils.getPropDefault("beanshell.server.port", 0);
// $NON-NLS-1$ $NON-NLS-2$
String bshfile = JMeterUtils.getPropDefault("beanshell.server.file", "");
if (bshport > 0) {
log.info("Starting Beanshell server ({},{})", bshport, bshfile);
Runnable t = new BeanShellServer(bshport, bshfile);
// NOSONAR we just evaluate some code here
t.run();
}
// Should we run a beanshell script on startup?
// $NON-NLS-1$
String bshinit = JMeterUtils.getProperty("beanshell.init.file");
if (bshinit != null) {
log.info("Run Beanshell on file: {}", bshinit);
try {
BeanShellInterpreter bsi = new BeanShellInterpreter();
bsi.source(bshinit);
} catch (ClassNotFoundException e) {
if (log.isWarnEnabled()) {
log.warn("Could not start Beanshell: {}", e.getLocalizedMessage());
}
} catch (JMeterException e) {
if (log.isWarnEnabled()) {
log.warn("Could not process Beanshell file: {}", e.getLocalizedMessage());
}
}
}
// $NON-NLS-1$
int mirrorPort = JMeterUtils.getPropDefault("mirror.server.port", 0);
if (mirrorPort > 0) {
log.info("Starting Mirror server ({})", mirrorPort);
try {
Object instance = ClassTools.construct(// $NON-NLS-1$
"org.apache.jmeter.protocol.http.control.HttpMirrorControl", mirrorPort);
ClassTools.invoke(instance, "startHttpMirror");
} catch (JMeterException e) {
log.warn("Could not start Mirror server", e);
}
}
}
Aggregations