FR二次开发stopModules进程没有结束

来源:互联网 发布:淘宝去边框代码 编辑:程序博客网 时间:2024/05/23 19:15

下面这段是FR7.1版本二次开发把模板导出成pdf文件的语句:

public static void main(String[] args) throws Exception{String envpath = "c:\\Program Files\\FineReport_7.1\\WebReport\\WEB-INF";FRContext.setCurrentEnv(new LocalEnv(envpath));ModuleContext.startModule(EngineModule.class.getName());String cptname = "00.cpt";WorkBook workbook = (WorkBook) TemplateWorkBookIO.readTemplateWorkBook(FRContext.getCurrentEnv(), cptname);OutputStream outputStream = new FileOutputStream(new File("c:\\TxtExport.txt"));TextExporter TxtExport = new TextExporter();Map parameterMap = new HashMap();parameterMap.put("p1", "sdf");TxtExport.export(outputStream, workbook.execute(parameterMap, ActorFactory.getActor("page")));outputStream.close();ModuleContext.stopModules();}

思路很简单,启动FR的工程模块,加载解析模板导出到pdf,最后调用ModuleContext.stopModules()关闭模块。
问题是执行到最后发现主进程并没有退出。
这是因为有子线程还在执行。这个子线程是填报模块(WriteModule)的excel批量导入服务(ExcelSubmitService)中定义的一个定时任务。stopModules并没有关闭掉这个定时任务的线程。所以需要在最后加上一句:new WriteModule().stop()。

0 0
原创粉丝点击