jmingo-core/src/main/java/org/jmingo/config/MongoConfig.java
public class MongoConfig {

    public static String DEF_HOST = ServerAddress.defaultHost();
    public static int DEF_PORT = ServerAddress.defaultPort();

    private final String databaseHost;
    private final int databasePort;
    private final String dbName;
    private final String writeConcern;

    private Map<String, String> options;

    private MongoConfig() {
        throw new UnsupportedOperationException("private constructor, use builder instead");
    }

    public static Builder builder() {
        return new Builder();
    }

    public String getDatabaseHost() {
        return databaseHost;
    }

    public int getDatabasePort() {
        return databasePort;
    }

    public String getDbName() {
        return dbName;
    }

    public String getWriteConcern() {
        return writeConcern;
    }

    public Map<String, String> getOptions() {
        return options;
    }

    public MongoConfig(Builder builder) {
        this.databaseHost = builder.databaseHost;
        this.databasePort = builder.databasePort;
        this.dbName = builder.dbName;
        this.options = builder.options;
        this.writeConcern = builder.writeConcern;
    }

    public static class Builder {
        private String databaseHost = DEF_HOST;
        private int databasePort = DEF_PORT;
        private String dbName;
        private String writeConcern;
        private Map<String, String> options = new HashMap<>();

        public Builder dbHost(String host) {
            this.databaseHost = host;
            return this;
        }

        public Builder dbPort(int port) {
            this.databasePort = port;
            return this;
        }

        public Builder dbName(String db) {
            this.dbName = db;
            return this;
        }

        public Builder writeConcern(String writeConcern) {
            this.writeConcern = writeConcern;
            return this;
        }

        /**
         * Mongo options, to get more info see {@link com.mongodb.MongoClientOptions}.
         *
         * @param options options
         */
        public void options(Map<String, String> options) {
            this.options = options;
        }

        public void option(String name, String val) {
            options.put(name, val);
        }

        public MongoConfig build() {
            return new MongoConfig(this);
        }
    }

}
jmingo-core/src/main/java/org/jmingo/parser/xml/dom/DocumentBuilderFactoryCreator.java
public static DocumentBuilderFactory createDocumentBuilderFactory(ParserConfiguration parserConfiguration)
    throws ParserConfigurationException {
    DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
    documentBuilderFactory.setValidating(parserConfiguration.isValidate());
    documentBuilderFactory.setNamespaceAware(parserConfiguration.isNamespaceAware());
    documentBuilderFactory.setFeature(ParserConstants.DYNAMIC_VALIDATION, true);
    List<Source> sourceList = createSchemaSources(parserConfiguration.getXsdSchemaPaths());
    if (CollectionUtils.isNotEmpty(sourceList)) {
        documentBuilderFactory.setSchema(createSchema(sourceList));
    }
    return documentBuilderFactory;
}
jmingo-core/src/main/java/org/jmingo/parser/xml/dom/util/DomUtil.java
public static String getAttributeString(Node node, String attributeName) {
    Validate.notNull(node, "getAttributeString::node cannot be null");
    String value = StringUtils.EMPTY;
    if (node.hasAttributes()) {
        value = getAttributes(node).get(attributeName);
    }
    return value;
}
jmingo-core/src/main/java/org/jmingo/parser/xml/dom/util/DomUtil.java
public static void assertPositive(int val, String msg) {
    if (val < 0) {
        throw new IllegalArgumentException(msg);
    }
}
jmingo-core/src/main/java/org/jmingo/parser/Parser.java
public interface Parser<T> {

    /**
     * Parse data from file with specified path.
     *
     * @param path the path to file to parse
     * @return specific domain object as result of parsing
     * @throws org.jmingo.exceptions.JMingoParserException {@link org.jmingo.exceptions.JMingoParserException}
     */
    T parse(Path path) throws JMingoParserException;
}
jmingo-core/src/main/java/org/jmingo/config/ContextDefinition.java
public class ContextDefinition {

    private QuerySetConfig querySetConfig;

    private MongoConfig mongoConfig;

    /* default converter class */
    private String defaultConverter;
    /* package to scan for converters */
    private String converterPackageScan;

    /**
     * Gets query set configuration.
     *
     * @return {@link QuerySetConfig}
     */
    public QuerySetConfig getQuerySetConfig() {
        return querySetConfig;
    }

    /**
     * Sets query set configuration.
     *
     * @param querySetConfig {@link QuerySetConfig}
     */
    public void setQuerySetConfig(QuerySetConfig querySetConfig) {
        this.querySetConfig = querySetConfig;
    }

