Package org.impalaframework.module.spi

Examples of org.impalaframework.module.spi.ModuleStateHolder


    }

    public ModuleOperationResult doExecute(ModuleOperationInput moduleOperationInput) {

        Assert.notNull(moduleOperationInput, "moduleOperationInput cannot be null");
        ModuleStateHolder moduleStateHolder = getModuleStateHolder();
       
        //note that the module definition source is externally supplied
        ModuleDefinitionSource newModuleDefinitionSource = moduleOperationInput.getModuleDefinitionSource();
        Assert.notNull(newModuleDefinitionSource, "moduleDefinitionSource is required as it specifies the new module definition to apply in " + this.getClass().getName());
       
        RootModuleDefinition newModuleDefinition = newModuleDefinitionSource.getModuleDefinition();
        RootModuleDefinition oldModuleDefinition = getExistingModuleDefinitionSource();
       
        ModificationExtractorType modificationExtractorType = getModificationExtractorType();
       
        // figure out the modules to reload
        ModificationExtractor calculator = getModificationExtractorRegistry().getModificationExtractor(modificationExtractorType);
       
        TransitionSet transitions = calculator.getTransitions(oldModuleDefinition, newModuleDefinition);
        moduleStateHolder.processTransitions(transitions);
        return ModuleOperationResult.TRUE;
    }
View Full Code Here


       
        Assert.notNull(moduleOperationInput, "moduleOperationInput cannot be null");
        ModuleDefinition moduleToAdd = moduleOperationInput.getModuleDefinition();
        Assert.notNull(moduleToAdd, "moduleName is required as it specifies the name of the module to add in " + this.getClass().getName());
       
        ModuleStateHolder moduleStateHolder = getModuleStateHolder();
        ModificationExtractor calculator = getModificationExtractorRegistry().getModificationExtractor(ModificationExtractorType.STICKY);
       
        addModule(moduleStateHolder, calculator, moduleToAdd);
        return new ModuleOperationResult(true);
    }
View Full Code Here

       
        Assert.notNull(moduleOperationInput, "moduleOperationInput cannot be null");
        String moduleToRemove = moduleOperationInput.getModuleName();
        Assert.notNull(moduleToRemove, "moduleName is required as it specifies the name of the module to remove in " + this.getClass().getName());
       
        ModuleStateHolder moduleStateHolder = getModuleStateHolder();
        ModificationExtractor calculator = getModificationExtractorRegistry().getModificationExtractor(ModificationExtractorType.STRICT);
        boolean result = removeModule(moduleStateHolder, calculator, moduleToRemove);
        return result ? ModuleOperationResult.TRUE : ModuleOperationResult.FALSE;
    }
