/** * Deploys rules into Byteman, where the rule definitions are found in the * given streams. Rule definitions are read from the streams and the rule * text uploaded directly to the Byteman agent. * * This method is useful for using rules files from the classpath. * * @param resourceStreams * input streams containing the rule definitions to be deployed * to Byteman * * @return the results of the deployment * * @throws Exception * if the request failed */ public String addRulesFromResources(List<InputStream> resourceStreams) throws Exception { List<ScriptText> scripts = getRulesFromRuleStreams(resourceStreams); return addScripts(scripts); }
/** * Deploys rules into Byteman, where the rule definitions are found in the * local files found at the given paths. The rule definitions found in the * files are actually passed down directly to Byteman, not the file paths * themselves. Therefore, these files must exist on the machine where this * client is running (i.e. the files are not loaded directly by the Byteman * agent). * * @param filePaths * the local files containing the rule definitions to be deployed * to Byteman * * @return the results of the deployment * * @throws Exception * if the request failed */ public String addRulesFromFiles(List<String> filePaths) throws Exception { List<ScriptText> scripts = getRulesFromRuleFiles(filePaths); return addScripts(scripts); }
/** * loads a script supplied as a text String rather than via a file on disk * @param clazz the test class * @param testname the test name * @param scriptText the text of the rule or rules contained in the script * @throws Exception if the script text cannot be loaded */ public static void loadScriptText(Class<?> clazz, String testname, String scriptText) throws Exception { if (BMUnitConfigState.getCurrentConfigState() == null) { throw new Exception("BMUnit : load script file requested with no current configuration " + clazz.getName() + (testname != null ? " " + testname : "")); } String className = clazz.getName(); if (testname == null) { testname = ""; } String key = className + "+" + testname; fileTable.put(key, scriptText); Submit submit = new Submit(getHost(), getPort()); if (isBMUnitVerbose()) { System.out.println("BMUnit : loading text script = " + key); // System.out.println(scriptText); } List<ScriptText> scripts = new ArrayList<ScriptText>(); ScriptText script = new ScriptText(key, scriptText); scripts.add(script); submit.addScripts(scripts); }
List<ScriptText> scriptTexts = new LinkedList<ScriptText>(); scriptTexts.add(scriptText); submit.addScripts(scriptTexts); installedScripts.addAll(scriptTexts); } else {