public static List<JRSaveContributor> createBuiltinContributors(JasperReportsContext context, Locale locale, ResourceBundle resourceBundle) { ArrayList<JRSaveContributor> contributors = new ArrayList<JRSaveContributor>(DEFAULT_CONTRIBUTORS.length); for (String contributorClassName : DEFAULT_CONTRIBUTORS) { try { Class<?> saveContribClass = JRClassLoader.loadClassForName(contributorClassName); Constructor<?> constructor = saveContribClass.getConstructor(CONSTRUCTOR_SIGNATURE); JRSaveContributor saveContrib = (JRSaveContributor) constructor.newInstance(context, locale, resourceBundle); contributors.add(saveContrib); } catch (Exception e) { // shouldn't happen, but log anyway log.warn("Error creating save contributor of type " + contributorClassName, e); } } return contributors; }
@Override public Class<?> getValueClass() { if (valueClass == null) { String className = getValueClassRealName(); if (className != null) { try { valueClass = JRClassLoader.loadClassForName(className); } catch(ClassNotFoundException e) { throw new JRRuntimeException(e); } } } return valueClass; }
@Override public Class<?> getNestedType() { if (nestedTypeName != null && nestedType == null) { try { nestedType = JRClassLoader.loadClassForName(nestedTypeName); } catch(ClassNotFoundException e) { throw new JRRuntimeException(e); } } return nestedType; }
/** * @deprecated To be removed. */ @Override public Class<?> getValueClass() { if (valueClass == null) { String className = getValueClassRealName(); if (className != null) { try { valueClass = JRClassLoader.loadClassForName(className); } catch(ClassNotFoundException e) { throw new JRRuntimeException(e); } } } return valueClass; }
@Override public Class<?> getIncrementerFactoryClass() { if (incrementerFactoryClass == null) { String className = getIncrementerFactoryClassRealName(); if (className != null) { try { incrementerFactoryClass = JRClassLoader.loadClassForName(className); } catch(ClassNotFoundException e) { throw new JRRuntimeException(e); } } } return incrementerFactoryClass; }
@Override public Class<?> getValueClass() { if (valueClass == null) { String className = getValueClassRealName(); if (className != null) { try { valueClass = JRClassLoader.loadClassForName(className); } catch (ClassNotFoundException e) { throw new JRRuntimeException( EXCEPTION_MESSAGE_KEY_BUCKET_LOAD_ERROR, (Object[])null, e); } } } return valueClass; }
@Override public Class<?> getValueClass() { if (valueClass == null) { String className = JRClassLoader.getClassRealName(valueClassName); if (className != null) { try { valueClass = JRClassLoader.loadClassForName(className); } catch (ClassNotFoundException e) { throw new JRRuntimeException( EXCEPTION_MESSAGE_KEY_MEASURE_VALUE_LOAD_ERROR, (Object[])null, e); } } } return valueClass; }
@Override public Class<?> getIncrementerFactoryClass() { if (incrementerFactoryClass == null) { String className = JRClassLoader.getClassRealName(incrementerFactoryClassName); if (className != null) { try { incrementerFactoryClass = JRClassLoader.loadClassForName(className); } catch (ClassNotFoundException e) { throw new JRRuntimeException( EXCEPTION_MESSAGE_KEY_MEASURE_INCREMENTER_LOAD_ERROR, (Object[])null, e); } } } return incrementerFactoryClass; }
protected void verifyFormatFactoryClass() { String formatFactoryClassName = jasperDesign.getFormatFactoryClass(); if (formatFactoryClassName != null) { try { Class<?> formatFactoryClass = JRClassLoader.loadClassForName(formatFactoryClassName); if (!FormatFactory.class.isAssignableFrom(formatFactoryClass)) { addBrokenRule("The report format factory class is not compatible with " + FormatFactory.class.getName(), jasperDesign); } } catch (ClassNotFoundException e) { addBrokenRule(e.toString(), jasperDesign); } } }
/** * */ private ClassLoader getClassLoader() { ClassLoader clsLoader = Thread.currentThread().getContextClassLoader(); if (clsLoader != null) { try { Class.forName(JRJdtCompiler.class.getName(), true, clsLoader); } catch (ClassNotFoundException e) { clsLoader = null; //if (log.isWarnEnabled()) // log.warn("Failure using Thread.currentThread().getContextClassLoader() in JRJdtCompiler class. Using JRJdtCompiler.class.getClassLoader() instead."); } } if (clsLoader == null) { clsLoader = JRClassLoader.class.getClassLoader(); } return clsLoader; }
@Override public Class<?> getIncrementerFactoryClass() { if (incrementerFactoryClass == null) { String className = getIncrementerFactoryClassRealName(); if (className != null) { try { incrementerFactoryClass = JRClassLoader.loadClassForName(className); } catch (ClassNotFoundException e) { throw new JRRuntimeException( EXCEPTION_MESSAGE_KEY_MEASURE_INCREMENTER_CLASS_LOAD_ERROR, (Object[])null, e); } } } return incrementerFactoryClass; }
@Override public Class<?> getValueClass() { if (valueClass == null) { String className = getValueClassRealName(); if (className != null) { try { valueClass = JRClassLoader.loadClassForName(className); } catch (ClassNotFoundException e) { throw new JRRuntimeException( EXCEPTION_MESSAGE_KEY_MEASURE_VALUE_CLASS_LOAD_ERROR, (Object[])null, e); } } } return valueClass; }
@Override public Class<?> getPercentageCalculatorClass() { if (percentageCalculatorClass == null) { String className = getPercentageCalculatorClassRealName(); if (className != null) { try { percentageCalculatorClass = JRClassLoader.loadClassForName(className); } catch (ClassNotFoundException e) { throw new JRRuntimeException( EXCEPTION_MESSAGE_KEY_MEASURE_PERCENTAGE_CALCULATOR_CLASS_LOAD_ERROR, (Object[])null, e); } } } return percentageCalculatorClass; }
protected ProtectionDomain getProtectionDomain() { ProtectionDomain domain = protectionDomain; if (domain == null) { synchronized (this) { domain = protectionDomain; if (domain == null) { ProtectionDomainFactory protectionDomainFactory = JRClassLoader.getProtectionDomainFactory(); domain = protectionDomain = protectionDomainFactory.getProtectionDomain(this); } } } return domain; }
protected ProtectionDomain getProtectionDomain() { ProtectionDomain domain = protectionDomain; if (domain == null) { synchronized (this) { domain = protectionDomain; if (domain == null) { ProtectionDomainFactory protectionDomainFactory = JRClassLoader.getProtectionDomainFactory(); domain = protectionDomain = protectionDomainFactory.getProtectionDomain( Codegen.class.getClassLoader()); } } } return domain; }
/** * */ private ClassLoader getClassLoader() { ClassLoader clsLoader = Thread.currentThread().getContextClassLoader(); if (clsLoader != null) { try { Class.forName(JRJdtCompiler.class.getName(), true, clsLoader); } catch (ClassNotFoundException e) { clsLoader = null; // if (log.isWarnEnabled()) // log.warn("Failure using Thread.currentThread().getContextClassLoader() in JRJdtCompiler class. Using JRJdtCompiler.class.getClassLoader() instead."); } } if (clsLoader == null) clsLoader = JRClassLoader.class.getClassLoader(); return clsLoader; }
/** * */ protected void initSaveContributors() { final String[] DEFAULT_CONTRIBUTORS = { "net.sf.jasperreports.view.save.JRPrintSaveContributor", "net.sf.jasperreports.view.save.JRPdfSaveContributor", "net.sf.jasperreports.view.save.JRRtfSaveContributor", "net.sf.jasperreports.view.save.JROdtSaveContributor", "net.sf.jasperreports.view.save.JRHtmlSaveContributor", "net.sf.jasperreports.view.save.JRSingleSheetXlsSaveContributor", "net.sf.jasperreports.view.save.JRMultipleSheetsXlsSaveContributor", "net.sf.jasperreports.view.save.JRCsvSaveContributor", "net.sf.jasperreports.view.save.JRXmlSaveContributor", "net.sf.jasperreports.view.save.JREmbeddedImagesXmlSaveContributor" }; for(int i = 0; i < DEFAULT_CONTRIBUTORS.length; i++) { try { Class saveContribClass = JRClassLoader.loadClassForName(DEFAULT_CONTRIBUTORS[i]); Constructor constructor = saveContribClass.getConstructor(new Class[]{Locale.class, ResourceBundle.class}); JRSaveContributor saveContrib = (JRSaveContributor)constructor.newInstance(new Object[]{getLocale(), resourceBundle}); saveContributors.add(saveContrib); } catch (Exception e) { } } }
/** * */ private String getValueClassRealName() { if (valueClassRealName == null) { valueClassRealName = JRClassLoader.getClassRealName(valueClassName); } return valueClassRealName; }
/** * @deprecated To be removed. */ private String getValueClassRealName() { if (valueClassRealName == null) { valueClassRealName = JRClassLoader.getClassRealName(valueClassName); } return valueClassRealName; }
/** * */ private String getIncrementerFactoryClassRealName() { if (incrementerFactoryClassRealName == null) { incrementerFactoryClassRealName = JRClassLoader.getClassRealName(incrementerFactoryClassName); } return incrementerFactoryClassRealName; }
private String getValueClassRealName() { if (valueClassRealName == null) { valueClassRealName = JRClassLoader.getClassRealName(valueClassName); } return valueClassRealName; }
@Override protected JREvaluator loadEvaluator(Serializable compileData, String className) throws JRException { JREvaluator evaluator = null; try { Class<?> clazz = getClassFromCache(className); if (clazz == null) { clazz = JRClassLoader.loadClassFromBytes(className, (byte[]) compileData); putClassInCache(className, clazz); } if (JRPropertiesUtil.getInstance(jasperReportsContext).getBooleanProperty(PROPERTY_EVALUATOR_CLASS_REFERENCE_FIX_ENABLED)) { //FIXME multiple classes per thread? classFromBytesRef.set(clazz); } evaluator = (JREvaluator) clazz.newInstance(); } catch (Exception e) { throw new JRException( EXCEPTION_MESSAGE_KEY_EXPRESSION_CLASS_NOT_LOADED, new Object[]{className}, e); } return evaluator; }
/** * */ protected JRChartCustomizer createAndInitCustomizer( String customizerClassName, String customizerName ) { JRChartCustomizer customizer = null; if (customizerClassName != null && customizerClassName.length() > 0) { try { Class<?> customizerClass = JRClassLoader.loadClassForName(customizerClassName); customizer = (JRChartCustomizer) customizerClass.newInstance(); } catch (Exception e) { throw new JRRuntimeException( EXCEPTION_MESSAGE_KEY_CUSTOMIZER_INSTANCE_ERROR, (Object[])null, e); } if (customizer instanceof JRAbstractChartCustomizer) { ((JRAbstractChartCustomizer) customizer).init(this); } if (customizer instanceof NamedChartCustomizer) { ((NamedChartCustomizer) customizer).setName(customizerName); } } return customizer; }
/** * Gets the incrementer to be used for this copied value. */ public JRIncrementer getIncrementer() { if (incrementer == null) { String incrementerFactoryClassName = getIncrementerFactoryClassName(); JRIncrementerFactory incrementerFactory; if (incrementerFactoryClassName == null) { JRVariable toVariable = filler.getVariable(getToVariable()); incrementerFactory = JRDefaultIncrementerFactory.getFactory(toVariable.getValueClass()); } else { try { Class<?> incrementerFactoryClass = JRClassLoader.loadClassForName(incrementerFactoryClassName); incrementerFactory = JRIncrementerFactoryCache.getInstance(incrementerFactoryClass); } catch (ClassNotFoundException e) { throw new JRRuntimeException( EXCEPTION_MESSAGE_KEY_INCREMENTER_CLASS_NOT_FOUND, new Object[]{incrementerFactoryClassName}, e); } } incrementer = incrementerFactory.getIncrementer(getCalculation().getValue()); } return incrementer; }
/** * */ private String getPercentageCalculatorClassRealName() { if (percentageCalculatorClassRealName == null) { percentageCalculatorClassRealName = JRClassLoader.getClassRealName(percentageCalculatorClassName); } return percentageCalculatorClassRealName; }
/** * */ public void addFunctionClass(String className) { try { Class<?> clazz = JRClassLoader.loadClassForName(className); addFunctionClass(clazz); } catch (ClassNotFoundException e) { throw new JRRuntimeException(e); } }
/** * */ // JG Jul 2012 Added Docx Contributor protected void initSaveContributors() { final String[] defaultContributors = { "net.sf.jasperreports.view.save.JRCsvSaveContributor", "net.sf.jasperreports.view.save.JRDocxSaveContributor", "net.sf.jasperreports.view.save.JREmbeddedImagesXmlSaveContributor", "net.sf.jasperreports.view.save.JRHtmlSaveContributor", "net.sf.jasperreports.view.save.JRMultipleSheetsXlsSaveContributor", "net.sf.jasperreports.view.save.JROdtSaveContributor", "net.sf.jasperreports.view.save.JRPdfSaveContributor", "net.sf.jasperreports.view.save.JRPrintSaveContributor", "net.sf.jasperreports.view.save.JRRtfSaveContributor", "net.sf.jasperreports.view.save.JRSingleSheetXlsSaveContributor", "net.sf.jasperreports.view.save.JRXmlSaveContributor", }; for(int i = 0; i < defaultContributors.length; i++) { try { Class saveContribClass = JRClassLoader.loadClassForName(defaultContributors[i]); Constructor constructor = saveContribClass.getConstructor(new Class[]{Locale.class, ResourceBundle.class}); JRSaveContributor saveContrib = (JRSaveContributor)constructor.newInstance(new Object[]{getLocale(), resourceBundle}); saveContributors.add(saveContrib); } catch (ClassNotFoundException | NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { } } }
/** * */ protected void initSaveContributors() { final String[] DEFAULT_CONTRIBUTORS = { "net.sf.jasperreports.view.save.JRPrintSaveContributor", "net.sf.jasperreports.view.save.JRPdfSaveContributor", "net.sf.jasperreports.view.save.JRRtfSaveContributor", "net.sf.jasperreports.view.save.JROdtSaveContributor", "net.sf.jasperreports.view.save.JRHtmlSaveContributor", "net.sf.jasperreports.view.save.JRSingleSheetXlsSaveContributor", "net.sf.jasperreports.view.save.JRMultipleSheetsXlsSaveContributor", "net.sf.jasperreports.view.save.JRCsvSaveContributor", "net.sf.jasperreports.view.save.JRXmlSaveContributor", "net.sf.jasperreports.view.save.JREmbeddedImagesXmlSaveContributor" }; for(int i = 0; i < DEFAULT_CONTRIBUTORS.length; i++) { try { Class saveContribClass = JRClassLoader.loadClassForName(DEFAULT_CONTRIBUTORS[i]); Constructor constructor = saveContribClass.getConstructor(new Class[]{Locale.class, ResourceBundle.class}); JRSaveContributor saveContrib = (JRSaveContributor)constructor.newInstance(new Object[]{getLocale(), getViewerContext().getResourceBundle()}); saveContributors.add(saveContrib); } catch (Exception e) { } } }