我正在尝试使用它的java API从Jasperserver存储库中检索资源,根据jasper report server ultimate guide,我应该得到一个ExecutionContext接口的实例:
ExecutionContext context = JasperServerUtil.getExecutionContext();
然后,获取RepositoryService接口的实例:
RepositoryService repositoryService = ...; //how??
现在我可以使用以下代码获取文件:
FileResourceData fileResourceData = repositoryService.getContentResourceData(context, "/examples/report.pdf");
我的问题是我如何获得RepositoryService实例?
答案 0 :(得分:4)
ApplicationContext ctx = StaticApplicationContext.getApplicationContext();
String repositoryServiceName = "repositoryService";
RepositoryService repositoryService = (RepositoryService) ctx.getBean(repositoryServiceName);
ExecutionContext context = JasperServerUtil.getExecutionContext();
Resource resource = repositoryService.getResource(context, fileURI);