public TransitionResultSet processTransitions(ModuleStateHolder moduleStateHolder, Application application, TransitionSet transitions) {
TransitionResultSet resultSet = new TransitionResultSet();
final RootModuleDefinition newRootModuleDefinition = transitions.getNewRootModuleDefinition();
moduleStateHolder.setTargetRootModuleDefinition(newRootModuleDefinition);
try {
Assert.notNull(transitionProcessorRegistry, TransitionProcessorRegistry.class.getSimpleName() + " cannot be null");
Collection<? extends ModuleStateChange> changes = transitions.getModuleTransitions();
for (ModuleStateChange change : changes) {
if (logger.isDebugEnabled()) {
logger.debug("Processing module state change: " + change);
}
String transition = change.getTransition();
ModuleDefinition currentModuleDefinition = change.getModuleDefinition();
TransitionProcessor transitionProcessor = transitionProcessorRegistry.getTransitionProcessor(transition);
TransitionResult result;
try {
transitionProcessor.process(application, newRootModuleDefinition, currentModuleDefinition);
result = new TransitionResult(change);
}
catch (Throwable error) {
result = new TransitionResult(change, error);
}
resultSet.addResult(result);
if (result.getError() == null && moduleStateChangeNotifier != null) {
moduleStateChangeNotifier.notify(moduleStateHolder, result);
}
}
resultSet.complete();
transitionsLogger.logTransitions(resultSet);
} finally {
RootModuleDefinition rootModuleDefinition = newRootModuleDefinition;
moduleStateHolder.setRootModuleDefinition(rootModuleDefinition);
//no longer applies
moduleStateHolder.setTargetRootModuleDefinition(null);
}