@Override public <T> List<T> getExtensions(Class<T> extensionType) { if (JRQueryExecuterFactoryBundle.class.equals(extensionType)) { return (List<T>) Collections.singletonList((Object)DefaultQueryExecuterFactoryBundle.getInstance()); } else if (ScriptletFactory.class.equals(extensionType)) { return (List<T>) Collections.singletonList((Object)DefaultScriptletFactory.getInstance()); } else if (ChartThemeBundle.class.equals(extensionType)) { return (List<T>) Collections.singletonList((Object)DefaultChartTheme.BUNDLE); } else if (GenericElementHandlerBundle.class.equals(extensionType)) { return (List<T>) Collections.singletonList((Object)HANDLER_BUNDLE); } else if (MessageProviderFactory.class.equals(extensionType)) { return (List<T>) Collections.singletonList((Object) new ResourceBundleMessageProviderFactory()); } return null; }
@SuppressWarnings("unchecked") public <T> List<T> getExtensions(Class<T> extensionType) { if (DataAdapterServiceFactory.class.equals(extensionType)) { if (dataAdapterServiceFactories == null) { dataAdapterServiceFactories = new ArrayList<DataAdapterServiceFactory>(); dataAdapterServiceFactories.add(HBaseDataAdapterServiceFactoryImpl.getInstance()); } return (List<T>) dataAdapterServiceFactories; } else if (JRQueryExecuterFactoryBundle.class.equals(extensionType)) { if (queryExecuterFactories == null) { queryExecuterFactories = new ArrayList<JRQueryExecuterFactoryBundle>(); queryExecuterFactories.add(HBaseQueryExecuterFactoryBundle.getInstance()); } return (List<T>) queryExecuterFactories; } return null; }
/** * */ public String[] getLanguages() { Set<String> langs = new HashSet<String>(); List<?> bundles = ExtensionsEnvironment.getExtensionsRegistry() .getExtensions(JRQueryExecuterFactoryBundle.class); for (Iterator<?> it = bundles.iterator(); it.hasNext();) { JRQueryExecuterFactoryBundle bundle = (JRQueryExecuterFactoryBundle) it .next(); if (!bundle.getClass().equals(this.getClass())) { String[] l = bundle.getLanguages(); for (int i = 0; i < l.length; i++) { langs.add(l[i]); } } } List<String> languages = new ArrayList<String>(); languages.addAll(langs); return languages.toArray(new String[languages.size()]); }
@SuppressWarnings("unchecked") public <T> List<T> getExtensions(Class<T> extensionType) { if (JRQueryExecuterFactoryBundle.class.equals(extensionType)) { logger.debug("Registering the ESQueryExecuterFactoryBundle"); return (List<T>) Collections .singletonList(ESQueryExecuterFactoryBundle .getInstance()); } return null; }
protected void init(ExtensionsRegistry extensionsRegistry) { ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader(); Object cl = jasperReportsContext.getValue(AbstractClasspathAwareDataAdapterService.CURRENT_CLASS_LOADER); if (cl != null && cl instanceof ClassLoader) Thread.currentThread().setContextClassLoader((ClassLoader) cl); try { oldExtensionsRegistry = extensionsRegistry; Set<String> langs = new HashSet<String>(); mqef = new HashMap<String, QueryExecuterFactory>(); List<JRQueryExecuterFactoryBundle> bundles = ExtensionsEnvironment.getExtensionsRegistry().getExtensions(JRQueryExecuterFactoryBundle.class); for (JRQueryExecuterFactoryBundle bundle : bundles) { if (!bundle.getClass().equals(this.getClass())) { if (bundle instanceof DefaultQueryExecuterFactoryBundle) bundle = DefaultQueryExecuterFactoryBundle.getInstance(jasperReportsContext); String[] l = bundle.getLanguages(); for (String lang : l) { langs.add(lang); if (!mqef.containsKey(lang)) try { mqef.put(lang, bundle.getQueryExecuterFactory(lang)); } catch (JRException e) { e.printStackTrace(); } } } } languages = langs.toArray(new String[langs.size()]); } finally { Thread.currentThread().setContextClassLoader(originalClassLoader); } }
public List getExtensions(Class extensionType) { if (JRQueryExecuterFactoryBundle.class.equals(extensionType)) { return Collections .singletonList(IRQueryExecuterFactoryBundle .getInstance()); } return null; }
public List getExtensions(Class extensionType) { if (JRQueryExecuterFactoryBundle.class.equals(extensionType)) return Collections.singletonList(EmptyQueryExecuterFactoryBundle.getInstance()); return null; }
@SuppressWarnings("unchecked") public <T> List<T> getExtensions(Class<T> extensionType) { if (JRQueryExecuterFactoryBundle.class.equals(extensionType)) return (List<T>) Collections.singletonList(HBaseQueryExecuterFactoryBundle.getInstance()); return null; }
/** * */ public QueryExecuterFactory getQueryExecuterFactory(String language) throws JRException { List<?> bundles = ExtensionsEnvironment.getExtensionsRegistry() .getExtensions(JRQueryExecuterFactoryBundle.class); for (Iterator<?> it = bundles.iterator(); it.hasNext();) { JRQueryExecuterFactoryBundle bundle = (JRQueryExecuterFactoryBundle) it .next(); if (!bundle.getClass().equals(this.getClass())) { QueryExecuterFactory factory = bundle .getQueryExecuterFactory(language); if (factory != null) { return factory; } } } // we have not found anything... let's see if iReport knows about it... //QueryExecuterDef List<QueryExecuterDef> qes = IReportManager.getInstance().getQueryExecuters(); for (QueryExecuterDef qe : qes) { if (qe.getLanguage().equals(language)) { try { return (QueryExecuterFactory)cache.getCachedInstance(qe.getClassName()); //QueryExecuterFactory)IReportManager.getJRExtensionsClassLoader().loadClass(qe.getClassName()).newInstance(); } catch (JRException ex) { if (log.isWarnEnabled()) log.warn("Unable to instance the create a QueryExecuterFactory for the language " + language + ": " + ex.getMessage()); System.out.println("Unable to instance the create a QueryExecuterFactory for the language " + language + ": " + ex.getMessage()); System.out.flush(); } } } if (log.isWarnEnabled()) log.warn("No query executer factory class registered for " + language + " queries."); return (QueryExecuterFactory) cache .getCachedInstance(IRQueryExecuterFactory.class.getName()); }