Skip to content

Commit

Permalink
Back porting wyclif's fix for:
Browse files Browse the repository at this point in the history
ModuleActivator.started()/.contextRefreshed() not called when module is
stopped/restarted or newly uploaded - TRUNK-4134
  • Loading branch information
dkayiwa committed Nov 27, 2013
1 parent f6f640f commit 23e3a63
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions api/src/main/java/org/openmrs/module/ModuleFactory.java
Expand Up @@ -24,8 +24,10 @@
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.SortedMap;
import java.util.Vector;
import java.util.WeakHashMap;
Expand Down Expand Up @@ -73,7 +75,7 @@ public class ModuleFactory {

private static final Map<String, DaemonToken> daemonTokens = new WeakHashMap<String, DaemonToken>();

private static List<String> actualStartupOrder;
private static Set<String> actualStartupOrder;

/**
* Add a module (in the form of a jar file) to the list of openmrs modules Returns null if an
Expand Down Expand Up @@ -187,7 +189,6 @@ public static void loadModules(List<File> modulesToLoad) {
* Modules that are already started will be skipped.
*/
public static void startModules() {
List<String> currentStartupOrder = new ArrayList<String>();

// loop over and try starting each of the loaded modules
if (getLoadedModules().size() > 0) {
Expand Down Expand Up @@ -218,7 +219,6 @@ public static void startModules() {
log.debug("starting module: " + mod.getModuleId());

startModule(mod);
currentStartupOrder.add(mod.getModuleId());
}
catch (Exception e) {
log.error("Error while starting module: " + mod.getName(), e);
Expand Down Expand Up @@ -258,7 +258,6 @@ public static void startModules() {
// it would only be on the leftover modules list if
// it were set to true already
startModule(leftoverModule);
currentStartupOrder.add(leftoverModule.getModuleId());

// set this boolean flag to true so we keep looping over the modules
atLeastOneModuleLoaded = true;
Expand Down Expand Up @@ -291,7 +290,6 @@ public static void startModules() {
}
}

actualStartupOrder = currentStartupOrder;
}

/**
Expand Down Expand Up @@ -579,6 +577,10 @@ public static Module startModuleInternal(Module module) throws ModuleException {

// effectively mark this module as started successfully
getStartedModulesMap().put(moduleId, module);
if (actualStartupOrder == null) {
actualStartupOrder = new LinkedHashSet<String>();
}
actualStartupOrder.add(moduleId);

try {
// save the state of this module for future restarts
Expand Down

0 comments on commit 23e3a63

Please sign in to comment.