package net.sf.jasperreports.engine.util;

import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.query.JRQueryExecuterFactory;

public class JRQueryExecuterUtils {
  private static final JRSingletonCache cache = new JRSingletonCache(JRQueryExecuterFactory.class);
  
  public static JRQueryExecuterFactory getQueryExecuterFactory(String language) throws JRException {
    String factoryClassName = JRProperties.getProperty("net.sf.jasperreports.query.executer.factory." + language);
    if (factoryClassName == null)
      throw new JRException("No query executer factory class registered for " + language + " queries.  " + "Create a propery named " + "net.sf.jasperreports.query.executer.factory." + language + "."); 
    return (JRQueryExecuterFactory)cache.getCachedInstance(factoryClassName);
  }
}
