Retrieve resource from jasperserver repository usi

2019-04-11 11:20发布

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条回答
唯我独甜
2楼-- · 2019-04-11 11:51
ApplicationContext ctx = StaticApplicationContext.getApplicationContext();
String repositoryServiceName = "repositoryService";
RepositoryService repositoryService = (RepositoryService) ctx.getBean(repositoryServiceName);
ExecutionContext context = JasperServerUtil.getExecutionContext();
Resource resource = repositoryService.getResource(context, fileURI);
查看更多
登录 后发表回答