Package org.impalaframework.module.holder

Examples of org.impalaframework.module.holder.DefaultModuleStateHolder


        parentContext = createMock(ConfigurableApplicationContext.class);
        childContext = createMock(ConfigurableApplicationContext.class);
        moduleStateChangeNotifier = createMock(ModuleStateChangeNotifier.class);
        moduleRuntimeManager = createMock(ModuleRuntimeManager.class);

        moduleStateHolder = new DefaultModuleStateHolder();
        transitionManager = new DefaultTransitionManager();
       
        ApplicationManager applicationManager = TestApplicationManager.newApplicationManager(null, moduleStateHolder, null);
        application = applicationManager.getCurrentApplication();
       
View Full Code Here


public class TransitionManagerTest extends TestCase {

    public void testProcessTransitions() {
       
        DefaultModuleStateHolder moduleStateHolder = new DefaultModuleStateHolder();
        DefaultTransitionManager transitionManager = new DefaultTransitionManager();
        ModuleLoaderRegistry registry = new ModuleLoaderRegistry();
        ModuleLocationResolver resolver = new StandaloneModuleLocationResolver();

        CustomClassLoaderFactory classLoaderFactory = new CustomClassLoaderFactory();
        classLoaderFactory.setModuleLocationResolver(resolver);
       
        ApplicationModuleLoader rootModuleLoader = new ApplicationModuleLoader();
       
        registry.addItem("spring-"+ModuleTypes.ROOT, rootModuleLoader);
        ApplicationModuleLoader applicationModuleLoader = new ApplicationModuleLoader();
       
        registry.addItem("spring-"+ModuleTypes.APPLICATION, applicationModuleLoader);
        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);    

        ApplicationManager applicationManager = TestApplicationManager.newApplicationManager(new ModuleClassLoaderRegistry(), moduleStateHolder, new DelegatingServiceRegistry());
        Application application = applicationManager.getCurrentApplication();
       
        RootModuleDefinition test1Definition = newTest1().getModuleDefinition();
        ModificationExtractor calculator = new StrictModificationExtractor();
        TransitionSet transitions = calculator.getTransitions(application, null, test1Definition);
       
        transitionManager.processTransitions(moduleStateHolder, application, transitions);

        ConfigurableApplicationContext context = SpringModuleUtils.getRootSpringContext(moduleStateHolder);
        service((FileMonitor) context.getBean("bean1"));
        noService((FileMonitor) context.getBean("bean3"));

        RootModuleDefinition test2Definition = newTest2().getModuleDefinition();
        transitions = calculator.getTransitions(application, test1Definition, test2Definition);
        transitionManager.processTransitions(moduleStateHolder, application, transitions);

        context = SpringModuleUtils.getRootSpringContext(moduleStateHolder);
        service((FileMonitor) context.getBean("bean1"));
        //now we got bean3
        service((FileMonitor) context.getBean("bean3"));
       
        moduleStateHolder.setExternalRootModuleName("sample-module1");
        SpringRuntimeModule module1 = (SpringRuntimeModule) moduleStateHolder.getModule("sample-module1");
        ConfigurableApplicationContext newRootModule = SpringModuleUtils.getRootSpringContext(moduleStateHolder);
        assertSame(module1.getApplicationContext(), newRootModule);

    }
View Full Code Here

public class SimpleModuleStateHolderFactory implements ModuleStateHolderFactory {
   
    private String externalRootModuleName;
   
    public ModuleStateHolder newModuleStateHolder() {
        DefaultModuleStateHolder defaultModuleStateHolder = newDefaultModuleStateHolder();
        defaultModuleStateHolder.setExternalRootModuleName(externalRootModuleName);
        return defaultModuleStateHolder;
    }
View Full Code Here

        defaultModuleStateHolder.setExternalRootModuleName(externalRootModuleName);
        return defaultModuleStateHolder;
    }

    protected DefaultModuleStateHolder newDefaultModuleStateHolder() {
        return new DefaultModuleStateHolder();
    }
View Full Code Here

public class SimpleModuleStateHolderFactory implements ModuleStateHolderFactory {
   
    private String externalRootModuleName;
   
    public ModuleStateHolder newModuleStateHolder() {
        DefaultModuleStateHolder defaultModuleStateHolder = newDefaultModuleStateHolder();
        defaultModuleStateHolder.setExternalRootModuleName(externalRootModuleName);
        return defaultModuleStateHolder;
    }
View Full Code Here

        defaultModuleStateHolder.setExternalRootModuleName(externalRootModuleName);
        return defaultModuleStateHolder;
    }

    protected DefaultModuleStateHolder newDefaultModuleStateHolder() {
        return new DefaultModuleStateHolder();
    }
View Full Code Here

TOP

Related Classes of org.impalaframework.module.holder.DefaultModuleStateHolder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.