Skip to content

Commit 67c9f03

Browse files
committedAug 20, 2013
TRUNK-3738 Fixed stopping module
1 parent fd7cffc commit 67c9f03

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed
 

‎api/src/main/java/org/openmrs/module/ModuleUtil.java

+9-5
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,8 @@ public static AbstractRefreshableApplicationContext refreshApplicationContext(Ab
750750
public static AbstractRefreshableApplicationContext refreshApplicationContext(AbstractRefreshableApplicationContext ctx,
751751
boolean isOpenmrsStartup, Module startedModule) {
752752
//notify all started modules that we are about to refresh the context
753-
for (Module module : ModuleFactory.getStartedModules()) {
753+
Set<Module> startedModules = new HashSet<Module>(ModuleFactory.getStartedModules());
754+
for (Module module : startedModules) {
754755
try {
755756
if (module.getModuleActivator() != null)
756757
module.getModuleActivator().willRefreshContext();
@@ -791,16 +792,19 @@ public static AbstractRefreshableApplicationContext refreshApplicationContext(Ab
791792

792793
// reload the advice points that were lost when refreshing Spring
793794
if (log.isDebugEnabled())
794-
log.debug("Reloading advice for all started modules: " + ModuleFactory.getStartedModules().size());
795+
log.debug("Reloading advice for all started modules: " + startedModules.size());
795796

796797
try {
797798
//The call backs in this block may need lazy loading of objects
798799
//which will fail because we use an OpenSessionInViewFilter whose opened session
799800
//was closed when the application context was refreshed as above.
800801
//So we need to open another session now. TRUNK-3739
801802
Context.openSessionWithCurrentUser();
802-
803-
for (Module module : ModuleFactory.getStartedModules()) {
803+
for (Module module : startedModules) {
804+
if (!module.isStarted()) {
805+
continue;
806+
}
807+
804808
ModuleFactory.loadAdvice(module);
805809
try {
806810
ModuleFactory.passDaemonToken(module);
@@ -817,7 +821,7 @@ else if (!isOpenmrsStartup && module.equals(startedModule))
817821
}
818822
catch (Exception e) {
819823
log.warn("Unable to invoke started() method on the module's activator", e);
820-
ModuleFactory.stopModule(module);
824+
ModuleFactory.stopModule(module, true, true);
821825
}
822826
}
823827

0 commit comments

Comments
 (0)
Please sign in to comment.