Ejemplo n.º 1
0
  private static JRCompiler getCompiler(JasperReport jasperReport) throws JRException {
    JRCompiler compiler = null;

    String compilerClassName = jasperReport.getCompilerClass();

    Class compilerClass = null;

    ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
    if (classLoader != null) {
      try {
        compilerClass = classLoader.loadClass(compilerClassName);
      } catch (ClassNotFoundException e) {
      }
    }

    if (compilerClass == null) {
      classLoader = JasperCompileManager.class.getClassLoader();
      try {
        if (classLoader == null) {
          compilerClass = Class.forName(compilerClassName);
        } else {
          compilerClass = classLoader.loadClass(compilerClassName);
        }
      } catch (ClassNotFoundException e) {
        throw new JRException("Report compiler class not found : " + compilerClassName);
      }
    }

    try {
      compiler = (JRCompiler) compilerClass.newInstance();
    } catch (Exception e) {
      throw new JRException("Could not instantiate report compiler : " + compilerClassName, e);
    }
    return compiler;
  }
Ejemplo n.º 2
0
 public static JREvaluator loadEvaluator(JasperReport jasperReport) throws JRException {
   return loadEvaluator(jasperReport, jasperReport.getMainDataset());
 }