protected void initManager(ScriptEngineManager sem) { final String label = getName(); final String fileName = getFilename(); final String scriptParameters = getParameters(); // Use actual class name for log final Logger logger = LoggingManager.getLoggerForShortName(getClass().getName()); sem.put("log", logger); sem.put("Label", label); sem.put("FileName", fileName); sem.put("Parameters", scriptParameters); String[] args = JOrphanUtils.split(scriptParameters, " "); // $NON-NLS-1$ sem.put("args", args); // Add variables for access to context and variables JMeterContext jmctx = JMeterContextService.getContext(); sem.put("ctx", jmctx); JMeterVariables vars = jmctx.getVariables(); sem.put("vars", vars); Properties props = JMeterUtils.getJMeterProperties(); sem.put("props", props); // For use in debugging: sem.put("OUT", System.out); // Most subclasses will need these: Sampler sampler = jmctx.getCurrentSampler(); sem.put("sampler", sampler); SampleResult prev = jmctx.getPreviousResult(); sem.put("prev", prev); }
protected void initManager(BSFManager mgr) throws BSFException { final String label = getName(); final String fileName = getFilename(); final String scriptParameters = getParameters(); // Use actual class name for log final Logger logger = LoggingManager.getLoggerForShortName(getClass().getName()); mgr.declareBean("log", logger, Logger.class); // $NON-NLS-1$ mgr.declareBean("Label", label, String.class); // $NON-NLS-1$ mgr.declareBean("FileName", fileName, String.class); // $NON-NLS-1$ mgr.declareBean("Parameters", scriptParameters, String.class); // $NON-NLS-1$ String[] args = JOrphanUtils.split(scriptParameters, " "); // $NON-NLS-1$ mgr.declareBean("args", args, args.getClass()); // $NON-NLS-1$ // Add variables for access to context and variables JMeterContext jmctx = JMeterContextService.getContext(); JMeterVariables vars = jmctx.getVariables(); Properties props = JMeterUtils.getJMeterProperties(); mgr.declareBean("ctx", jmctx, jmctx.getClass()); // $NON-NLS-1$ mgr.declareBean("vars", vars, vars.getClass()); // $NON-NLS-1$ mgr.declareBean("props", props, props.getClass()); // $NON-NLS-1$ // For use in debugging: mgr.declareBean("OUT", System.out, PrintStream.class); // $NON-NLS-1$ // Most subclasses will need these: Sampler sampler = jmctx.getCurrentSampler(); mgr.declareBean("sampler", sampler, Sampler.class); SampleResult prev = jmctx.getPreviousResult(); mgr.declareBean("prev", prev, SampleResult.class); }