    /**
     * Gets database host. see {@link #getMongoConfig()}.
     *
     * @return database host
     */
    public String getDatabaseHost() {
        return mongoConfig.getDatabaseHost();
    }

    /**
     * Gets database port. see {@link #getMongoConfig()}.
     *
     * @return database port
     */
    public int getDatabasePort() {
        return mongoConfig.getDatabasePort();
    }


    /**
     * Sets default converter.
     *
     * @param fullClassName full converter class name
     */
    public void setDefaultConverter(String fullClassName) {
        this.defaultConverter = fullClassName;
    }

    /**
     * Gets default converter.
     *
     * @return converter class
     */
    public String getDefaultConverter() {
        return defaultConverter;
    }

    /**
     * Gets converter package scan.
     *
     * @return converter package scan
     */
    public String getConverterPackageScan() {
        return converterPackageScan;
    }

    /**
     * Sets converter package scan.
     *
     * @param converterPackageScan the converter package scan
     */
    public void setConverterPackageScan(String converterPackageScan) {
        this.converterPackageScan = converterPackageScan;
    }

    /**
     * Gets mongo config.
     *
     * @return mongo config
     */
    public MongoConfig getMongoConfig() {
        return mongoConfig;
    }

    /**
     * Sets mongo config.
     *
     * @param mongoConfig the mongo config
     */
    public void setMongoConfig(MongoConfig mongoConfig) {
        this.mongoConfig = mongoConfig;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this)
                .append("mongoConfig", mongoConfig)
                .append("querySetConfiguration", querySetConfig)
                .append("defaultConverter", defaultConverter)
                .append("converterPackageScan", converterPackageScan)
                .toString();
    }
}
jmingo-core/src/main/java/org/jmingo/exceptions/JMingoParserException.java
public class JMingoParserException extends RuntimeException {

    /**
     * Default constructor.
     */
    public JMingoParserException() {
    }

    /**
     * Constructor with parameters.
     *
     * @param message message
     */
    public JMingoParserException(String message) {
        super(message);
    }

    /**
     * Constructor with parameters.
     *
     * @param cause cause
     */
    public JMingoParserException(Throwable cause) {
        super(cause);
    }

    /**
     * Constructor with parameters.
     *
     * @param message message
     * @param cause   cause
     */
    public JMingoParserException(String message, Throwable cause) {
        super(message, cause);
    }
}
jmingo-core/src/main/java/org/jmingo/parser/xml/dom/util/DomUtil.java
public static Node getFirstTagOccurrence(Element element, String tagName) {
    Node firstNode = null;
    NodeList nodeList = element.getElementsByTagName(tagName);
    if (nodeList != null && nodeList.getLength() > 0) {
        firstNode = nodeList.item(FIRST_ELEMENT);
    }
    return firstNode;
}
jmingo-core/src/main/java/org/jmingo/parser/xml/dom/util/DomUtil.java
public static List<Node> getAllChildNodes(Node root, String name) {
    if (!root.hasChildNodes()) {
        return Collections.emptyList();
    }
    List<Node> nodes = new ArrayList<>();
    for (int index = 0; index < root.getChildNodes().getLength(); index++) {
        if (name.equals(root.getChildNodes().item(index).getNodeName())) {
            nodes.add(root.getChildNodes().item(index));
        }
        if (root.getChildNodes().item(index).hasChildNodes()) {
            nodes.addAll(getAllChildNodes(root.getChildNodes().item(index), name));
        }
    }
    return nodes;
}
jmingo-core/src/main/java/org/jmingo/config/QuerySetConfig.java
public class QuerySetConfig {

    private Set<String> querySets = Sets.newHashSet();

    /**
     * Gets query sets.
     *
     * @return query sets
     */
    public Set<String> getQuerySets() {
        return querySets;
    }

    /**
     * Add query set.
     *
     * @param querySet query set
     */
    public void addQuerySet(String querySet) {
        Validate.notBlank(querySet, "query set path cannot be empty");
        querySets.add(querySet);
    }

    /**
     * Add query sets.
     *
     * @param pQuerySets the query sets to add
     */
    public void addQuerySet(Set<String> pQuerySets) {
        if (CollectionUtils.isNotEmpty(pQuerySets)) {
            querySets.addAll(pQuerySets);
        }
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("QuerySetConfig{");
        sb.append("querySets=").append(querySets);
        sb.append('}');
        return sb.toString();
    }
}
jmingo-core/src/main/java/org/jmingo/parser/xml/dom/util/DomUtil.java
public static int getAttributeInt(Node node, String attributeName) {
    Validate.notNull(node, "getAttributeInt::node cannot be null");
    String value = getAttributeString(node, attributeName);
    return Integer.parseInt(value);
}


