public QueryProfileRegistry read(String directory) {
        List<NamedReader> queryProfileReaders = new ArrayList<>();
        List<NamedReader> queryProfileTypeReaders = new ArrayList<>();
        try {
            File dir = new File(directory);
            if ( ! dir.isDirectory() ) throw new IllegalArgumentException("Could not read query profiles: '" +
                                                                          directory + "' is not a valid directory.");

            for (File file : sortFiles(dir)) {
                if ( ! file.getName().endsWith(".xml")) continue;
                queryProfileReaders.add(new NamedReader(file.getName(), new FileReader(file)));
            }
            File typeDir = new File(dir,"types");
            if (typeDir.isDirectory()) {
                for (File file : sortFiles(typeDir)) {
                    if ( ! file.getName().endsWith(".xml")) continue;
                    queryProfileTypeReaders.add(new NamedReader(file.getName(), new FileReader(file)));
                }
            }

            return read(queryProfileTypeReaders, queryProfileReaders);
        }
        catch (IOException e) {
            throw new IllegalArgumentException("Could not read query profiles from '" + directory + "'", e);
        }
        finally {
            closeAll(queryProfileReaders);
            closeAll(queryProfileTypeReaders);
        }
    }
Reads all query profile xml files in a given directory,
and all type xml files from the immediate subdirectory "types/" (if any)

@throws IllegalArgumentException if the directory is not readable, or if there is some error in the XML
container-search/src/main/java/com/yahoo/search/query/profile/config/QueryProfileXMLReader.java