Search in sources :

Example 1 with ScenarioController

use of io.engineblock.core.ScenarioController in project engineblock by engineblock.

the class Scenario method init.

private void init() {
    MetricRegistry metricRegistry = ActivityMetrics.getMetricRegistry();
    scriptEngine = engineManager.getEngineByName("nashorn");
    scriptEnv = new ScenarioContext(scenarioController);
    scriptEngine.setContext(scriptEnv);
    scenarioController = new ScenarioController();
    progressIndicator = new ProgressIndicator(scenarioController, progressInterval);
    scriptEngine.put("scenario", scenarioController);
    scriptEngine.put("activities", new ScenarioBindings(scenarioController));
    scriptEngine.put("metrics", new MetricRegistryBindings(metricRegistry));
    for (ScriptingPluginInfo extensionDescriptor : SandboxExtensionFinder.findAll()) {
        if (!extensionDescriptor.isAutoLoading()) {
            logger.info("Not loading " + extensionDescriptor + ", autoloading is false");
            continue;
        }
        org.slf4j.Logger extensionLogger = LoggerFactory.getLogger("extensions." + extensionDescriptor.getBaseVariableName());
        Object extensionObject = extensionDescriptor.getExtensionObject(extensionLogger, metricRegistry, scriptEnv);
        logger.debug("Adding extension object:  name=" + extensionDescriptor.getBaseVariableName() + " class=" + extensionObject.getClass().getSimpleName());
        scriptEngine.put(extensionDescriptor.getBaseVariableName(), extensionObject);
    }
}
Also used : MetricRegistryBindings(io.engineblock.metrics.MetricRegistryBindings) ScenarioController(io.engineblock.core.ScenarioController) ProgressIndicator(io.engineblock.activitycore.ProgressIndicator) MetricRegistry(com.codahale.metrics.MetricRegistry) ScriptingPluginInfo(io.engineblock.extensions.ScriptingPluginInfo)

Aggregations

MetricRegistry (com.codahale.metrics.MetricRegistry)1 ProgressIndicator (io.engineblock.activitycore.ProgressIndicator)1 ScenarioController (io.engineblock.core.ScenarioController)1 ScriptingPluginInfo (io.engineblock.extensions.ScriptingPluginInfo)1 MetricRegistryBindings (io.engineblock.metrics.MetricRegistryBindings)1