Package org.impalaframework.module.spi

Examples of org.impalaframework.module.spi.TransitionResultSet


        super();
    }

    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);
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);
                }
            }
View Full Code Here

        try {
           
            Application application = applicationManager.getCurrentApplication();
            ModuleOperationResult execute = operation.execute(application, new ModuleOperationInput(null, null, moduleName));
           
            TransitionResultSet transitionResultSet = execute.getTransitionResultSet();
            if (transitionResultSet.hasResults()) {
                if (transitionResultSet.isSuccess()) {
                    return "Successfully reloaded " + execute.getOutputParameters().get("moduleName");
                } else {
                    Throwable error = transitionResultSet.getFirstError();
                    return "One or more module operations failed: " + (error != null ? error.getMessage() : "error is null");
                }
            } else {
                return "Could not find module " + moduleName;
            }
View Full Code Here

    }
   
    public void testModuleNotFound() {
       
        expect(moduleOperationRegistry.getOperation(ModuleOperationConstants.ReloadModuleNamedLikeOperation)).andReturn(moduleOperation);
        expect(moduleOperation.execute(application, new ModuleOperationInput(null, null, "someModule"))).andReturn(new ModuleOperationResult(new TransitionResultSet()));

        replayMocks();

        assertEquals("Could not find module someModule", operations.reloadModule("someModule"));
View Full Code Here

        try {
           
            Application application = applicationManager.getCurrentApplication();
            ModuleOperationResult execute = operation.execute(application, new ModuleOperationInput(null, null, moduleName));
           
            TransitionResultSet transitionResultSet = execute.getTransitionResultSet();
            if (transitionResultSet.hasResults()) {
                if (transitionResultSet.isSuccess()) {
                    return "Successfully reloaded " + execute.getOutputParameters().get("moduleName");
                } else {
                    Throwable error = transitionResultSet.getFirstError();
                    return "One or more module operations failed: " + (error != null ? error.getMessage() : "error is null");
                }
            } else {
                return "Could not find module " + moduleName;
            }
View Full Code Here

        super.setUp();
        logger = new TransitionsLogger();
    }
   
    public void testSuccess() {
        TransitionResultSet resultSet = newSuccessTransitionResultSet();
        System.out.println(logger.getTransitionString(resultSet, true));
    }
View Full Code Here

        TransitionResultSet resultSet = newSuccessTransitionResultSet();
        System.out.println(logger.getTransitionString(resultSet, true));
    }
   
    public void testFail() {
        TransitionResultSet resultSet = newFailedTransitionResultSet();
        System.out.println(logger.getTransitionString(resultSet, true));
    }
View Full Code Here

       
        expect(stickyModificationExtractor.getTransitions(application, originalDefinition, newDefinition)).andReturn(transitionSet);
       
        newDefinition.addChildModuleDefinition(moduleDefinition);
       
        expect(transitionManager.processTransitions(moduleStateHolder, application, transitionSet)).andReturn(new TransitionResultSet());
       
        replayMocks();

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

        expect(strictModificationExtractor.getTransitions(application, originalDefinition, null)).andReturn(transitionSet);
        transitionManager.processTransitions(moduleStateHolder, application, transitionSet);
    }
   
    private TransitionResultSet newTransitionResultSet() {
        TransitionResultSet result = new TransitionResultSet();
        ModuleStateChange stateChange = new ModuleStateChange(Transition.LOADED_TO_UNLOADED, new SimpleModuleDefinition("myModule"));
        result.addResult(new TransitionResult(stateChange));
        return result;
    }
View Full Code Here

        expect(newDefinition.findChildDefinition("mymodule", true)).andReturn(newDefinition);
        newDefinition.setState(ModuleState.STALE);
        expect(newDefinition.isReloadable()).andReturn(true);
       
        expect(strictModificationExtractor.getTransitions(application, originalDefinition, newDefinition)).andReturn(transitionSet);
        expect(transitionManager.processTransitions(moduleStateHolder, application, transitionSet)).andReturn(new TransitionResultSet());
        expect(transitionSet.getModuleTransitions()).andReturn(Collections.EMPTY_LIST);
       
        replayMocks();

        //returns fallse because no module transitions found
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.