Configures with a properties file, which could be on either the file system
(file: location) or the class path (classpath: location).
769836
public void setPropertiesLocation(String location) {
        Properties properties = load(null, new PathMatchingResourcePatternResolver(), location);
        if (properties != null && properties.size() > 0) {
            configure(properties);
        }
    }
804156
public static void setInitFilePath(String filePath) {
		filePath=getPropertiesFilePath(filePath);
		
		if (staticFileProperties == null) {
			staticFileProperties=new FileProperties(filePath);
		} else {
			staticFileProperties.setInitFilePath(filePath);
		}
	}
248129
public static void modifySelfConfig(String configAbsoluteClassPath, Map<IConfigKey, String> modifyConfig)
            throws IOException {
        OneProperties configs = otherConfigs.get(configAbsoluteClassPath);
        if (configs == null) {
            return;
        }
        configs.modifyConfig(modifyConfig);
    }
969592
private static void configure()
    {
        String propertyFile = System.getProperty( SYSTEM_PROPERTY, PROPERTYFILENAME );

        InputStream in = findConfigFile( propertyFile,
                                         "/com/ecyrd/speed4j/default_speed4j.properties");

        configure(in);
    }
318107
def setBundlePath(path):
    
    if os.path.exists(path):
        Settings.BundlePath = path
    else:
        raise OSError("File not found: " + path)
742904
protected void loadConfigs() {
        configs = new Properties();
        // If run as a jar, find in file system classpath first, if not found, then get resource in jar.
        if (ClassPathUtil.testRunMainInJar()) {
            String[] classPathsInFileSystem = ClassPathUtil.getAllClassPathNotInJar();
            String workDir = System.getProperty("user.dir");
            String mainJarRelativePath = ClassPathUtil.getClassPathsInSystemProperty()[0];
            File mainJar = new File(workDir, mainJarRelativePath);
            File mainJarDir = mainJar.getParentFile();
            for (String classPath : classPathsInFileSystem) {
                File classPathFile = new File(classPath);
                File configFile;
                if (classPathFile.isAbsolute()) {
                    configFile = new File(classPathFile, propertiesAbsoluteClassPath);
                } else {
                    configFile = new File(new File(mainJarDir, classPath), propertiesAbsoluteClassPath);
                }
                if (configFile.exists() && configFile.isFile()) {
                    InputStream is = null;
                    try {
                        is = new FileInputStream(configFile);
                        loadConfigsFromStream(is);
                    } catch (FileNotFoundException e) {
                        LOGGER.warn("Load config file " + configFile.getPath() + " error!", e);
                    }
                    return;
                }
            }
        }
        if (propertiesFilePath == null) {
            if (propertiesAbsoluteClassPath == null) {
                return;
            }
            InputStream is = OneProperties.class.getResourceAsStream(propertiesAbsoluteClassPath);
            loadConfigsFromStream(is);
        } else {
            configs = PropertiesIO.load(propertiesFilePath);
        }
    }
1366767
protected void modifyConfig(Map<? extends IConfigKey, String> modifyConfig) throws IOException {
        if (propertiesFilePath == null) {
            LOGGER.warn("Config " + propertiesAbsoluteClassPath + " is not a file, maybe just a resource in library.");
        }
        if (configs == null) {
            loadConfigs();
        }
        for (IConfigKey key : modifyConfig.keySet()) {
            if (modifyConfig.get(key) != null) {
                configs.setProperty(key.getKeyString(), modifyConfig.get(key));
            }
        }
        PropertiesIO.store(propertiesFilePath, configs);
    }
