Package org.impalaframework.module.spi

Examples of org.impalaframework.module.spi.TransitionResultSet


        expect(newDefinition.isReloadable()).andReturn(true);

        expect(moduleOperationRegistry.getOperation(ModuleOperationConstants.ReloadNamedModuleOperation)).andReturn(moduleOperation);
       
        expect(newDefinition.getName()).andReturn("mymodule2");
        TransitionResultSet transitionResultSet = TransitionResultSetTest.newSuccessTransitionResultSet();
        expect(moduleOperation.execute(application, new ModuleOperationInput(null, null, "mymodule2"))).andReturn(new ModuleOperationResult(transitionResultSet));
       
        replayMocks();
        replay(moduleOperationRegistry);
        replay(moduleOperation);
View Full Code Here


        if (existingDefinition != null) {
          expect(existingDefinition.isReloadable()).andReturn(true);
        }
       
        expect(strictModificationExtractor.getTransitions(application, existingDefinition, newDefinition)).andReturn(transitionSet);
        expect(transitionManager.processTransitions(moduleStateHolder, application, transitionSet)).andReturn(new TransitionResultSet());
       
        replayMocks();
        replay(moduleDefinitionSource);

        assertEquals(ModuleOperationResult.EMPTY, operation.doExecute(application, new ModuleOperationInput(moduleDefinitionSource, null, null)));
View Full Code Here

        assertFalse(result.isErrorFree());
        assertTrue(result.hasResults());
    }
   
    public void testEmpty() throws Exception {
        ModuleOperationResult result = new ModuleOperationResult(new TransitionResultSet());
        assertFalse(result.isSuccess());
        assertTrue(result.isErrorFree());
        assertFalse(result.hasResults());
    }
View Full Code Here

   
    public final void testExecute() {
        expect(moduleStateHolder.getRootModuleDefinition()).andReturn(originalDefinition);
       
        expect(strictModificationExtractor.getTransitions(application, originalDefinition, null)).andReturn(transitionSet);
        expect(transitionManager.processTransitions(moduleStateHolder, application, transitionSet)).andReturn(new TransitionResultSet());
       
        replayMocks();

        assertEquals(ModuleOperationResult.EMPTY, operation.doExecute(application, new ModuleOperationInput(null, null, null)));
       
View Full Code Here

        if (childDefinition != null) {
            childDefinition.setState(ModuleState.STALE);

            TransitionSet transitions = calculator.getTransitions(application, oldRootDefinition, newRootDefinition);
            TransitionResultSet transitionResultSet = getTransitionManager().processTransitions(moduleStateHolder, application, transitions);

            boolean result = !transitions.getModuleTransitions().isEmpty();
            return result ? new ModuleOperationResult(transitionResultSet) : ModuleOperationResult.EMPTY;
        }
       
View Full Code Here

        RootModuleDefinition rootModuleDefinition = moduleStateHolder.getRootModuleDefinition();
       
        if (rootModuleDefinition != null) {
            logger.info("Shutting down application context");
            TransitionSet transitions = calculator.getTransitions(application, rootModuleDefinition, null);
            TransitionResultSet transitionResultSet = getTransitionManager().processTransitions(moduleStateHolder, application, transitions);
            return new ModuleOperationResult(transitionResultSet);
        }
        else {
            return new ModuleOperationResult(new TransitionResultSet());
        }
    }
View Full Code Here

            Assert.notNull(moduleOperationRegistry, "moduleOperationRegistry cannot be null");
           
            ModuleOperation operation = moduleOperationRegistry.getOperation(
                    ModuleOperationConstants.ReloadNamedModuleOperation);
            ModuleOperationResult execute = operation.execute(application, new ModuleOperationInput(null, null, foundModuleName));
            TransitionResultSet transitionResultSet = execute.getTransitionResultSet();

            Map<String, Object> resultMap = new HashMap<String, Object>();
            resultMap.put("moduleName", foundModuleName);
            return new ModuleOperationResult(transitionResultSet, resultMap);
        }
View Full Code Here

        if (oldModuleDefinition == null && newModuleDefinition == null) {
            return ModuleOperationResult.EMPTY;
        }
       
        TransitionSet transitions = calculator.getTransitions(application, oldModuleDefinition, newModuleDefinition);
        TransitionResultSet transitionResultSet = getTransitionManager().processTransitions(moduleStateHolder, application, transitions);
        return new ModuleOperationResult(transitionResultSet);
    }
View Full Code Here

        super();
    }

    public TransitionResultSet processTransitions(ModuleStateHolder moduleStateHolder, Application application, TransitionSet transitions) {

        TransitionResultSet resultSet = new TransitionResultSet();
       
        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, transitions.getNewRootModuleDefinition(), 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 = transitions.getNewRootModuleDefinition();
            moduleStateHolder.setRootModuleDefinition(rootModuleDefinition);
View Full Code Here

        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 = application.getModuleStateHolder();
        ModificationExtractor calculator = getModificationExtractorRegistry().getModificationExtractor(ModificationExtractorType.STRICT);
        TransitionResultSet transitionResultSet = removeModule(moduleStateHolder, application, calculator, moduleToRemove);
       
        boolean hasResults = transitionResultSet.hasResults();
        return hasResults ? new ModuleOperationResult(transitionResultSet) : ModuleOperationResult.EMPTY;
    }
View Full Code Here

TOP

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

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.