/** * @param config */ @SuppressWarnings("unchecked") private void initExtractor(ExtractorConfig<T> config) { try { Class<T> rdd = config.getExtractorImplClass(); if (rdd == null) { rdd = (Class<T>) Class.forName(config.getExtractorImplClassName()); } Constructor<T> c = null; if (config.getEntityClass().isAssignableFrom(Cells.class)) { c = rdd.getConstructor(); this.extractor = (IExtractor<T, ExtractorConfig<T>>) c.newInstance(); } else { c = rdd.getConstructor(Class.class); this.extractor = (IExtractor<T, ExtractorConfig<T>>) c.newInstance(config.getEntityClass()); } } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) { LOG.error("Impossible to make an extractor instance, check classpath " + e.getMessage()); throw new DeepInstantiationException( "Impossible to make an extractor instance, check classpath " + e.getMessage()); } }
private ExtractorConfig createDeepJobConfig() { ExtractorConfig extractorConfig = mock(ExtractorConfig.class); when(extractorConfig.getExtractorImplClass()).thenReturn(new Object().getClass()); // when(extractorConfig.getInputFormatClass()).thenReturn(null); return extractorConfig; }
/** * @param config */ @SuppressWarnings("unchecked") private void initExtractor(ExtractorConfig<T> config) { try { Class<T> rdd = config.getExtractorImplClass(); if (rdd == null) { rdd = (Class<T>) Class.forName(config.getExtractorImplClassName()); } Constructor<T> c = null; if (config.getEntityClass().isAssignableFrom(Cells.class)) { c = rdd.getConstructor(); this.extractor = (IExtractor<T, ExtractorConfig<T>>) c.newInstance(); } else { c = rdd.getConstructor(Class.class); this.extractor = (IExtractor<T, ExtractorConfig<T>>) c.newInstance(config.getEntityClass()); } } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) { LOG.error("Impossible to make an extractor instance, check classpath " + e.getMessage()); throw new DeepInstantiationException( "Impossible to make an extractor instance, check classpath " + e.getMessage()); } }