309072
private static Properties load() {
		Properties properties = new Properties();

		String file = System.getProperty(CONFIGURATION_PROPERTY);
		try {
			if (file != null) {
				InputStream stream;
				if (URL_DETECTION_PATTERN.matcher(file).matches()) {
					stream = new URL(file).openStream();
				} else {
					stream = Thread.currentThread().getContextClassLoader().getResourceAsStream(file);
					if (stream == null) {
						stream = new FileInputStream(file);
					}
				}
				load(properties, stream);
			} else {
				InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream(DEFAULT_CONFIGURATION_FILE);
				if (stream != null) {
					load(properties, stream);
				}
			}
		} catch (IOException ex) {
			InternalLogger.log(Level.ERROR, "Failed loading configuration from '" + file + "'");
		}

		for (Object key : new ArrayList<Object>(System.getProperties().keySet())) {
			String name = (String) key;
			if (name.startsWith(PROPERTIES_PREFIX)) {
				properties.put(name.substring(PROPERTIES_PREFIX.length()), System.getProperty(name));
			}
		}

		for (Entry<Object, Object> entry : properties.entrySet()) {
			String value = (String) entry.getValue();
			if (value.indexOf('{') != -1) {
				value = resolve(value, EnvironmentVariableResolver.INSTANCE);
				value = resolve(value, SystemPropertyResolver.INSTANCE);
				properties.put(entry.getKey(), value);
			}
		}

		return properties;
	}
1034079
private void init() {
		Collection<String> paths = StringSupport.split(classpath, ";:", false);

		for (String location : paths) {

			location = FileSupport.convertToUnixStylePath(location);
			if (location.endsWith(".zip") || location.endsWith(".jar")) {
				mapFilesInZip(location);
			} else {
				File dir = new File(location);
				if (dir.isDirectory()) {
					if (!location.endsWith("/")) {
						location += '/';
					}
					Collection<File> classFiles = FileSupport.getFilesInDirectoryTree(dir);
					for (File file : classFiles) {
						String fileName = file.getPath();
						if ((fileName.endsWith(".jar") || fileName.endsWith(".zip")) && !file.isHidden()) {
							mapFilesInZip(fileName);
						} else { // .class .properties etc.
							mapClassResourceEntry(file.getPath().substring(location.length()), file);
							fileCreationTimes.put(file, new Long(file.lastModified()));
						}
					}
				} else {
					//path can not be mapped
				}
			}
		}
	}
1075116
protected void configure() {
		String className = AsyncFileLogger.class.getName();
		ClassLoader cl = Thread.currentThread().getContextClassLoader();

		// Get configured log directory
		directory = getProperty(className + ".directory", "");
		if (directory.isEmpty()) {
			directory = getProperty("moleculer.log.directory", "");
		}

		// Automatic directory selection
		// services.moleculer.logger.AsyncFileLogger.directory = #AUTO
		if (directory.startsWith("#")) {
			String found = null;

			// Detect by "catalina.home" System Property
			String path = System.getProperty("catalina.home");
			if (path != null && path.length() > 0) {
				File test = new File(path, "logs");
				if (test.isDirectory()) {
					found = test.getAbsolutePath();
				}
			}

			// Detect by classpath
			if (found == null) {

				// Lehetséges útvonalak
				HashSet<String> paths = new HashSet<String>();
				paths.add("/moleculer");
				paths.add("/Program Files/moleculer");
				paths.add("/Program Files (x86)/moleculer");
				paths.add("/opt/moleculer");

				String cp = System.getProperty("java.class.path");
				if (paths != null) {
					String pathSeparator = System.getProperty("path.separator");
					if (pathSeparator == null || pathSeparator.length() == 0) {
						pathSeparator = ";:";
					}
					StringTokenizer st = new StringTokenizer(cp, pathSeparator);
					while (st.hasMoreTokens()) {
						path = st.nextToken().trim();
						if (path.length() > 0) {
							path = path.replace('\\', '/');
							int index = path.lastIndexOf('/');
							if (index > -1) {
								path = path.substring(0, index);
							}
							paths.add(path);
						}
					}
				}
				for (String test : paths) {
					found = findLogDirectory(new File(test));
					if (found != null) {
						found = found.replace('\\', '/');
						break;
					}
				}
			}
			if (found == null) {
				found = System.getProperty("user.home", "") + "/logs";
			}
			directory = found;
		}

		if (directory.isEmpty()) {
			logDirectory = null;
		} else {
			logDirectory = new File(directory);
			if (!logDirectory.isDirectory()) {
				logDirectory.mkdirs();
			}
		}

		if (prefix == null) {
			prefix = getProperty(className + ".prefix", "moleculer-");
		}

		// Set 'compress after days' property
		String day = getProperty(className + ".compressAfter", "");
		if (!day.isEmpty()) {
			if (!day.endsWith("days")) {
				throw new IllegalArgumentException("The \"compressAfter\" must be in days (eg. \"14 days\")!");
			}
			compressAfterDays = Integer.parseInt(day.substring(0, day.length() - 4).trim());
		}

		// Set "delete after days" property
		day = getProperty(className + ".deleteAfter", "");
		if (!day.isEmpty()) {
			if (!day.endsWith("days")) {
				throw new IllegalArgumentException("The \"deleteAfter\" must be in days (eg. \"14 days\")!");
			}
			deleteAfterDays = Integer.parseInt(day.substring(0, day.length() - 4).trim());
			if (deleteAfterDays < compressAfterDays || compressAfterDays < 2 || deleteAfterDays < 2) {
				throw new IllegalArgumentException("Invalid values (delete logs after " + deleteAfterDays
						+ " days, compress logs after " + compressAfterDays + " days)!");
			}
		}

		// Set formatter
		String formatterName = getProperty(className + ".formatter", null);
		if (formatterName != null && !formatterName.isEmpty()) {
			try {
				setFormatter((Formatter) cl.loadClass(formatterName).newInstance());
			} catch (Exception ignored) {
			}
		}
		if (getFormatter() == null) {
			setFormatter(new FastLogFormatter());
		}

		// Set file encoding
		fileEncoding = getProperty(className + ".encoding", "UTF8");

		// Log to console
		logToConsole = Boolean.parseBoolean(getProperty(className + ".logToConsole", "false"));

		// Enable colors
		enableColors = Boolean.parseBoolean(getProperty(className + ".enableColors", "true"));

		// Set level
		setLevel(Level.parse(getProperty(className + ".level", Level.INFO.toString())));

		// Print log directory
		if (logDirectory != null) {
			try {
				LogRecord record = new LogRecord(Level.INFO,
						"Directory of log files: " + logDirectory.getCanonicalPath());
				record.setSourceClassName(AsyncFileLogger.class.getName());
				publish(record);
			} catch (Exception cause) {
				cause.printStackTrace();
			}
		}
	}
