Retrieve resource from jasperserver repository using server java api

拜拜、爱过 提交于 2020-01-01 17:27:51

问题


I'm trying to retrieve resource from Jasperserver repository using its java API, according to jasper report server ultimate guide, I should get an instance of the ExecutionContext interface:

ExecutionContext context = JasperServerUtil.getExecutionContext();

then, get an instance of the RepositoryService interface:

RepositoryService repositoryService = ...; //how??

Now I can get the file using the following code:

FileResourceData fileResourceData = repositoryService.getContentResourceData(context, "/examples/report.pdf");

my question is how can I get the RepositoryService instance?


回答1:


ApplicationContext ctx = StaticApplicationContext.getApplicationContext();
String repositoryServiceName = "repositoryService";
RepositoryService repositoryService = (RepositoryService) ctx.getBean(repositoryServiceName);
ExecutionContext context = JasperServerUtil.getExecutionContext();
Resource resource = repositoryService.getResource(context, fileURI);


来源:https://stackoverflow.com/questions/27705766/retrieve-resource-from-jasperserver-repository-using-server-java-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!