View Full Code Here

        boolean success = true;
       
        final String moduleName = currentDefinition.getName();
        logger.info("Loading definition " + moduleName);
       
        final ModuleStateHolder moduleStateHolder = application.getModuleStateHolder();
        final ServiceRegistry serviceRegistry = application.getServiceRegistry();
       
        if (moduleStateHolder.getModule(moduleName) == null) {

            ModuleRuntime moduleRuntime = getModuleRuntime(currentDefinition);
           
            try {
                RuntimeModule runtimeModule = moduleRuntime.loadRuntimeModule(application, currentDefinition);
                moduleStateHolder.putModule(moduleName, runtimeModule);
            }
            catch (Throwable e) {
               
                try {
                    serviceRegistry.evictModuleServices(moduleName);
View Full Code Here

        final String moduleDefinition = currentDefinition.getName();
        logger.info("Unloading module " + moduleDefinition);

        boolean success = true;

        final ModuleStateHolder moduleStateHolder = application.getModuleStateHolder();
       
        RuntimeModule runtimeModule = moduleStateHolder.removeModule(moduleDefinition);
        if (runtimeModule != null) {
            try {
                ModuleRuntime moduleRuntime = getModuleRuntime(currentDefinition);
                moduleRuntime.closeModule(application, runtimeModule);
            }
View Full Code Here

    final ServletContext servletContext = servlet.getServletContext();
    ModuleManagementFacade facade = ImpalaServletUtils.getModuleManagementFacade(servletContext);

    final String servletName = servlet.getServletName();
    Application application = facade.getApplicationManager().getCurrentApplication();
        ModuleStateHolder moduleStateHolder = application.getModuleStateHolder();
   
    if (!initialized) {
     
      ModuleStateChangeNotifier moduleStateChangeNotifier = facade.getModuleStateChangeNotifier();
      ModuleStateChangeListener listener = newModuleStateChangeListener(servletName);
View Full Code Here

        Impala.init();
        System.out.println(getModuleDefinition());
       
        Impala.init(this);
        Application application = Impala.getCurrentApplication();
        ModuleStateHolder moduleStateHolder = application.getModuleStateHolder();
       
        BaseBeanGraphInheritanceStrategy strategy = new ParentFirstBeanGraphInheritanceStrategy();
        assertTrue(strategy.getDelegateGetBeanCallsToParent());

        checkExpected(moduleStateHolder, strategy, "sample-module4", 0);
        checkExpected(moduleStateHolder, strategy, "sample-module6", 3);
        checkExpected(moduleStateHolder, strategy, "sample-module5", 0);
        checkExpected(moduleStateHolder, strategy, "sample-module2", 0);
        checkExpected(moduleStateHolder, strategy, "impala-core", 0);
       
        strategy = new GraphOrderedBeanInheritanceStrategy();
        assertFalse(strategy.getDelegateGetBeanCallsToParent());

        checkExpected(moduleStateHolder, strategy, "sample-module4", 2);
        checkExpected(moduleStateHolder, strategy, "sample-module6", 4);
        checkExpected(moduleStateHolder, strategy, "sample-module5", 0);
        checkExpected(moduleStateHolder, strategy, "sample-module2", 1);
        checkExpected(moduleStateHolder, strategy, "impala-core", 0);
       
        executeBean("sample-module6", "bean4");
       
        //check that the ordering can be swapped

        ModuleDefinition definition = moduleStateHolder.getModuleDefinition().findChildDefinition("sample-module4", true);
        final List<ModuleDefinition> dList = strategy.getDependencyList(definition, (GraphModuleStateHolder)moduleStateHolder);
        assertTrue(dList.size() > 0);
       
        final List<ModuleDefinition> dependencyList = new ArrayList<ModuleDefinition>(dList);
        assertEquals(0, strategy.getRootModuleDefinitionIndex(dependencyList));
View Full Code Here

    }
   
    private ApplicationContext getApplicationContext(String moduleName) {

        Application application = Impala.getCurrentApplication();
        ModuleStateHolder moduleStateHolder = application.getModuleStateHolder();
        ModuleDefinition definition = moduleStateHolder.getModuleDefinition().findChildDefinition(moduleName, true);

        ApplicationContext parent = getApplicationContext(moduleStateHolder,
                definition);
       
        return parent;
View Full Code Here

       
        RootModuleDefinition definition = new Provider().getModuleDefinition();
        TransitionSet transitions = calculatorRegistry.getModificationExtractor(ModificationExtractorType.STRICT).getTransitions(application, null, definition);
        TransitionManager transitionManager = (TransitionManager) context.getBean("transitionManager");
       
        ModuleStateHolder moduleStateHolder = application.getModuleStateHolder();
        transitionManager.processTransitions(moduleStateHolder, application, transitions);

        ConfigurableApplicationContext parentContext = SpringModuleUtils.getRootSpringContext(moduleStateHolder);
        FileMonitor bean = (FileMonitor) parentContext.getBean("bean1");
        bean.lastModified((File) null);
View Full Code Here

    public void testGraph() throws Exception {
   
        Impala.init(this);
        Application application = Impala.getCurrentApplication();
        ModuleStateHolder moduleStateHolder = application.getModuleStateHolder();
        Map<String, RuntimeModule> moduleContexts = moduleStateHolder.getRuntimeModules();
        System.out.println(moduleContexts);
        assertEquals(5, moduleContexts.size());
        assertNotNull(moduleContexts.get("impala-core"));
        assertNotNull(moduleContexts.get("sample-module2"));
        assertNotNull(moduleContexts.get("sample-module4"));
View Full Code Here

TOP

Related Classes of org.impalaframework.module.spi.ModuleStateHolder

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.