1097668
@Override
    protected void configure() {
        // ***** Properties *****
        URL resource = getClass().getResource("/URIMapper.txt");
        if (resource == null) {
            log.debug("No /URIMapper.txt resource exists.");
        } else {
            bind(File.class).annotatedWith(Names.named("uri-mappings")).toInstance(
                    new File(resource.getFile()));            
        }
    }
549639
private static boolean couldBeYarnConfigurationPath(final String path) {
    return path.contains("conf") ||
            path.contains("etc") ||
            path.contains(HadoopEnvironment.HADOOP_CONF_DIR);
  }
478817
@Override
	public void configure(Configuration parameters) {
		// get the file path
		String filePath = parameters.getString(FILE_PARAMETER_KEY, null);
		if (filePath != null) {
			try {
				this.filePath = new Path(filePath);
			}
			catch (RuntimeException rex) {
				throw new RuntimeException("Could not create a valid URI from the given file path name: " + rex.getMessage()); 
			}
		}
		else if (this.filePath == null) {
			throw new IllegalArgumentException("File path was not specified in input format, or configuration."); 
		}
	}
1124756
private void mapClassResourceEntry(String fileName, Object location) {
		Object previouslyFoundLocation = mixedResourceLocations.get(fileName);
		if (previouslyFoundLocation != null && !previouslyFoundLocation.equals(location)) {
			//this may indicate a conflict
			//it occurs frequently for "/MANIFEST.MF" which shouldn't be a problem
			//it may occur for other resources
			//log those occurrences that seem suspicious
			registerMultipleLocations(fileName, location);
			return;
		}
		if (fileName.endsWith(".properties")) {
			String className = convertFileNameToClassName(fileName);
			propertiesResourceLocations.put(className, fileName);
		} else if (fileName.endsWith(".class")) {
			String className = convertFileNameToClassName(fileName);
			classResourceLocations.put(className, location);
		}
		mixedResourceLocations.put(fileName, location);
	}
