/** * Load a configuration from a resource on this classpath. * If the resource is not found, an empty configuration is returned * @param resource the resource name * @return the loaded configuration. */ public static Configuration loadFromResource(String resource) { Configuration conf = new Configuration(false); URL resURL = getResourceUrl(resource); if (resURL != null) { log.debug("loaded resources from {}", resURL); conf.addResource(resource); } else{ log.debug("failed to find {} on the classpath", resource); } return conf; }
/** * Load a configuration from a resource on this classpath. * If the resource is not found, an empty configuration is returned * @param resource the resource name * @return the loaded configuration. */ public static Configuration loadFromResource(String resource) { Configuration conf = new Configuration(false); URL resURL = getResourceUrl(resource); if (resURL != null) { log.debug("loaded resources from {}", resURL); conf.addResource(resource); } else{ log.debug("failed to find {} on the classpath", resource); } return conf; }
/** * Load a resource that must be on the classpath * @param resource the resource name * @return the loaded configuration * @throws FileNotFoundException if the resource is missing */ public static Configuration loadMandatoryResource(String resource) throws FileNotFoundException { Configuration conf = new Configuration(false); URL resURL = getResourceUrl(resource); if (resURL != null) { log.debug("loaded resources from {}", resURL); conf.addResource(resource); } else { throw new FileNotFoundException(resource); } return conf; }
/** * Load a resource that must be on the classpath * @param resource the resource name * @return the loaded configuration * @throws FileNotFoundException if the resource is missing */ public static Configuration loadMandatoryResource(String resource) throws FileNotFoundException { Configuration conf = new Configuration(false); URL resURL = getResourceUrl(resource); if (resURL != null) { log.debug("loaded resources from {}", resURL); conf.addResource(resource); } else { throw new FileNotFoundException(resource); } return conf; }
/** * Register a resource as a default resource. * Do not attempt to use this unless you understand that the * order in which default resources are loaded affects the outcome, * and that subclasses of Configuration often register new default * resources * @param resource the resource name * @return the URL or null */ public static URL registerDefaultResource(String resource) { URL resURL = getResourceUrl(resource); if (resURL != null) { Configuration.addDefaultResource(resource); } return resURL; }
/** * Register a resource as a default resource. * Do not attempt to use this unless you understand that the * order in which default resources are loaded affects the outcome, * and that subclasses of Configuration often register new default * resources * @param resource the resource name * @return the URL or null */ public static URL registerDefaultResource(String resource) { URL resURL = getResourceUrl(resource); if (resURL != null) { Configuration.addDefaultResource(resource); } return resURL; }
/** * Inject the {@link SliderKeys#SLIDER_XML} resource * into the configuration resources <i>of all configurations</i>. * <p> * This operation is idempotent. * <p> * If the resource is not on the classpath, downgrades, rather than * fails. * @return true if the resource was found and loaded. */ public static synchronized boolean injectSliderXMLResource() { if (sliderResourceInjectionAttempted.getAndSet(true)) { return sliderResourceInjected.get(); } URL resourceUrl = getResourceUrl(SliderKeys.SLIDER_XML); if (resourceUrl != null) { Configuration.addDefaultResource(SliderKeys.SLIDER_XML); sliderResourceInjected.set(true); } return sliderResourceInjected.get(); }
/** * Inject the {@link SliderKeys#SLIDER_XML} resource * into the configuration resources <i>of all configurations</i>. * <p> * This operation is idempotent. * <p> * If the resource is not on the classpath, downgrades, rather than * fails. * @return true if the resource was found and loaded. */ public static synchronized boolean injectSliderXMLResource() { if (sliderResourceInjectionAttempted.getAndSet(true)) { return sliderResourceInjected.get(); } URL resourceUrl = getResourceUrl(SliderKeys.SLIDER_XML); if (resourceUrl != null) { Configuration.addDefaultResource(SliderKeys.SLIDER_XML); sliderResourceInjected.set(true); } return sliderResourceInjected.get(); }
URL serverXmlUrl = ConfigHelper.getResourceUrl(SLIDER_SERVER_XML); if (serverXmlUrl != null) { log.info("Loading {} at {}", SLIDER_SERVER_XML, serverXmlUrl);
URL serverXmlUrl = ConfigHelper.getResourceUrl(SLIDER_SERVER_XML); if (serverXmlUrl != null) { log.info("Loading {} at {}", SLIDER_SERVER_XML, serverXmlUrl);