Search in sources :

Example 1 with BasicDNSServerSettingsProvider

use of org.nhindirect.dns.provider.BasicDNSServerSettingsProvider in project nhin-d by DirectProject.

the class WSDNSServerConfig method getServerSettings.

/*
	 * Just use the basic settings provider for now.  Will only allow setting the port and IP bindings.
	 */
private Provider<DNSServerSettings> getServerSettings() {
    String ipBindings = "";
    int port = 0;
    try {
        Setting[] settings = cfService.getSettingsByNames(new String[] { DNS_SERVER_BINDING, DNS_SERVER_PORT });
        if (settings != null && settings.length > 0) {
            for (Setting setting : settings) {
                if (setting.getName().equalsIgnoreCase(DNS_SERVER_BINDING)) {
                    ipBindings = setting.getValue();
                } else if (setting.getName().equalsIgnoreCase(DNS_SERVER_PORT)) {
                    String sPort = setting.getValue();
                    try {
                        port = Integer.parseInt(sPort);
                    } catch (Exception e) {
                        LOGGER.warn("Could not parse port setting " + port + " from configuration service");
                    }
                }
            }
        }
    } catch (Exception e) {
        LOGGER.warn("Could not get DNS setting from web service.");
    }
    if ((ipBindings == null || ipBindings.length() == 0) && port == 0 && settings != null) {
        LOGGER.info("Using DNS server settings from injected provider.");
        return settings;
    }
    LOGGER.info("Using DNS server settings from configuration service.");
    return new BasicDNSServerSettingsProvider(ipBindings, port);
}
Also used : BasicDNSServerSettingsProvider(org.nhindirect.dns.provider.BasicDNSServerSettingsProvider) Setting(org.nhind.config.Setting)

Aggregations

Setting (org.nhind.config.Setting)1 BasicDNSServerSettingsProvider (org.nhindirect.dns.provider.BasicDNSServerSettingsProvider)1