use of com.webobjects.foundation.NSProperties in project wonder-slim by undur.
the class ERXLoader method bundleDidLoad.
/**
* Will be called after each bundle load. We use it to know when the last
* bundle loaded so we can post a notification for it. Note that the bundles
* will get loaded in the order of the classpath but the main bundle will
* get loaded last. So in order to set the properties correctly, we first
* add all the props that are not already set, then we add the main bundle
* and the WebObjects.properties and finally the command line props.
*/
public void bundleDidLoad(NSNotification n) {
NSBundle bundle = (NSBundle) n.object();
if (allFrameworks.contains(bundle.name())) {
allFrameworks.remove(bundle.name());
debugMsg("Loaded " + bundle.name() + ". Remaining: " + allFrameworks);
} else if (bundle.isFramework()) {
debugMsg("Loaded unexpected framework bundle '" + bundle.name() + "'. Ensure your build.properties settings like project.name match the bundle name (including case).");
}
if (allBundleProps == null) {
allBundleProps = new Properties();
}
String userName = propertyFromCommandLineFirst("user.name");
applyIfUnset(readProperties(bundle, "Properties." + userName));
applyIfUnset(readProperties(bundle, null));
if (allFrameworks.size() == 0) {
mainProps = null;
mainUserProps = null;
collectMainProps(userName);
allBundleProps.putAll(mainProps);
if (mainUserProps != null) {
allBundleProps.putAll(mainUserProps);
}
String userHome = propertyFromCommandLineFirst("user.home");
Properties userHomeProps = null;
if (userHome != null && userHome.length() > 0) {
userHomeProps = readProperties(new File(userHome, "WebObjects.properties"));
}
if (userHomeProps != null) {
allBundleProps.putAll(userHomeProps);
}
Properties props = NSProperties._getProperties();
props.putAll(allBundleProps);
NSProperties._setProperties(props);
insertCommandLineArguments();
if (userHomeProps != null) {
urls.add(0, urls.remove(urls.size() - 1));
}
if (mainUserProps != null) {
urls.add(0, urls.remove(urls.size() - 1));
}
urls.add(0, urls.remove(urls.size() - 1));
// System.out.print(urls);
NSNotificationCenter.defaultCenter().postNotification(new NSNotification(ERXApplication.AllBundlesLoadedNotification, NSKeyValueCoding.NullValue));
}
}
Aggregations