private static JRCompiler getCompiler(JasperDesign jasperDesign) throws JRException { JRCompiler compiler = null; String compilerClassName = JRProperties.getProperty(JRProperties.COMPILER_CLASS); if (compilerClassName == null || compilerClassName.trim().length() == 0) { String language = jasperDesign.getLanguage(); compilerClassName = JRProperties.getProperty(JRCompiler.COMPILER_PREFIX + language); if (compilerClassName == null || compilerClassName.trim().length() == 0) { if (JRReport.LANGUAGE_JAVA.equals(language)) { return getJavaCompiler(); } else { throw new JRException("No report compiler set for language : " + language); } } } try { Class clazz = JRClassLoader.loadClassForName(compilerClassName); compiler = (JRCompiler) clazz.newInstance(); } catch (Exception e) { throw new JRException("Could not instantiate report compiler : " + compilerClassName, e); } return compiler; }
protected static MarkupProcessor getMarkupProcessor(String markup) { MarkupProcessor markupProcessor = (MarkupProcessor) markupProcessors.get(markup); if (markupProcessor == null) { String factoryClass = JRProperties.getProperty( MarkupProcessorFactory.PROPERTY_MARKUP_PROCESSOR_FACTORY_PREFIX + markup); if (factoryClass == null) { throw new JRRuntimeException( "No markup processor factory specifyed for '" + markup + "' markup."); } MarkupProcessorFactory factory = null; try { factory = (MarkupProcessorFactory) markupProcessorFactoryCache.getCachedInstance(factoryClass); } catch (JRException e) { throw new JRRuntimeException(e); } markupProcessor = factory.createMarkupProcessor(); markupProcessors.put(markup, markupProcessor); } return markupProcessor; }
public static BarcodeImageProducer getImageProducer(JRPropertiesHolder propertiesHolder) { String producerProperty = JRProperties.getProperty(propertiesHolder, BarcodeImageProducer.PROPERTY_IMAGE_PRODUCER); String producerClass = JRProperties.getProperty( propertiesHolder, BarcodeImageProducer.PROPERTY_PREFIX_IMAGE_PRODUCER + producerProperty); if (producerClass == null) { producerClass = producerProperty; } try { return (BarcodeImageProducer) imageProducerCache.getCachedInstance(producerClass); } catch (JRException e) { throw new JRRuntimeException(e); } }
protected static JRSubreportRunnerFactory getRunnerFactory() throws JRException { String factoryClassName = JRProperties.getProperty(JRSubreportRunnerFactory.SUBREPORT_RUNNER_FACTORY); if (factoryClassName == null) { throw new JRException( "Property \"" + JRSubreportRunnerFactory.SUBREPORT_RUNNER_FACTORY + "\" must be set"); } return runnerFactoryCache.getCachedInstance(factoryClassName); }
/** * Creates a data source out of the query result. * * @return the data source */ protected JRDataSource createResultDatasource() { JRDataSource resDatasource; String runType = JRProperties.getProperty( dataset, JRHibernateQueryExecuterFactory.PROPERTY_HIBERNATE_QUERY_RUN_TYPE); boolean useFieldDescriptions = JRProperties.getBooleanProperty( dataset, JRHibernateQueryExecuterFactory.PROPERTY_HIBERNATE_FIELD_MAPPING_DESCRIPTIONS, true); if (runType == null || runType.equals(JRHibernateQueryExecuterFactory.VALUE_HIBERNATE_QUERY_RUN_TYPE_LIST)) { try { int pageSize = JRProperties.getIntegerProperty( dataset, JRHibernateQueryExecuterFactory.PROPERTY_HIBERNATE_QUERY_LIST_PAGE_SIZE, 0); resDatasource = new JRHibernateListDataSource(this, useFieldDescriptions, pageSize); } catch (NumberFormatException e) { throw new JRRuntimeException( "The " + JRHibernateQueryExecuterFactory.PROPERTY_HIBERNATE_QUERY_LIST_PAGE_SIZE + " property must be numerical.", e); } } else if (runType.equals( JRHibernateQueryExecuterFactory.VALUE_HIBERNATE_QUERY_RUN_TYPE_ITERATE)) { resDatasource = new JRHibernateIterateDataSource(this, useFieldDescriptions); } else if (runType.equals( JRHibernateQueryExecuterFactory.VALUE_HIBERNATE_QUERY_RUN_TYPE_SCROLL)) { resDatasource = new JRHibernateScrollDataSource(this, useFieldDescriptions); } else { throw new JRRuntimeException( "Unknown value for the " + JRHibernateQueryExecuterFactory.PROPERTY_HIBERNATE_QUERY_RUN_TYPE + " property. Possible values are " + JRHibernateQueryExecuterFactory.VALUE_HIBERNATE_QUERY_RUN_TYPE_LIST + ", " + JRHibernateQueryExecuterFactory.VALUE_HIBERNATE_QUERY_RUN_TYPE_ITERATE + " and " + JRHibernateQueryExecuterFactory.VALUE_HIBERNATE_QUERY_RUN_TYPE_SCROLL + "."); } return resDatasource; }