propertiesPaths.addObject(path);
}
}
public static NSArray<String> pathsForUserAndBundleProperties(boolean reportLoggingEnabled) {
NSMutableArray<String> propertiesPaths = new NSMutableArray();
NSMutableArray<String> projectsInfo = new NSMutableArray();
/* Properties for frameworks */
NSArray frameworkNames = (NSArray) NSBundle.frameworkBundles().valueForKey("name");
Enumeration e = frameworkNames.reverseObjectEnumerator();
while (e.hasMoreElements()) {
String frameworkName = (String) e.nextElement();
String propertyPath = ERXFileUtilities.pathForResourceNamed("Properties", frameworkName, null);
addIfPresent(frameworkName + ".framework", propertyPath, propertiesPaths, projectsInfo);
/** Properties.dev -- per-Framework-dev properties
* This adds support for Properties.dev in your Frameworks new load order will be
*/
String devPropertiesPath = ERXApplication.isDevelopmentModeSafe() ? ERXProperties.variantPropertiesInBundle("dev", frameworkName) : null;
addIfPresent(frameworkName + ".framework.dev", devPropertiesPath, propertiesPaths, projectsInfo);
/** Properties.<userName> -- per-Framework-per-User properties */
String userPropertiesPath = ERXProperties.variantPropertiesInBundle(ERXSystem.getProperty("user.name"), frameworkName);
addIfPresent(frameworkName + ".framework.user", userPropertiesPath, propertiesPaths, projectsInfo);
}
NSBundle mainBundle = NSBundle.mainBundle();
if( mainBundle != null ) {
String mainBundleName = mainBundle.name();
String appPath = ERXFileUtilities.pathForResourceNamed("Properties", "app", null);
addIfPresent(mainBundleName + ".app", appPath, propertiesPaths, projectsInfo);
}
/* WebObjects.properties in the user home directory */
String userHome = ERXSystem.getProperty("user.home");
if (userHome != null && userHome.length() > 0) {
File file = new File(userHome, "WebObjects.properties");
if (file.exists() && file.isFile() && file.canRead()) {
try {
String userHomePath = file.getCanonicalPath();
addIfPresent("{$user.home}/WebObjects.properties", userHomePath, propertiesPaths, projectsInfo);
}
catch (java.io.IOException ex) {
ERXProperties.log.error("Failed to load the configuration file '" + file.getAbsolutePath() + "'.", ex);
}
}
}
/* Optional properties files */
if (optionalConfigurationFiles() != null && optionalConfigurationFiles().count() > 0) {
for (Enumeration configEnumerator = optionalConfigurationFiles().objectEnumerator(); configEnumerator.hasMoreElements();) {
String configFile = (String) configEnumerator.nextElement();
File file = new File(configFile);
if (file.exists() && file.isFile() && file.canRead()) {
try {
String optionalPath = file.getCanonicalPath();
addIfPresent("Optional Configuration", optionalPath, propertiesPaths, projectsInfo);
}
catch (java.io.IOException ex) {
ERXProperties.log.error("Failed to load configuration file '" + file.getAbsolutePath() + "'.", ex);
}
}
else {
ERXProperties.log.error("The optional configuration file '" + file.getAbsolutePath() + "' either does not exist or could not be read.");
}
}
}
optionalPropertiesLoader(ERXSystem.getProperty("user.name"), propertiesPaths, projectsInfo);
/** /etc/WebObjects/AppName/Properties -- per-Application-per-Machine properties */
String applicationMachinePropertiesPath = ERXProperties.applicationMachinePropertiesPath("Properties");
addIfPresent("Application-Machine Properties", applicationMachinePropertiesPath, propertiesPaths, projectsInfo);
/** Properties.dev -- per-Application-dev properties */
String applicationDeveloperPropertiesPath = ERXProperties.applicationDeveloperProperties();
addIfPresent("Application-Developer Properties", applicationDeveloperPropertiesPath, propertiesPaths, projectsInfo);
/** Properties.<userName> -- per-Application-per-User properties */
String applicationUserPropertiesPath = ERXProperties.applicationUserProperties();
addIfPresent("Application-User Properties", applicationUserPropertiesPath, propertiesPaths, projectsInfo);
/* Report the result */
if (reportLoggingEnabled && projectsInfo.count() > 0 && log.isInfoEnabled()) {
StringBuilder message = new StringBuilder();
message.append("\n\n").append("ERXProperties has found the following Properties files: \n");
message.append(projectsInfo.componentsJoinedByString("\n"));
message.append('\n');
message.append("ERXProperties currently has the following properties:\n");
message.append(ERXProperties.logString(ERXSystem.getProperties()));
// ERXLogger.configureLoggingWithSystemProperties();
log.info(message.toString());