/** * Gets extractor instance. * * @param config the config * @return the extractor instance */ public static <T, S extends BaseConfig> IExtractor<T, S> getExtractorInstance(S config) { try { Class<T> rdd = (Class<T>) config.getExtractorImplClass(); if (rdd == null) { rdd = (Class<T>) Class.forName(config.getExtractorImplClassName()); } Constructor<T> c; if (config.getEntityClass().isAssignableFrom(Cells.class)) { c = rdd.getConstructor(); return (IExtractor<T, S>) c.newInstance(); } else { c = rdd.getConstructor(Class.class); return (IExtractor<T, S>) c.newInstance(config.getEntityClass()); } } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) { String message = "A exception happens and we wrap with DeepExtractorInitializationException" + e.getMessage(); LOG.error(message); throw new DeepExtractorInitializationException(message,e); } }
/** * Gets extractor instance. * * @param config the config * @return the extractor instance */ public static <T, S extends BaseConfig> IExtractor<T, S> getExtractorInstance(S config) { try { Class<T> rdd = (Class<T>) config.getExtractorImplClass(); if (rdd == null) { rdd = (Class<T>) Class.forName(config.getExtractorImplClassName()); } Constructor<T> c; if (config.getEntityClass().isAssignableFrom(Cells.class)) { c = rdd.getConstructor(); return (IExtractor<T, S>) c.newInstance(); } else { c = rdd.getConstructor(Class.class); return (IExtractor<T, S>) c.newInstance(config.getEntityClass()); } } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) { String message = "A exception happens and we wrap with DeepExtractorInitializationException" + e.getMessage(); LOG.error(message); throw new DeepExtractorInitializationException(message,e); } }