public SRBuilder(Env env, String metricName, Language language) throws ConfigurationException { this.env = env; this.language = language; this.config = env.getConfiguration(); this.srDir = new File(config.get().getString("sr.metric.path")); datasetNames = config.get().getStringList("sr.dataset.defaultsets"); // Properly resolve the default metric name. this.metricName = env.getConfigurator().resolveComponentName(SRMetric.class, metricName); if (!srDir.isDirectory()) { srDir.mkdirs(); } }
name = resolveComponentName(klass, name); Config config = getConfig(klass, name); Map<String, Object> cache = components.get(klass);
/** * Returns the config object associated with the given class and name. * @param klass The generic interface or superclass, not the specific implementation. * @param name The name of the class as it appears in the config file. If name is null, * the configurator tries to guess by looking for a "default" entry in * the config that provides the name for a default implementation or, if * there is exactly one implementation returning it. Otherwise, if name is * null it throws an error. * @return The requested config object. * @throws ConfigurationException */ public Config getConfig(Class klass, String name) throws ConfigurationException { if (!providers.containsKey(klass)) { throw new ConfigurationException("No registered providers for components with class " + klass); } ProviderSet pset = providers.get(klass); name = resolveComponentName(klass, name); String path = pset.path + "." + name; if (!conf.get().hasPath(path)) { throw new ConfigurationException("Configuration path " + path + " does not exist"); } return conf.get().getConfig(path); }
name = resolveComponentName(klass, name); Config config = getConfig(klass, name); Map<String, Object> cache = components.get(klass);
/** * Returns the config object associated with the given class and name. * @param klass The generic interface or superclass, not the specific implementation. * @param name The name of the class as it appears in the config file. If name is null, * the configurator tries to guess by looking for a "default" entry in * the config that provides the name for a default implementation or, if * there is exactly one implementation returning it. Otherwise, if name is * null it throws an error. * @return The requested config object. * @throws ConfigurationException */ public Config getConfig(Class klass, String name) throws ConfigurationException { if (!providers.containsKey(klass)) { throw new ConfigurationException("No registered providers for components with class " + klass); } ProviderSet pset = providers.get(klass); name = resolveComponentName(klass, name); String path = pset.path + "." + name; if (!conf.get().hasPath(path)) { throw new ConfigurationException("Configuration path " + path + " does not exist"); } return conf.get().getConfig(path); }