protected Properties loadProperties()

in taverna-app-configuration-impl/src/main/java/org/apache/taverna/configuration/app/impl/ApplicationConfigurationImpl.java [211:246]


	protected Properties loadProperties(String resourceName) {
		// Ordered list of config locations to attempt to load
		// properties from
		List<URI> configs = new ArrayList<URI>();

		File startupDir = getStartupDir().toFile();
		if (startupDir != null) {
			configs.add(startupDir.toURI().resolve(CONF_DIR).resolve(resourceName));
			configs.add(startupDir.toURI().resolve(resourceName));
		}

		ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
		findInClassLoader(configs, contextClassLoader, CONF_DIR + resourceName);
		findInClassLoader(configs, contextClassLoader, resourceName);

		findInClassLoader(configs, getClass().getClassLoader(), CONF_DIR + resourceName);
		findInClassLoader(configs, getClass().getClassLoader(), resourceName);

		Properties loadedProps = new Properties();
		for (URI config : configs) {
			try {
				InputStream inputStream = config.toURL().openStream();
				loadedProps.load(inputStream);
			} catch (MalformedURLException ex) {
				throw new RuntimeException("Invalid URL from URI: " + config, ex);
			} catch (IOException ex) {
				continue; // Probably not found/access denied
			}
			if (!loadedProps.isEmpty()) {
				logger.debug("Loaded " + resourceName + " from " + config);
				return loadedProps;
			}
		}
		logger.debug("Could not find application properties file " + resourceName);
		return loadedProps;
	}