Package org.impalaframework.module.spi

Examples of org.impalaframework.module.spi.ModificationExtractor


     */
    public final void testCheckFreezeUnfreeze() {
        RootModuleDefinition parentSpec1 = ModificationTestUtils.spec("app-context1.xml", "plugin1, plugin2, plugin3");
        RootModuleDefinition parentSpec2 = ModificationTestUtils.spec("app-context1.xml", "plugin1, plugin2");

        ModificationExtractor calculator = new StrictModificationExtractor();
        TransitionSet transitions = calculator.getTransitions(application, parentSpec1, parentSpec2);
        RootModuleDefinition newRoot = transitions.getNewRootModuleDefinition();
       
        ModuleDefinitionWalker.walkRootDefinition(newRoot, new ModuleDefinitionCallback(){

            public boolean matches(ModuleDefinition moduleDefinition) {
                assertTrue(moduleDefinition.isFrozen());
                return false;
            }
           
        });
        calculator.getTransitions(application, newRoot, parentSpec2);
    }  
View Full Code Here


        ModuleDefinition plugin2 = parentSpec2.findChildDefinition("plugin2", true);
        ModuleDefinition plugin4 = new SimpleModuleDefinition(plugin2, "plugin4");
        new SimpleModuleDefinition(plugin4, "plugin5");
        new SimpleModuleDefinition(plugin4, "plugin6");

        ModificationExtractor calculator = new StrictModificationExtractor();
        TransitionSet transitions = calculator.getTransitions(application, parentSpec1, parentSpec2);
       
        Iterator<? extends ModuleStateChange> iterator = doAssertions(transitions, 4);
       
        ModuleStateChange change3 = iterator.next();
        assertEquals("plugin3", change3.getModuleDefinition().getName());
        assertEquals(Transition.LOADED_TO_UNLOADED, change3.getTransition());
       
        //now show that the sticky calculator has the same set of changes, but omits the last one
        ModificationExtractor stickyCalculator = new StickyModificationExtractor();
        TransitionSet stickyTransitions = stickyCalculator.getTransitions(application, parentSpec1, parentSpec2);
        doAssertions(stickyTransitions, 3);
    }
View Full Code Here

    public final void testAddParentLocations() {
        RootModuleDefinition parentSpec1 = ModificationTestUtils.spec("app-context1.xml", "plugin1, plugin2, plugin4");
        RootModuleDefinition parentSpec2 = ModificationTestUtils.spec("app-context1.xml", "plugin1, plugin2, plugin3");

        //now show that the sticky calculator has the same set of changes, but omits the last one
        ModificationExtractor stickyCalculator = new StickyModificationExtractor();
        TransitionSet stickyTransitions = stickyCalculator.getTransitions(application, parentSpec1, parentSpec2);
       
        Collection<? extends ModuleStateChange> moduleTransitions = stickyTransitions.getModuleTransitions();
        assertEquals(1, moduleTransitions.size());
       
        Iterator<? extends ModuleStateChange> iterator = moduleTransitions.iterator();
View Full Code Here

        ModuleDefinitionSource moduleDefinitionSource = EasyMock.createMock(ModuleDefinitionSource.class);
       
        expect(moduleDefinitionSource.getModuleDefinition()).andReturn(newDefinition);
       
        ModificationExtractor modificationExtractor = getModificationExtractor();
        expect(modificationExtractor.getTransitions(application, null, newDefinition)).andReturn(transitionSet);
       
        RootModuleDefinition existingDefinition = getExistingDefinition();
        if (existingDefinition != null) {
          expect(existingDefinition.isReloadable()).andReturn(true);
        }
View Full Code Here

        ModuleStateHolder moduleStateHolder = application.getModuleStateHolder();
        RootModuleDefinition oldRootDefinition = moduleStateHolder.cloneRootModuleDefinition();
        RootModuleDefinition newRootDefinition = moduleStateHolder.cloneRootModuleDefinition();

        ModificationExtractorRegistry modificationExtractor = getModificationExtractorRegistry();
        ModificationExtractor calculator = modificationExtractor
                .getModificationExtractor(ModificationExtractorType.STRICT);

        ModuleDefinition childDefinition = newRootDefinition.findChildDefinition(moduleToReload, true);

        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

    public ModuleOperationResult doExecute(Application application, ModuleOperationInput moduleOperationInput) {
       
        ModuleStateHolder moduleStateHolder = application.getModuleStateHolder();
        ModificationExtractorRegistry modificationExtractorRegistry = getModificationExtractorRegistry();
        ModificationExtractor calculator = modificationExtractorRegistry
                .getModificationExtractor(ModificationExtractorType.STRICT);
        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

public class ModificationExtractorRegistry {

  private Map<ModificationExtractorType, ModificationExtractor> modificationExtractors = new HashMap<ModificationExtractorType, ModificationExtractor>();

  public ModificationExtractor getModificationExtractor(ModificationExtractorType type) {
    ModificationExtractor calculator = modificationExtractors.get(type);

    if (calculator == null) {
      throw new NoServiceException("No " + ModificationExtractor.class.getSimpleName()
          + " available for modification type " + type);
    }
View Full Code Here

        RootModuleDefinition oldModuleDefinition = getExistingModuleDefinitionSource(application);
       
        ModificationExtractorType modificationExtractorType = getModificationExtractorType();
       
        // figure out the modules to reload
        ModificationExtractor calculator = getModificationExtractorRegistry().getModificationExtractor(modificationExtractorType);
       
        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

        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 = 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

        ModuleStateHolder moduleStateHolder = application.getModuleStateHolder();
        RootModuleDefinition oldRootDefinition = moduleStateHolder.cloneRootModuleDefinition();
        RootModuleDefinition newRootDefinition = moduleStateHolder.cloneRootModuleDefinition();

        ModificationExtractorRegistry modificationExtractor = getModificationExtractorRegistry();
        ModificationExtractor calculator = modificationExtractor
                .getModificationExtractor(ModificationExtractorType.STRICT);

        ModuleDefinition childDefinition = newRootDefinition.findChildDefinition(moduleToReload, true);

        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

TOP

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

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.