Package org.impalaframework.module

Examples of org.impalaframework.module.RootModuleDefinition


    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);
           
            //no longer applies
            moduleStateHolder.setTargetRootModuleDefinition(null);
        }
View Full Code Here


    final SpringModuleLoader moduleLoader = ObjectUtils.cast(loader, SpringModuleLoader.class);
   
    ConfigurableApplicationContext parentContext = SpringModuleUtils.getRootSpringContext(moduleStateHolder);
    ClassLoader classLoader = parentContext.getClassLoader();

    RootModuleDefinition existingModuleDefinition = moduleStateHolder.getRootModuleDefinition();
    String applicationId = application.getId();
    Resource[] existingResources = moduleLoader.getSpringConfigResources(applicationId, existingModuleDefinition, classLoader);
    Resource[] newResources = moduleLoader.getSpringConfigResources(applicationId, newRootDefinition, classLoader);

    // compare difference
View Full Code Here

    public TransitionSet getTransitions(Application application, RootModuleDefinition originalDefinition, RootModuleDefinition newDefinition) {

        List<ModuleStateChange> transitions = new ArrayList<ModuleStateChange>();
       
        RootModuleDefinition copy = ModuleDefinitionUtils.cloneAndUnfreeze(originalDefinition);
        DependencyManager dependencyManager = new DependencyManager(copy);
        Collection<ModuleDefinition> sortedModules = dependencyManager.getAllModules();
       
        for (ModuleDefinition moduleDefinition : sortedModules) {
            if (ModuleState.ERROR.equals(moduleDefinition.getState()) || ModuleState.DEPENDENCY_FAILED.equals(moduleDefinition.getState())) {
                transitions.add(new ModuleStateChange(Transition.UNLOADED_TO_LOADED, moduleDefinition));
                moduleDefinition.setState(ModuleState.LOADING);
            }
        }
       
        copy.freeze();
        return new TransitionSet(transitions, copy);
    }
View Full Code Here

            return null;
        }
       
        Properties rootModuleProperties = getPropertiesForModule(rootModuleName);
        TypeReader typeReader = getTypeReadeRegistry().getTypeReader(ModuleTypes.ROOT);
        RootModuleDefinition rootModuleDefinition = readRootModuleDefinition(rootModuleProperties, typeReader);
       
        //recursively build child definitions
        buildChildDefinitions(rootModuleDefinition, rootModuleName);
       
        for (String sibling : siblings) {
            ModuleDefinition siblingDefinition = buildModuleDefinition(null, sibling);
            buildChildDefinitions(siblingDefinition, siblingDefinition.getName());
            rootModuleDefinition.addSibling(siblingDefinition);
        }
        return rootModuleDefinition;
    }
View Full Code Here

            TypeReader typeReader) {
        ModuleDefinition moduleDefinition = typeReader.readModuleDefinition(null, rootModuleName, rootModuleProperties);
        if (!(moduleDefinition instanceof RootModuleDefinition)) {
            throw new IllegalStateException("Type reader " + typeReader + " produced " + ModuleDefinition.class.getSimpleName() + " which is not an instance of " + RootModuleDefinition.class.getName());
        }
        RootModuleDefinition rootDefinition = (RootModuleDefinition) moduleDefinition;
        return rootDefinition;
    }
View Full Code Here

            }
           
            transitionsLogger.logTransitions(resultSet);
           
        } finally {
            RootModuleDefinition rootModuleDefinition = transitions.getNewRootModuleDefinition();
            moduleStateHolder.setRootModuleDefinition(rootModuleDefinition);
        }
       
        return resultSet;
    }
View Full Code Here

public class WebPlaceholderModuleDefinitionTest extends TestCase {
   
    private String projectName = "impala-core";
   
    public void testGetters() throws Exception {
        RootModuleDefinition parent = new SimpleRootModuleDefinition(projectName, "parent-context.xml");
        WebPlaceholderModuleDefinition definition1 = new WebPlaceholderModuleDefinition(parent, "placeholder");
        assertEquals("placeholder", definition1.getName());
        assertEquals(WebModuleTypes.WEB_PLACEHOLDER, definition1.getType());
        assertSame(parent, definition1.getParentDefinition());
        assertTrue(definition1.getConfigLocations().isEmpty());
View Full Code Here

        assertSame(parent, definition1.getParentDefinition());
        assertTrue(definition1.getConfigLocations().isEmpty());
    }  
   
    public void testEquals() throws Exception {
        RootModuleDefinition parent = new SimpleRootModuleDefinition(projectName, "parent-context.xml");
        WebPlaceholderModuleDefinition definition1 = new WebPlaceholderModuleDefinition(parent, "placeholder");
        WebPlaceholderModuleDefinition definition2 = new WebPlaceholderModuleDefinition(parent, "placeholder");
       
        assertEquals(definition1, definition2);
    }
View Full Code Here

       
        assertEquals(definition1, definition2);
    }
   
    public void testAdd() throws Exception {
        RootModuleDefinition parent = new SimpleRootModuleDefinition(projectName, "parent-context.xml");
        WebPlaceholderModuleDefinition definition1 = new WebPlaceholderModuleDefinition(parent, "placeholder");
        WebPlaceholderModuleDefinition definition3 = new WebPlaceholderModuleDefinition(parent, "toAdd");
       
        try {
            definition1.addChildModuleDefinition(definition3);
View Full Code Here

    WebXmlBasedContextLoader contextLoader = new WebXmlBasedContextLoader();

    replay(servletContext);

    ModuleDefinitionSource builder = contextLoader.getModuleDefinitionSource(servletContext, facade);
    RootModuleDefinition rootModuleDefinition = builder.getModuleDefinition();

    List<String> list = new ArrayList<String>();
    list.add("context1.xml");
    list.add("context2.xml");

    assertEquals(list, rootModuleDefinition.getConfigLocations());

    assertTrue(Arrays.equals(new String[] { "p1", "p2", "p3" }, rootModuleDefinition.getChildModuleNames().toArray(new String[3])));

    verify(servletContext);
  }
View Full Code Here

TOP

Related Classes of org.impalaframework.module.RootModuleDefinition

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.