@@ -0,0 +1,3802 @@
+package org.sahagin.runlib.runresultsgen;%0A%0Aimport java.io.File;%0Aimport java.util.logging.Logger;%0A%0Aimport org.sahagin.report.HtmlReport;%0Aimport org.sahagin.share.CommonPath;%0Aimport org.sahagin.share.Config;%0Aimport org.sahagin.share.IllegalDataStructureException;%0Aimport org.sahagin.share.IllegalTestScriptException;%0Aimport org.sahagin.share.JavaConfig;%0Aimport org.sahagin.share.Logging;%0Aimport org.sahagin.share.srctree.SrcTree;%0Aimport org.sahagin.share.yaml.YamlConvertException;%0Aimport org.sahagin.share.yaml.YamlUtils;%0A%0A// TODO support multiple thread concurrent test execution%0A%0Apublic class HookMethodDef %7B%0A    private static Logger logger = Logging.getLogger(HookMethodDef.class.getName());%0A    private static HookMethodManager manager = null;%0A%0A    // if called multiple times, just ignored%0A    public static void initialize(String configFilePath) %7B%0A        if (manager != null) %7B%0A            return;%0A        %7D%0A%0A        logger.info(%22initialize%22);%0A%0A        final Config config;%0A        try %7B%0A            config = JavaConfig.generateFromYamlConfig(new File(configFilePath));%0A        %7D catch (YamlConvertException e) %7B%0A            throw new RuntimeException(e);%0A        %7D%0A%0A        // load srcTree from already dumped srcTree YAML%0A        final File srcTreeFile = CommonPath.srcTreeFile(config.getRootBaseReportIntermediateDataDir());%0A        SrcTree srcTree = new SrcTree();%0A        try %7B%0A            srcTree.fromYamlObject(YamlUtils.load(srcTreeFile));%0A        %7D catch (YamlConvertException e) %7B%0A            throw new RuntimeException(e);%0A        %7D%0A        try %7B%0A            srcTree.resolveKeyReference();%0A        %7D catch (IllegalDataStructureException e) %7B%0A            throw new RuntimeException(e);%0A        %7D%0A%0A        manager = new HookMethodManager(srcTree, config);%0A%0A        if (!config.isRunTestOnly()) %7B%0A            // set up shutdown hook which generates HTML report%0A            Runtime.getRuntime().addShutdownHook(new Thread() %7B%0A                @Override%0A                public void run() %7B%0A                    HtmlReport report = new HtmlReport();%0A                    try %7B%0A                        report.generate(config.getRootBaseReportIntermediateDataDir(),%0A                                config.getRootBaseReportOutputDir());%0A                    %7D catch (IllegalDataStructureException e) %7B%0A                        throw new RuntimeException(e);%0A                    %7D catch (IllegalTestScriptException e) %7B%0A                        throw new RuntimeException(e);%0A                    %7D%0A                %7D%0A            %7D);%0A        %7D%0A    %7D%0A%0A    private static void initializedCheck() %7B%0A        if (manager == null) %7B%0A            throw new IllegalStateException(%22initialize first%22);%0A        %7D%0A    %7D%0A%0A    public static void beforeMethodHook(%0A            String hookedClassQualifiedName, String hookedMethodSimpleName) %7B%0A        initializedCheck();%0A        manager.beforeMethodHook(hookedClassQualifiedName, hookedMethodSimpleName);%0A    %7D%0A%0A    public static void methodErrorHook(%0A            String hookedClassQualifiedName, String hookedMethodSimpleName, Throwable e) %7B%0A        initializedCheck();%0A        manager.methodErrorHook(hookedClassQualifiedName, hookedMethodSimpleName, e);%0A    %7D%0A%0A    public static void afterMethodHook(%0A            String hookedClassQualifiedName, String hookedMethodSimpleName) %7B%0A        initializedCheck();%0A        manager.afterMethodHook(hookedClassQualifiedName, hookedMethodSimpleName);%0A    %7D%0A%0A    public static void beforeCodeLineHook(String hookedClassQualifiedName, String hookedMethodSimpleName,%0A            String hookedArgClassesStr, int line, int actualInsertedLine) %7B%0A        initializedCheck();%0A        manager.beforeCodeLineHook(hookedClassQualifiedName,%0A                hookedMethodSimpleName, hookedArgClassesStr, line, actualInsertedLine);%0A    %7D%0A%0A%7D

Split HookMethodDef class