Skip to content

Commit

Permalink
Merge pull request #1360 from ashitsalesforce/master
Browse files Browse the repository at this point in the history
instantiate AppConfig by instantiating Controller
  • Loading branch information
ashitsalesforce authored Oct 23, 2024
2 parents 56cf6d8 + 36c69c5 commit 39eddcf
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1856,6 +1856,7 @@ private static synchronized String[] initializeAppConfig(String[] args) throws F
Map<String, String> argsMap = AppUtil.convertCommandArgsArrayToArgMap(args);
AppConfig.setConfigurationsDir(argsMap);
LoggingUtil.initializeLog(argsMap);
logger = DLLogManager.getLogger(AppConfig.class);
return AppUtil.convertCommandArgsMapToArgsArray(argsMap);
}

Expand Down Expand Up @@ -1892,7 +1893,6 @@ public static synchronized AppConfig getInstance(Map<String, String> argMap) thr
argMap = new HashMap<String, String>();
}
AppConfig.initializeAppConfig(AppUtil.convertCommandArgsMapToArgsArray(argMap));
logger = DLLogManager.getLogger(AppConfig.class);

String configurationsDirPath = AppConfig.getConfigurationsDir();
File configurationsDir;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,13 @@ private Controller(Map<String, String> argsMap) throws ControllerInitializationE
// if name is passed to controller, use it to create a unique run file name
try {
this.appConfig = AppConfig.getInstance(argsMap);
// config containing log4j config file is not initialized
// till AppConfig is instantiated.
logger = DLLogManager.getLogger(Controller.class);
} catch (Exception e) {
logger.error("Exception happened in initConfig:", e);
System.err.println("Controller: Exception happened in initializing AppConfig:");
System.err.println(e.getMessage());
e.printStackTrace();
throw new ControllerInitializationException(e.getMessage());
}

Expand Down Expand Up @@ -363,9 +368,7 @@ public LoaderWindow getLoaderWindow() {
}

public static synchronized Controller getInstance(Map<String, String> argsMap) throws ControllerInitializationException, ParameterLoadException, ConfigInitializationException {
Controller controller = new Controller(argsMap);
logger = DLLogManager.getLogger(Controller.class);
return controller;
return new Controller(argsMap);
}

public synchronized boolean saveConfig() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,10 @@ public static void main(String[] args) {
}

public static IProcess runApp(String[] args, ILoaderProgress monitor) {
Controller controller = null;
Runtime.getRuntime().addShutdownHook(new DataLoaderRunner());
try {
AppConfig.getInstance(AppUtil.convertCommandArgsArrayToArgMap(args));
controller = Controller.getInstance(AppUtil.convertCommandArgsArrayToArgMap(args));
} catch (FactoryConfigurationError | Exception ex) {
ex.printStackTrace();
System.exit(AppUtil.EXIT_CODE_CLIENT_ERROR);
Expand All @@ -110,7 +111,6 @@ public static IProcess runApp(String[] args, ILoaderProgress monitor) {
} else {
logger.debug("org.eclipse.swt.browser.DefaultType set to " + defaultBrowser + " for UI mode on Windows");
}
Controller controller = Controller.getInstance(argsMap);
controller.createAndShowGUI();
} catch (Exception e) {
UIUtils.errorMessageBox(new Shell(new Display()), e);
Expand Down

0 comments on commit 39eddcf

Please sign in to comment.