@VisibleForTesting protected Extension loadFromFile(File localFile) throws InvalidConfigException {
  Preconditions.checkNotNull(localFile);
  Preconditions.checkState(localFile.exists());
  Closer closer=Closer.create();
  try {
    InputStream fileIn=closer.register(new FileInputStream(localFile));
    Extension extension=factory.build(fileIn);
    extension.setRowType(normalizeRowType(extension.getRowType()));
    log.info("Successfully loaded extension " + extension.getRowType());
    return extension;
  }
 catch (  IOException e) {
    log.error("Can't access local extension file (" + localFile.getAbsolutePath() + ")",e);
    throw new InvalidConfigException(TYPE.INVALID_EXTENSION,"Can't access local extension file");
  }
catch (  SAXException e) {
    log.error("Can't parse local extension file (" + localFile.getAbsolutePath() + ")",e);
    throw new InvalidConfigException(TYPE.INVALID_EXTENSION,"Can't parse local extension file: " + e.getMessage());
  }
catch (  ParserConfigurationException e) {
    log.error("Can't create sax parser",e);
    throw new InvalidConfigException(TYPE.INVALID_EXTENSION,"Can't create sax parser");
  }
 finally {
    try {
      closer.close();
    }
 catch (    IOException e) {
      log.debug("Failed to close input stream on extension file",e);
    }
  }
}

@ VisibleForTesting protected Extension loadFromFile ( File localFile ) throws InvalidConfigException { Preconditions . checkNotNull ( localFile ) ; Preconditions . checkState ( localFile . exists ( ) ) ; Closer closer = Closer . create ( ) ; try { InputStream fileIn = closer . register ( new FileInputStream ( localFile ) ) ; Extension extension = factory . build ( fileIn ) ; extension . setRowType ( normalizeRowType ( extension . getRowType ( ) ) ) ; log . info ( "Successfully loaded extension " + extension . getRowType ( ) ) ; return extension ; } catch ( IOException e ) { log . error ( "Can't access local extension file (" + localFile . getAbsolutePath ( ) + ")" , e ) ; throw new InvalidConfigException ( TYPE . INVALID_EXTENSION , "Can't access local extension file" ) ; } catch ( SAXException e ) { log . error ( "Can't parse local extension file (" + localFile . getAbsolutePath ( ) + ")" , e ) ; throw new InvalidConfigException ( TYPE . INVALID_EXTENSION , "Can't parse local extension file: " + e . getMessage ( ) ) ; } catch ( ParserConfigurationException e ) { log . error ( "Can't create sax parser" , e ) ; throw new InvalidConfigException ( TYPE . INVALID_EXTENSION , "Can't create sax parser" ) ; } finally { try { closer . close ( ) ; } catch ( IOException e ) { log . debug ( "Failed to close input stream on extension file" , e ) ; } } }
reads an extension from file and returns it .
