public Config getMetricConfig(String name) throws ConfigurationException { return env.getConfigurator().getConfig(SRMetric.class, name); }
/** * Constructs a new factory that creates an sr metric with a particular name from the config * file. The overrides take precedence over any configuration parameters, and are relative to * the innermost configuration block for an SR metric (i.e. the nested dictionary with key * the name of the metric). * * @param language * @param configurator * @param name Name of metric from configuration file * @param configOverrides Optional configuration overrides, or null. * @throws ConfigurationException */ public ConfigMonolingualSRFactory(Language language, Configurator configurator, String name, Map<String, Object> configOverrides) throws ConfigurationException { this.config = ConfigFactory.empty(); if (configOverrides != null) { config = config.withFallback(ConfigFactory.parseMap(configOverrides)); } config = config.withFallback(configurator.getConfig(SRMetric.class, name)); this.configurator = configurator; this.name = name; this.language = language; }
@Override public String describeDisambiguator() { if (!config.hasPath("disambiguator")){ return "none"; } String disambigName = config.getString("disambiguator"); try { Map dc = configurator.getConfig(Disambiguator.class, disambigName).root().unwrapped(); String phraseName = null; if (dc.containsKey("phraseAnalyzer")) { phraseName = (String) dc.get("phraseAnalyzer"); } if (phraseName == null || phraseName.equals("default")) { phraseName = configurator.getConf().get().getString("phrases.analyzer.default"); } dc.put("phraseAnalyzer", phraseName); return disambigName + "=" + dc.toString(); } catch (ConfigurationException e) { throw new IllegalStateException(e); } }
Config config = getConfig(klass, name); Map<String, Object> cache = components.get(klass); String key = makeCacheKey(name, runtimeParams);
@Override public boolean runDiagnostic(PrintWriter writer) { Config config = null; try { config = env.getConfigurator().getConfig(WpDataSource.class, null); } catch (ConfigurationException e) { throw new IllegalStateException(e); } boolean passed = true; try { WpDataSource ds = env.getConfigurator().get(WpDataSource.class); ds.getConnection().close(); writer.write("Connection to database succeeded. Active configuration:\n"); } catch (Exception e) { writer.write("Connection to database FAILED! Active configuration:\n"); passed = false; } for (Map.Entry<String, ConfigValue > entry : config.entrySet()) { writer.write("\t" + entry.getKey() + ": " + entry.getValue().render() + "\n"); } return passed; } }
Config config = getConfig(klass, name); Map<String, Object> cache = components.get(klass); String key = makeCacheKey(name, runtimeParams);
@Override public boolean runDiagnostic(PrintWriter writer) { Config config = null; try { config = env.getConfigurator().getConfig(WpDataSource.class, null); } catch (ConfigurationException e) { throw new IllegalStateException(e); } boolean passed = true; try { WpDataSource ds = env.getConfigurator().get(WpDataSource.class); ds.getConnection().close(); writer.write("Connection to database succeeded. Active configuration:\n"); } catch (Exception e) { writer.write("Connection to database FAILED! Active configuration:\n"); passed = false; } for (Map.Entry<String, ConfigValue > entry : config.entrySet()) { writer.write("\t" + entry.getKey() + ": " + entry.getValue().render() + "\n"); } return passed; } }
config = env.getConfigurator().getConfig(PostGISDB.class, null); } catch (ConfigurationException e) { throw new IllegalStateException(e);
config = env.getConfigurator().getConfig(PostGISDB.class, null); } catch (ConfigurationException e) { throw new IllegalStateException(e);