使用服务器java api从jasperserver存储库中检索资源

时间:2014-12-30 12:45:07

标签: java jasper-reports jasperserver

我正在尝试使用它的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实例?

1 个答案:

答案 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);