/** * */ private List<ParameterContributor> getParameterContributors(ParameterContributorContext context) throws JRException { List<ParameterContributor> allContributors = null; List<?> factories = getJasperReportsContext().getExtensions(ParameterContributorFactory.class); if (factories != null && factories.size() > 0) { allContributors = new ArrayList<ParameterContributor>(); for (Iterator<?> it = factories.iterator(); it.hasNext();) { ParameterContributorFactory factory = (ParameterContributorFactory)it.next(); List<ParameterContributor> contributors = factory.getContributors(context); if (contributors != null) { allContributors.addAll(contributors); } } } return allContributors; }
public void init() { jasperReportsContext = new SimpleJasperReportsContext(); // for some reason data adapter extensions are not registered by default jasperReportsContext.setExtensions(ParameterContributorFactory.class, Collections.singletonList(DataAdapterParameterContributorFactory.getInstance())); jasperReportsContext.setExtensions(DataFileServiceFactory.class, Collections.singletonList(BuiltinDataFileServiceFactory.instance())); try { compileReport(); readReferenceDigest(); } catch (JRException | IOException | NoSuchAlgorithmException e) { throw new RuntimeException(e); } }