DefaultApplicationContextLoader contextLoader = new DefaultApplicationContextLoader();
contextLoader.setModuleLoaderRegistry(registry);
contextLoader.setDelegatingContextLoaderRegistry(new DelegatingContextLoaderRegistry());
TransitionProcessorRegistry transitionProcessors = new TransitionProcessorRegistry();
LoadTransitionProcessor loadTransitionProcessor = new LoadTransitionProcessor();
SpringModuleRuntime moduleRuntime = new SpringModuleRuntime();
moduleRuntime.setApplicationContextLoader(contextLoader);
moduleRuntime.setClassLoaderFactory(classLoaderFactory);
ModuleRuntime springModuleRuntime = moduleRuntime;
Map<String, ModuleRuntime> moduleRuntimes = Collections.singletonMap("spring", springModuleRuntime);
DefaultModuleRuntimeManager manager = new DefaultModuleRuntimeManager();
manager.setModuleRuntimes(moduleRuntimes);
loadTransitionProcessor.setModuleRuntimeManager(manager);
UnloadTransitionProcessor unloadTransitionProcessor = new UnloadTransitionProcessor();
transitionProcessors.addItem(Transition.UNLOADED_TO_LOADED, loadTransitionProcessor);
transitionProcessors.addItem(Transition.LOADED_TO_UNLOADED, unloadTransitionProcessor);
transitionManager.setTransitionProcessorRegistry(transitionProcessors);