Question: import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Validate;
import org.jmingo.config.ContextDefinition;
import org.jmingo.config.MongoConfig;
import org.jmingo.config.QuerySetConfig;
import org.jmingo.exceptions.JMingoParserException;
import org.jmingo.parser.Parser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.ErrorHandler;
import org.xml.sax.InputSource;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import java.io.FileInputStream;
import java.io.InputStream;
import java.nio.file.Path;
import java.util.Set;
import static org.jmingo.parser.xml.dom.DocumentBuilderFactoryCreator.createDocumentBuilderFactory;
import static org.jmingo.parser.xml.dom.util.DomUtil.assertPositive;
import static org.jmingo.parser.xml.dom.util.DomUtil.getAllChildNodes;
import static org.jmingo.parser.xml.dom.util.DomUtil.getAttributeInt;
import static org.jmingo.parser.xml.dom.util.DomUtil.getAttributeString;
import static org.jmingo.parser.xml.dom.util.DomUtil.getFirstTagOccurrence;
/**
 * Copyright 2013-2014 The JMingo Team
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.jmingo.parser.xml.dom;




/**
 * This class is implementation of {@link Parser} interface to parse context configuration.
 * See context.xsd schema for details.
 */
public class ContextDefinitionParser implements Parser<ContextDefinition> {

    private DocumentBuilderFactory documentBuilderFactory;

    private ErrorHandler parseErrorHandler;

    private static final Logger LOGGER = LoggerFactory.getLogger(ContextDefinitionParser.class);

    private static final String CONTEXT_TAG = "context";

    private static final String QUERY_SET_CONFIG_TAG = "querySetConfig";
    private static final String QUERY_SET_TAG = "querySet";
    private static final String QUERY_SET_PATH_ATTR = "path";

    private static final String MONGO_TAG = "mongo";
    private static final String MONGO_HOST_ATTR = "host";
    private static final String MONGO_PORT_ATTR = "port";
    private static final String MONGO_DBNAME_ATTR = "dbName";

    private static final String DEFAULT_CONVERTER_TAG = "defaultConverter";
    private static final String CONVERTERS_TAG = "converters";
    private static final String CONVERTERS_PACKAGE_ATTR = "package";
    private static final String CONVERTER_CLASS_ATTR = "class";
    private static final String WRITE_CONCERN_ATTR = "writeConcern";
    private static final String OPTIONS_TAG = "options";
    private static final String OPTION_TAG = "option";

    /**
     * Constructor with parameters.
     *
     * @param parserConfiguration parser configuration {@link ParserConfiguration}
     * @param parseErrorHandler   parser error handler {@link ErrorHandler}
     * @throws ParserConfigurationException {@link ParserConfigurationException}
     */
    public ContextDefinitionParser(ParserConfiguration parserConfiguration, ErrorHandler parseErrorHandler)
            throws ParserConfigurationException {
        this.documentBuilderFactory = createDocumentBuilderFactory(parserConfiguration);
        this.parseErrorHandler = parseErrorHandler;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public ContextDefinition parse(Path path) throws JMingoParserException {
        LOGGER.debug("parse context configuration: {}", path);
        ContextDefinition contextDefinition;
        try (InputStream is = new FileInputStream(path.toFile())) {
            DocumentBuilder builder = documentBuilderFactory.newDocumentBuilder();
            builder.setErrorHandler(parseErrorHandler);
            Document document = builder.parse(new InputSource(is));
            contextDefinition = new ContextDefinition();
            Element element = document.getDocumentElement();
            contextDefinition.setQuerySetConfig(parseQuerySetConfigTag(element));
            contextDefinition.setMongoConfig(parseMongoTag(element));
            parseConvertersTag(contextDefinition, element);
            contextDefinition.setDefaultConverter(parseDefaultConverterTag(element));
        } catch(Exception e) {
            throw new JMingoParserException(e);
        }
        return contextDefinition;
    }

    /**
     * Parse <querySetConfig/> tag.
     *
     * @param element element of XML document
     * @return set of paths queries definitions
     */
Answer:     private QuerySetConfig parseQuerySetConfigTag(Element element) throws JMingoParserException {