1145283
private void setUpInternalProperties() {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.entry(tc, "setUpInternalProperties");
        }

        if (getLocation() != null) {
            // KEYSTORE CUSTOM PROPERTIES
            Map<String, String> otherProps = getCustomProps();
            if (otherProps != null) {
                for (Entry<String, String> current : otherProps.entrySet()) {
                    setProperty(current.getKey(), current.getValue());
                }
            }

            // load as key store
            String keyStoreProvider = getProvider();
            if (keyStoreProvider != null) {
                setProperty(Constants.SSLPROP_KEY_STORE_PROVIDER, keyStoreProvider);
            }

            // KEYSTORE NAME
            String keyStoreName = getName();
            if (keyStoreName != null) {
                setProperty(Constants.SSLPROP_KEY_STORE_NAME, keyStoreName);
            }

            // KEYSTORE PASSWORD
            String keyStorePassword = getPassword();
            if (keyStorePassword != null) {
                setProperty(Constants.SSLPROP_KEY_STORE_PASSWORD, keyStorePassword);
            }

            // KEYSTORE LOCATION
            String keyStoreLocation = getLocation();
            if (keyStoreLocation != null) {
                setProperty(Constants.SSLPROP_KEY_STORE, keyStoreLocation);
            }

            // KEYSTORE IS FILE BASED
            if (getFileBased() != null) {
                setProperty(Constants.SSLPROP_KEY_STORE_FILE_BASED, getFileBased().toString());
            }

            // KEYSTORE TYPE
            String keyStoreType = getType();
            if (keyStoreType != null) {
                setProperty(Constants.SSLPROP_KEY_STORE_TYPE, keyStoreType);

                if (!keyStoreType.equalsIgnoreCase(Constants.KEYSTORE_TYPE_JKS) && !keyStoreType.equalsIgnoreCase(Constants.KEYSTORE_TYPE_JCEKS)
                    && !keyStoreType.equalsIgnoreCase(Constants.KEYSTORE_TYPE_PKCS12)) {
                    setProperty(Constants.SSLPROP_KEY_STORE_FILE_BASED, Constants.FALSE);
                }

                if (keyStoreType.equalsIgnoreCase(Constants.KEYSTORE_TYPE_JAVACRYPTO)) {
                    setProperty(Constants.SSLPROP_TOKEN_ENABLED, Constants.TRUE);

                    // set appropriate provider for jvm vendor
                    if (JavaInfo.vendor().equals(JavaInfo.Vendor.IBM))
                        setProperty(Constants.SSLPROP_KEY_STORE_PROVIDER, IBMPKCS11Impl_PROVIDER_NAME);
                    else
                        setProperty(Constants.SSLPROP_KEY_STORE_PROVIDER, SUNPKCS11_PROVIDER_NAME);
                }
            }

            // KEYSTORE IS READ ONLY
            if (getReadOnly() != null)
                setProperty(Constants.SSLPROP_KEY_STORE_READ_ONLY, getReadOnly().toString());

            // KEYSTORE IS INITIALIZED AT STARTUP
            if (getInitializeAtStartup() != null)
                setProperty(Constants.SSLPROP_KEY_STORE_INITIALIZE_AT_STARTUP, getInitializeAtStartup().toString());

            // KEYSTORE STASH FOR CMS
            if (getStashFile() != null)
                setProperty(Constants.SSLPROP_KEY_STORE_CREATE_CMS_STASH, getStashFile().toString());

        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.exit(tc, "setUpInternalProperties");
        }
    }
24179
@Override
    public void setFile(File file) {
        configFile = file;
        if (tc.isDebugEnabled())
            Tr.debug(tc, "Jaspi configuration of persistent providers will be stored in file: " + file);
    }
1339867
public void addClasspath(Map<String, Object> conf, String classpath) {
    String cpKey = Config.TOPOLOGY_ADDITIONAL_CLASSPATH;

    if (conf.containsKey(cpKey)) {
      String newEntry = String.format("%s:%s", conf.get(cpKey), classpath);
      conf.put(cpKey, newEntry);
    } else {
      conf.put(cpKey, classpath);
    }
  }