MAConfig implements XmlConvertible { public RecordSource createRecordSource(Configuration conf) throws Exception { String className = getRecordSourceSpiClassName(); RecordSourceSpi service; if (className != null) { service = RecordSourceSpi.getForClassName(className); } else { service = RecordSourceSpi.getForUrl(getRecordSourceUrl()); } if (service != null) { return service.createRecordSource(getRecordSourceUrl(), conf); } else { if (className != null) { throw new IllegalStateException("record source reader service " + className + " of point data file not found"); } else { ServiceLoader<RecordSourceSpi> loader = ServiceLoader.load(RecordSourceSpi.class, Thread.currentThread().getContextClassLoader()); StringBuilder supportedExtensions = new StringBuilder(); for (RecordSourceSpi spi : loader) { for (String extension : spi.getAcceptedExtensions()) { if (supportedExtensions.length() > 0) { supportedExtensions.append(", "); } supportedExtensions.append(extension); } } throw new IllegalArgumentException("no record source reader found for filename extension of " + getRecordSourceUrl() + " point data file (one of " + supportedExtensions + " expected)"); } } } MAConfig(); static MAConfig get(Configuration conf); static MAConfig fromXml(String xml); @Override String toXml(); RecordSource createRecordSource(Configuration conf); String getRecordSourceSpiClassName(); void setRecordSourceSpiClassName(String recordSourceSpiClassName); String getRecordSourceUrl(); void setRecordSourceUrl(String recordSourceUrl); String getOutputTimeFormat(); void setOutputTimeFormat(String outputTimeFormat); String getOutputGroupName(); void setOutputGroupName(String outputGroupName); boolean getCopyInput(); void setCopyInput(boolean copyInput); int getMacroPixelSize(); void setMacroPixelSize(int macroPixelSize); String getMaxTimeDifference(); void setMaxTimeDifference(String maxTimeDifference); Double getFilteredMeanCoeff(); void setFilteredMeanCoeff(Double filteredMeanCoeff); String getGoodPixelExpression(); void setGoodPixelExpression(String goodPixelExpression); String getGoodRecordExpression(); void setGoodRecordExpression(String goodRecordExpression); boolean getFilterOverlapping(); void setFilterOverlapping(boolean filterOverlapping); boolean getSaveProcessedProducts(); void setSaveProcessedProducts(boolean saveProcessedProducts); VariableMapping[] getVariableMappings(); void setVariableMappings(VariableMapping[] variableMappings); boolean getOnlyExtractComplete(); void setOnlyExtractComplete(boolean onlyExtractComplete); static boolean isMaxTimeDifferenceValid(String maxTimeDifference);  }
@Test public void testCreateRecordSource() throws Exception { MAConfig maConfig = new MAConfig(); maConfig.setRecordSourceSpiClassName(TestRecordSourceSpi.class.getName()); RecordSource recordSource = maConfig.createRecordSource(new Configuration()); assertNotNull(recordSource); assertNotNull(recordSource.getRecords()); Iterator<Record> recordIterator = recordSource.getRecords().iterator(); assertTrue(recordIterator.hasNext()); Record record = recordIterator.next(); assertNotNull(record); }