使用服务器java api从jasperserver存储库中检索资源 [英] Retrieve resource from jasperserver repository using server java api
本文介绍了使用服务器java api从jasperserver存储库中检索资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用其Java API从Jasperserver存储库中检索资源,根据 jasper report server ultimate guide ,我应该得到一个ExecutionContext接口的实例:
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();
然后,获取RepositoryService接口的实例:
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");
我的问题是我如何获得RepositoryService实例?
my question is how can I get the RepositoryService instance?
推荐答案
ApplicationContext ctx = StaticApplicationContext.getApplicationContext();
String repositoryServiceName = "repositoryService";
RepositoryService repositoryService = (RepositoryService) ctx.getBean(repositoryServiceName);
ExecutionContext context = JasperServerUtil.getExecutionContext();
Resource resource = repositoryService.getResource(context, fileURI);
这篇关于使用服务器java api从jasperserver存储库中检索资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文