@Override public ExtensionsRegistry createRegistry(String registryId, JRPropertiesMap properties) { List<PropertySuffix> themeProperties = JRPropertiesUtil.getProperties(properties, XML_CHART_THEME_PROPERTY_PREFIX); Map<String, ChartTheme> themes = new HashMap<String, ChartTheme>(); for (Iterator<PropertySuffix> it = themeProperties.iterator(); it.hasNext();) { PropertySuffix themeProp = it.next(); String themeName = themeProp.getSuffix(); String themeLocation = themeProp.getValue(); XmlChartTheme theme = new XmlChartTheme(themeLocation); themes.put(themeName, theme); } ChartThemeMapBundle bundle = new ChartThemeMapBundle(); bundle.setThemes(themes); return new ChartThemeBundlesExtensionsRegistry(bundle); }
@Override public ExtensionsRegistry createRegistry(String registryId, JRPropertiesMap properties) { List<PropertySuffix> jacksonMappingProperties = JRPropertiesUtil.getProperties(properties, JACKSON_MAPPING_PROPERTY_PREFIX); List<JacksonMapping> jacksonMappings = new ArrayList<JacksonMapping>(); for (Iterator<PropertySuffix> it = jacksonMappingProperties.iterator(); it.hasNext();) { PropertySuffix jacksonMappingProp = it.next(); jacksonMappings.add( new JacksonMapping( jacksonMappingProp.getSuffix(), jacksonMappingProp.getValue() ) ); } return new ListExtensionRegistry<JacksonMapping>(JacksonMapping.class, jacksonMappings); }
protected void setPaths(String registryId, JRPropertiesMap properties, RequirejsTemplateConfigContributor templateContributor) { String pathPropPrefix = EXTENSION_PROPERTY_PATH_PREFIX + registryId + "."; List<PropertySuffix> pathProps = JRPropertiesUtil.getProperties(properties, pathPropPrefix); for (PropertySuffix pathProp : pathProps) { String suffix = pathProp.getSuffix(); String path = pathProp.getValue(); if (log.isDebugEnabled()) { log.debug("setting path " + suffix + " to " + path); } templateContributor.addPath(suffix, path); } }
protected void setResources(String registryId, JRPropertiesMap properties, RequirejsTemplateConfigContributor templateContributor) { String pathPropPrefix = EXTENSION_PROPERTY_RESOURCE_PREFIX + registryId + "."; List<PropertySuffix> pathProps = JRPropertiesUtil.getProperties(properties, pathPropPrefix); for (PropertySuffix pathProp : pathProps) { String suffix = pathProp.getSuffix(); String path = pathProp.getValue(); if (log.isDebugEnabled()) { log.debug("setting resource " + suffix + " to " + path); } templateContributor.addResourcePath(suffix, path); } }
@Override public ExtensionsRegistry createRegistry(String registryId, JRPropertiesMap properties) { List<PropertySuffix> requirejsModuleProperties = JRPropertiesUtil.getProperties(properties, REQUIREJS_MAPPING_PROPERTY_PREFIX); List<RequirejsModuleMapping> requirejsModules = new ArrayList<RequirejsModuleMapping>(); for (Iterator<PropertySuffix> it = requirejsModuleProperties.iterator(); it.hasNext();) { PropertySuffix requirejsModuleProp = it.next(); String suffix = requirejsModuleProp.getSuffix(); boolean isClasspathResource = !suffix.endsWith(URL_SUFFIX); requirejsModules.add( new RequirejsModuleMapping( isClasspathResource ? suffix : suffix.substring(0, suffix.indexOf(URL_SUFFIX)), requirejsModuleProp.getValue(), isClasspathResource ) ); } return new ListExtensionRegistry<RequirejsModuleMapping>(RequirejsModuleMapping.class, requirejsModules); }
public JRBasePart(JRPart part, JRBaseObjectFactory factory) { factory.put(part, this); this.uuid = part.getUUID(); this.propertiesMap = JRPropertiesMap.getPropertiesClone(part); this.printWhenExpression = factory.getExpression(part.getPrintWhenExpression()); this.partNameExpression = factory.getExpression(part.getPartNameExpression()); this.evaluationTime = part.getEvaluationTime(); componentKey = part.getComponentKey(); PartComponentManager manager = PartComponentsEnvironment.getInstance(DefaultJasperReportsContext.getInstance()).getManager(componentKey); component = manager.getComponentCompiler(DefaultJasperReportsContext.getInstance()).toCompiledComponent( part.getComponent(), factory); if (component instanceof JRVisitable) { ((JRVisitable) component).visit(factory); } }
@Override public ExtensionsRegistry createRegistry(String registryId, JRPropertiesMap properties) { List<PropertySuffix> fontFamiliesProperties = JRPropertiesUtil.getProperties(properties, SIMPLE_FONT_FAMILIES_PROPERTY_PREFIX); List<String> fontFamiliesLocations = new ArrayList<String>(); for (Iterator<PropertySuffix> it = fontFamiliesProperties.iterator(); it.hasNext();) { PropertySuffix fontFamiliesProp = it.next(); //String fontFamiliesName = fontFamiliesProp.getSuffix(); String fontFamiliesLocation = fontFamiliesProp.getValue(); //fontFamiliesLocations.addAll(SimpleFontExtensionHelper.getInstance().loadFontFamilies(fontFamiliesLocation)); fontFamiliesLocations.add(fontFamiliesLocation); } return new FontExtensionsRegistry(fontFamiliesLocations); }
/** * Adds a set of properties to the hash. * * @param properties */ public void add(JRPropertiesMap properties) { if (properties == null || !properties.hasProperties()) { addToHash(0); } else { String[] names = properties.getPropertyNames(); for (String prop : names) { add(prop); add(properties.getProperty(prop)); } } }
/** * * */ private void writeProperties( JRPropertiesHolder propertiesHolder, String propertiesHolderName) { if (propertiesHolder.hasProperties()) { JRPropertiesMap propertiesMap = propertiesHolder.getPropertiesMap(); String[] propertyNames = propertiesMap.getPropertyNames(); if (propertyNames != null && propertyNames.length > 0) { write( "//properties\n"); for(int i = 0; i < propertyNames.length; i++) { String value = propertiesMap.getProperty(propertyNames[i]); if (value != null) { write( propertiesHolderName + ".setProperty(\"" + propertyNames[i] + "\", \"" + JRStringUtil.escapeJavaStringLiteral(value) + "\");\n"); } } write("\n"); } flush(); } }
protected boolean allowElementNegativeX(JRElement element) { // default to report/global property boolean allow = allowElementNegativeX; if (element.hasProperties()) { JRPropertiesMap properties = element.getPropertiesMap(); if (properties.containsProperty(PROPERTY_ALLOW_ELEMENT_NEGATIVE_X)) { // use element level property allow = JRPropertiesUtil.asBoolean(properties.getProperty( PROPERTY_ALLOW_ELEMENT_NEGATIVE_X)); } } return allow; }
protected boolean allowElementNegativeY(JRElement element) { // default to report/global property boolean allow = allowElementNegativeY; if (element.hasProperties()) { JRPropertiesMap properties = element.getPropertiesMap(); if (properties.containsProperty(PROPERTY_ALLOW_ELEMENT_NEGATIVE_Y)) { // use element level property allow = JRPropertiesUtil.asBoolean(properties.getProperty( PROPERTY_ALLOW_ELEMENT_NEGATIVE_Y)); } } return allow; }
/** * */ protected void evaluateProperties(PropertyEvaluationTimeEnum evaluationTime) throws JRException { if (!propertyExpressions.isEmpty()) { JRPropertiesMap dynamicProperties = new JRPropertiesMap(); PropertyEvaluationTimeEnum defaultEvaluationTime = getDefaultPropertyEvaluationTime(); for (DatasetPropertyExpression prop : propertyExpressions) { PropertyEvaluationTimeEnum propEvalTime = prop.getEvaluationTime() == null ? defaultEvaluationTime : prop.getEvaluationTime(); if (evaluationTime == propEvalTime) { String value = (String) evaluateExpression(prop.getValueExpression(), JRExpression.EVALUATION_DEFAULT); //if (value != null) //is the null value significant for some field properties? { dynamicProperties.setProperty(prop.getName(), value); } } } JRPropertiesMap newMergedProperties = dynamicProperties.cloneProperties(); newMergedProperties.setBaseProperties(mergedProperties); mergedProperties = newMergedProperties; } }
/** * */ protected void evaluateProperties() throws JRException { if (propertyExpressions.isEmpty()) { mergedProperties = staticProperties; } else { JRPropertiesMap dynamicProperties = new JRPropertiesMap(); for (JRPropertyExpression prop : propertyExpressions) { String value = (String) evaluateExpression(prop.getValueExpression()); //if (value != null) //is the null value significant for some field properties? { dynamicProperties.setProperty(prop.getName(), value); } } mergedProperties = dynamicProperties.cloneProperties(); mergedProperties.setBaseProperties(staticProperties); } }
/** * */ private void addFunctionClasses(List<String> classNames, JRPropertiesMap properties, String propertyPrefix) { List<PropertySuffix> functionClassProperties = JRPropertiesUtil.getProperties(properties, propertyPrefix); for (Iterator<PropertySuffix> it = functionClassProperties.iterator(); it.hasNext();) { PropertySuffix functionsClassesProp = it.next(); // We assume this property value is a comma-separated class names list like: a.b.c.ClassA, a.b.d.ClassB String[] classes = functionsClassesProp.getValue().split(","); for (String className : classes) { className = className.trim(); if (className.length() > 0) { classNames.add( className); } } } }
@Override public String getStringParameter(net.sf.jasperreports.engine.JRExporterParameter parameter, String property) { String value; JRPropertiesMap hintsMap = jasperPrint.getPropertiesMap(); if (hintsMap != null && hintsMap.containsProperty(property)) { value = hintsMap.getProperty(property); } else { value = (String) parameters.get(parameter); if (value == null) { value = getPropertiesUtil().getProperty(property); } } return value; }
@Override public String[] getStringArrayParameter(net.sf.jasperreports.engine.JRExporterParameter parameter, String propertyPrefix) { String[] values = null; JRPropertiesMap hintsMap = jasperPrint.getPropertiesMap(); if (hintsMap != null) { List<PropertySuffix> properties = JRPropertiesUtil.getProperties(hintsMap, propertyPrefix); if (properties != null && !properties.isEmpty()) { values = new String[properties.size()]; for(int i = 0; i < values.length; i++) { values[i] = properties.get(i).getValue(); } } } else { values = (String[])parameters.get(parameter); } return values; }
@Override public Character getCharacterParameter(net.sf.jasperreports.engine.JRExporterParameter parameter, String property) { Character value; JRPropertiesMap hintsMap = jasperPrint.getPropertiesMap(); if (hintsMap != null && hintsMap.containsProperty(property)) { String prop = hintsMap.getProperty(property); value = JRPropertiesUtil.asCharacter(prop); } else { value = (Character) parameters.get(parameter); if (value == null) { value = getPropertiesUtil().getCharacterProperty(property); } } return value; }
/** * */ public static ConditionalFormattingData getConditionalFormattingData( JRDesignTextElement textElement, JasperReportsContext jasperReportsContext ) { ConditionalFormattingData cfd = null; if (textElement != null) { JRPropertiesMap propertiesMap = textElement.getPropertiesMap(); if ( propertiesMap.containsProperty(ConditionalFormattingCommand.COLUMN_CONDITIONAL_FORMATTING_PROPERTY) && propertiesMap.getProperty(ConditionalFormattingCommand.COLUMN_CONDITIONAL_FORMATTING_PROPERTY) != null ) { cfd = JacksonUtil.getInstance(jasperReportsContext).loadObject( propertiesMap.getProperty(ConditionalFormattingCommand.COLUMN_CONDITIONAL_FORMATTING_PROPERTY), ConditionalFormattingData.class ); } } return cfd; }
public StandardBaseColumn(BaseColumn column, ColumnFactory factory) { this.uuid = column.getUUID(); this.printWhenExpression = factory.getBaseObjectFactory().getExpression( column.getPrintWhenExpression()); this.tableHeader = factory.createCell(column.getTableHeader()); this.tableFooter = factory.createCell(column.getTableFooter()); this.groupHeaders = factory.createGroupCells(column.getGroupHeaders()); this.groupFooters = factory.createGroupCells(column.getGroupFooters()); this.columnHeader = factory.createCell(column.getColumnHeader()); this.columnFooter = factory.createCell(column.getColumnFooter()); this.width = column.getWidth(); propertiesMap = JRPropertiesMap.getPropertiesClone(column); copyPropertyExpressions(column, factory); }
@Override public FillColumn visitColumn(Column column) { try { boolean toPrint = toPrintColumn(column, evaluation); if (toPrint) { JRPropertiesMap properties = evaluateProperties(column, evaluation); return new FillColumn(column, properties); } return null; } catch (JRException e) { throw new JRRuntimeException(e); } }
@Override public ExtensionsRegistry createRegistry(String registryId, JRPropertiesMap properties) { List<PropertySuffix> contentTypeMappingProperties = JRPropertiesUtil.getProperties(properties, CONTENT_TYPE_MAPPING_PROPERTY_PREFIX); List<ContentTypeMapping> contentTypeMappings = new ArrayList<ContentTypeMapping>(); for (Iterator<PropertySuffix> it = contentTypeMappingProperties.iterator(); it.hasNext();) { PropertySuffix contentTypeMappingProp = it.next(); contentTypeMappings.add(new ContentTypeMapping(contentTypeMappingProp.getSuffix(),contentTypeMappingProp.getValue())); } return new ListExtensionRegistry<ContentTypeMapping>(ContentTypeMapping.class, contentTypeMappings); }
@Override public ExtensionsRegistry createRegistry(String registryId, JRPropertiesMap properties) { String template = properties.getProperty(EXTENSION_PROPERTY_TEMPLATE_PREFIX + registryId); String enabledProp = properties.getProperty(EXTENSION_PROPERTY_ENABLED_PREFIX + registryId); boolean enabled = JRPropertiesUtil.asBoolean(enabledProp, true); if (log.isDebugEnabled()) { log.debug("creating requirejs template contributor " + registryId + ", template: " + template + ", enabled: " + enabled); } RequirejsTemplateConfigContributor templateContributor = new RequirejsTemplateConfigContributor(); templateContributor.setTemplateName(template); setPaths(registryId, properties, templateContributor); setResources(registryId, properties, templateContributor); RequirejsConfigContributorSwitchDecorator switchDecorator = new RequirejsConfigContributorSwitchDecorator(); switchDecorator.setDefaultEnabled(enabled); switchDecorator.setPropertyName(PROPERTY_ENABLED_PREFIX + registryId); switchDecorator.setContributor(templateContributor); ExtensionsRegistry registry = new SingletonExtensionRegistry<RequirejsConfigContributor>( RequirejsConfigContributor.class, switchDecorator); return registry; }
/** * Initializes basic properties of the element. * @param element an element whose properties are copied to this element. Usually it is a * {@link net.sf.jasperreports.engine.design.JRDesignElement} that must be transformed into an * <tt>JRBaseElement</tt> at compile time. * @param factory a factory used in the compile process */ protected JRBaseElement(JRElement element, JRBaseObjectFactory factory) { factory.put(element, this); defaultStyleProvider = factory.getDefaultStyleProvider(); parentStyle = factory.getStyle(element.getStyle()); parentStyleNameReference = element.getStyleNameReference(); uuid = element.getUUID(); key = element.getKey(); positionTypeValue = element.getPositionTypeValue(); stretchTypeValue = element.getStretchTypeValue(); isPrintRepeatedValues = element.isPrintRepeatedValues(); modeValue = element.getOwnModeValue(); x = element.getX(); y = element.getY(); width = element.getWidth(); height = element.getHeight(); isRemoveLineWhenBlank = element.isRemoveLineWhenBlank(); isPrintInFirstWholeBand = element.isPrintInFirstWholeBand(); isPrintWhenDetailOverflows = element.isPrintWhenDetailOverflows(); forecolor = element.getOwnForecolor(); backcolor = element.getOwnBackcolor(); printWhenExpression = factory.getExpression(element.getPrintWhenExpression()); printWhenGroupChanges = factory.getGroup(element.getPrintWhenGroupChanges()); elementGroup = (JRElementGroup)factory.getVisitResult(element.getElementGroup()); propertiesMap = JRPropertiesMap.getPropertiesClone(element); propertyExpressions = factory.getPropertyExpressions(element.getPropertyExpressions()); }
/** * Creates a copy of a dataset instantiation. * * @param datasetRun the dataset instantiation * @param factory the base object factory */ protected JRBaseDatasetRun(JRDatasetRun datasetRun, JRBaseObjectFactory factory) { factory.put(datasetRun, this); uuid = datasetRun.getUUID(); datasetName = datasetRun.getDatasetName(); parametersMapExpression = factory.getExpression(datasetRun.getParametersMapExpression()); connectionExpression = factory.getExpression(datasetRun.getConnectionExpression()); dataSourceExpression = factory.getExpression(datasetRun.getDataSourceExpression()); propertiesMap = JRPropertiesMap.getPropertiesClone(datasetRun); JRDatasetParameter[] datasetParams = datasetRun.getParameters(); if (datasetParams != null && datasetParams.length > 0) { parameters = new JRBaseDatasetParameter[datasetParams.length]; for (int i = 0; i < parameters.length; i++) { parameters[i] = factory.getDatasetParameter(datasetParams[i]); } } List<ReturnValue> datesetReturnValues = datasetRun.getReturnValues(); if (datesetReturnValues != null && !datesetReturnValues.isEmpty()) { this.returnValues = new ArrayList<ReturnValue>(datesetReturnValues.size()); for (ReturnValue datasetReturnValue : datesetReturnValues) { BaseReturnValue returnValue = factory.getReturnValue(datasetReturnValue); this.returnValues.add(returnValue); } } }
public void writeProperties(JRPropertiesHolder propertiesHolder) throws IOException { if (propertiesHolder.hasProperties()) { JRPropertiesMap propertiesMap = propertiesHolder.getPropertiesMap(); String[] propertyNames = propertiesMap.getPropertyNames(); if (propertyNames != null && propertyNames.length > 0) { for(int i = 0; i < propertyNames.length; i++) { String propertyName = propertyNames[i]; if (isPropertyToWrite(propertiesHolder, propertyName)) { writer.startElement(JRXmlConstants.ELEMENT_property, getNamespace()); writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_name, propertyName); String value = propertiesMap.getProperty(propertyName); if (value != null) { String encodedValue = JRStringUtil.encodeXmlAttribute(value); if ( isNewerVersionOrEqual(JRConstants.VERSION_6_4_0) && encodedValue.length() != value.length() ) { writer.writeCDATA(value); } else { writer.addAttribute(JRXmlConstants.ATTRIBUTE_value, encodedValue); } } writer.closeElement(); } } } } }
protected void exportProperties(JRPropertiesHolder propertiesHolder) throws IOException { if (propertiesHolder.hasProperties()) { JRPropertiesMap propertiesMap = propertiesHolder.getPropertiesMap(); String[] propertyNames = propertiesMap.getPropertyNames(); if (propertyNames != null && propertyNames.length > 0) { for(int i = 0; i < propertyNames.length; i++) { xmlWriter.startElement(JRXmlConstants.ELEMENT_property); xmlWriter.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_name, propertyNames[i]); String value = propertiesMap.getProperty(propertyNames[i]); if (value != null) { String encodedValue = JRStringUtil.encodeXmlAttribute(value); if ( isNewerVersionOrEqual(JRConstants.VERSION_6_4_0) && encodedValue.length() != value.length() ) { xmlWriter.writeCDATA(value); } else { xmlWriter.addAttribute(JRXmlConstants.ATTRIBUTE_value, encodedValue); } } xmlWriter.closeElement(); } } } }
public static JROriginExporterFilter getFilter( JasperReportsContext jasperReportsContext, JRPropertiesMap propertiesMap, String originFilterPrefix ) { JROriginExporterFilter filter = null; filter = addOriginsToFilter(jasperReportsContext, filter, propertiesMap, originFilterPrefix, false); filter = addOriginsToFilter(jasperReportsContext, filter, propertiesMap, originFilterPrefix + KEEP_FIRST_PREFIX, true); return filter; }
private static JROriginExporterFilter addOriginsToFilter( JasperReportsContext jasperReportsContext, JROriginExporterFilter filter, JRPropertiesMap propertiesMap, String originFilterPrefix, boolean keepFirst ) { JRPropertiesUtil propUtil = JRPropertiesUtil.getInstance(jasperReportsContext); List<PropertySuffix> properties = propUtil.getProperties(originFilterPrefix + BAND_PREFIX); properties.addAll(JRPropertiesUtil.getProperties(propertiesMap, originFilterPrefix + BAND_PREFIX)); if (!properties.isEmpty()) { filter = (filter == null ? new JROriginExporterFilter(): filter); for(Iterator<PropertySuffix> it = properties.iterator(); it.hasNext();) { PropertySuffix propertySuffix = it.next(); String suffix = propertySuffix.getSuffix(); String propValue = propUtil.getProperty(propertiesMap, propertySuffix.getKey()); BandTypeEnum bandType = BandTypeEnum.getByName(propValue == null ? null : propValue.trim()); if (bandType != null) { filter.addOrigin( new JROrigin( propUtil.getProperty(propertiesMap, originFilterPrefix + REPORT_PREFIX + suffix), propUtil.getProperty(propertiesMap, originFilterPrefix + GROUP_PREFIX + suffix), bandType ), keepFirst ); } } } return filter; }
public ColumnHeaderCreator(ReportBandInfo bandInfo, FillColumn fillColumn, int xOffset, int yOffset, int level, Map<Integer, JRPropertiesMap> headerBaseProperties, AtomicBoolean firstColumn) { super(bandInfo, fillColumn, xOffset, yOffset, level); this.headerBaseProperties = headerBaseProperties; this.firstColumn = firstColumn; }
@Override public ExtensionsRegistry createRegistry(String registryId, JRPropertiesMap properties) { String root = JRPropertiesUtil.getInstance(DefaultJasperReportsContext.getInstance()).getProperty(properties, PROPERTY_FILE_REPOSITORY_ROOT); boolean resolveAbsolutePath = JRPropertiesUtil.getInstance(DefaultJasperReportsContext.getInstance()).getBooleanProperty(properties, PROPERTY_FILE_REPOSITORY_RESOLVE_ABSOLUTE_PATH, false); return new SingletonExtensionRegistry<RepositoryService>(RepositoryService.class, new FileRepositoryService(DefaultJasperReportsContext.getInstance(), root, resolveAbsolutePath)); }
public JRBaseCellContents(JRCellContents cell, JRBaseObjectFactory factory) { super(cell, factory); this.defaultStyleProvider = factory.getDefaultStyleProvider(); style = factory.getStyle(cell.getStyle()); styleNameReference = cell.getStyleNameReference(); modeValue = cell.getModeValue(); backcolor = cell.getBackcolor(); lineBox = cell.getLineBox().clone(this); width = cell.getWidth(); height = cell.getHeight(); this.propertiesMap = JRPropertiesMap.getPropertiesClone(cell); }
@Override public ExtensionsRegistry createRegistry(String registryId, JRPropertiesMap properties) { ListableBeanFactory beanFactory = getBeanFactory(registryId, properties); return new SpringExtensionsRegistry(beanFactory); }
protected ListableBeanFactory getBeanFactory(String registryId, JRPropertiesMap properties) { String resourceProp = DefaultExtensionsRegistry.PROPERTY_REGISTRY_PREFIX + registryId + PROPERTY_SUFFIX_SPRING_BEANS_RESOURCE; String resource = properties.getProperty(resourceProp); if (resource == null) { throw new JRRuntimeException( EXCEPTION_MESSAGE_KEY_NO_SPRING_RESOURCE_SET, (Object[])null); } URL resourceLocation = JRLoader.getResource(resource); if (resourceLocation == null) { throw new JRRuntimeException( EXCEPTION_MESSAGE_KEY_SPRING_RESOURCE_NOT_FOUND, new Object[]{resource, registryId}); } if (log.isDebugEnabled()) { log.debug("Creating Spring beans factory for extensions registry " + registryId + " using "+ resourceLocation); } DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory(); XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(beanFactory); reader.loadBeanDefinitions(new UrlResource(resourceLocation)); return beanFactory; }
public TableIndexProperties(String propertyName, String classFixedPart) { this.propertyName = propertyName; this.classFixedPart = classFixedPart; this.propertiesMap = new JRPropertiesMap(); }
protected List<ExtensionsRegistry> loadRegistries(JRPropertiesMap properties, Map<String, Exception> registryExceptions) { List<ExtensionsRegistry> registries = new ArrayList<ExtensionsRegistry>(); List<PropertySuffix> factoryProps = JRPropertiesUtil.getProperties(properties, PROPERTY_REGISTRY_FACTORY_PREFIX); for (Iterator<PropertySuffix> it = factoryProps.iterator(); it.hasNext();) { PropertySuffix factoryProp = it.next(); String registryId = factoryProp.getSuffix(); String factoryClass = factoryProp.getValue(); if (log.isDebugEnabled()) { log.debug("Instantiating registry of type " + factoryClass + " for property " + factoryProp.getKey()); } try { ExtensionsRegistry registry = instantiateRegistry( properties, registryId, factoryClass); registries.add(registry); } catch (Exception e) { //skip this registry //error logging is deferred after the registries are cached to avoid a loop from JRRuntimeException.resolveMessage registryExceptions.put(registryId, e); } } return registries; }
protected ExtensionsRegistry instantiateRegistry( JRPropertiesMap props, String registryId, String factoryClass) { if (log.isDebugEnabled()) { log.debug("Instantiating extensions registry for " + registryId + " using factory class " + factoryClass); } ExtensionsRegistryFactory factory = (ExtensionsRegistryFactory) ClassUtils.instantiateClass(factoryClass, ExtensionsRegistryFactory.class); return factory.createRegistry(registryId, props); }
protected URL detectDuplicate(JRPropertiesMap properties, Map<URL, URLRegistries> registries) { URL duplicateURL = null; for (Entry<URL, URLRegistries> registryEntry : registries.entrySet()) { JRPropertiesMap entryProperties = registryEntry.getValue().properties; if (ObjectUtils.equals(properties, entryProperties)) { duplicateURL = registryEntry.getKey(); break; } } return duplicateURL; }
public JRPropertiesMap getJRProperties() { if (properties == null) { return null; } return properties.getPropertiesMap(); }
@Override public ExtensionsRegistry createRegistry(String registryId, JRPropertiesMap properties) { List<PropertySuffix> castorMappingProperties = JRPropertiesUtil.getProperties(properties, CASTOR_MAPPING_PROPERTY_PREFIX); List<CastorMapping> castorMappings = new ArrayList<CastorMapping>(); for (Iterator<PropertySuffix> it = castorMappingProperties.iterator(); it.hasNext();) { PropertySuffix castorMappingProp = it.next(); String key; String version; String suffix = castorMappingProp.getSuffix(); int versionSeparatorIndex = suffix.lastIndexOf(CASTOR_MAPPING_VERSION_SEPARATOR); if (versionSeparatorIndex < 0) { key = suffix; version = null; } else { key = suffix.substring(0, versionSeparatorIndex); version = suffix.substring(versionSeparatorIndex + 1, suffix.length()); } String castorMappingPath = castorMappingProp.getValue(); CastorMapping mapping = new CastorMapping(key, version, castorMappingPath); castorMappings.add(mapping); } return new ListExtensionRegistry<CastorMapping>(CastorMapping.class, castorMappings); }
@Override public ExtensionsRegistry createRegistry(String registryId, JRPropertiesMap properties) { List<String> classNames = new ArrayList<String>(); addFunctionClasses(classNames, properties, EXPRESSION_FUNCTIONS_CLASSES_PROPERTY_PREFIX); addFunctionClasses(classNames, properties, FUNCTIONS_CLASSES_PROPERTY_PREFIX); return new SingletonExtensionRegistry<FunctionsBundle>(FunctionsBundle.class, new FunctionsBundle(classNames)); }