Package org.impalaframework.module

Examples of org.impalaframework.module.ModuleDefinition


public class DefaultModuleStateChangeNotifier implements ModuleStateChangeNotifier {

  private List<ModuleStateChangeListener> listeners = new LinkedList<ModuleStateChangeListener>();

  public void notify(ModuleStateHolder moduleStateHolder, ModuleStateChange change) {
    ModuleDefinition moduleDefinition = change.getModuleDefinition();

    for (ModuleStateChangeListener moduleStateChangeListener : listeners) {
      String moduleName = moduleStateChangeListener.getModuleName();

      boolean notify = true;

      if (moduleName != null) {
        if (!moduleName.equals(moduleDefinition.getName())) {
          notify = false;
        }
      }

      if (notify) {
View Full Code Here


   * implementation. If no parent definition is available, the built {@link ModuleDefinition} instance
   * is added as a sibling to the {@link RootModuleDefinition}.
   */
  public RootModuleDefinition getModuleDefinition() {
   
    ModuleDefinition currentParentDefinition = parentDefinition;
    for (String moduleName : modulesToLoad) {
      ModuleDefinition definition = buildModuleDefinition(currentParentDefinition, moduleName);
     
      if (currentParentDefinition == null) {
        Assert.isTrue(!definition.getName().equals(rootModuleDefinition.getName()), "Module definition with no parent cannot be the root module definition");
        rootModuleDefinition.addSibling(definition);
      }
     
      currentParentDefinition = definition;
    }
View Full Code Here

    if (oldRootDefinition == null) {
      return false;
    }
   
    RootModuleDefinition newRootDefinition = moduleStateHolder.cloneRootModuleDefinition();
    ModuleDefinition definitionToRemove = newRootDefinition.findChildDefinition(moduleToRemove, true);

    if (definitionToRemove != null) {
      if (definitionToRemove instanceof RootModuleDefinition) {
        //we're removing the rootModuleDefinition
        TransitionSet transitions = calculator.getTransitions(oldRootDefinition, null);
        moduleStateHolder.processTransitions(transitions);
        return true;
      }
      else {
        ModuleDefinition parent = definitionToRemove.getParentDefinition();
        if (parent != null) {
          parent.removeChildModuleDefinition(moduleToRemove);
         
          definitionToRemove.setParentDefinition(null);

          TransitionSet transitions = calculator.getTransitions(oldRootDefinition, newRootDefinition);
          moduleStateHolder.processTransitions(transitions);
View Full Code Here

      Collection<? extends ModuleStateChange> changes = transitions.getModuleTransitions();

      for (ModuleStateChange change : changes) {
        String transition = change.getTransition();
        ModuleDefinition currentModuleDefinition = change.getModuleDefinition();

        TransitionProcessor transitionProcessor = transitionProcessorRegistry.getTransitionProcessor(transition);
        transitionProcessor.process(transitions.getNewRootModuleDefinition(), currentModuleDefinition);
     
        if (moduleStateChangeNotifier != null) {
View Full Code Here

            Collection<ModuleDefinition> oldChildren,
            Collection<ModuleDefinition> newChildren,
            List<ModuleStateChange> transitions) {
       
        for (ModuleDefinition newChild : newChildren) {
            ModuleDefinition oldChild = ModuleDefinitionUtils.getModuleFromCollection(oldChildren, newChild.getName());

            //if new module has definition not present in old, then load this with children
            if (oldChild == null) {
                loadDefinitions(newChild, transitions);            
            }
View Full Code Here

            Collection<ModuleDefinition> oldChildren,
            Collection<ModuleDefinition> newChildren,
            List<ModuleStateChange> transitions) {
   
        for (ModuleDefinition oldChild : oldChildren) {
            ModuleDefinition newChild = ModuleDefinitionUtils.getModuleFromCollection(newChildren, oldChild.getName());

            //if old module has definition which is no longer present, then unload this
            if (newChild == null) {
                unloadDefinitions(oldChild, transitions);
            }
View Full Code Here

public class DefaultModuleStateChangeNotifier implements ModuleStateChangeNotifier {

    private List<ModuleStateChangeListener> listeners = new LinkedList<ModuleStateChangeListener>();

    public void notify(ModuleStateHolder moduleStateHolder, ModuleStateChange change) {
        ModuleDefinition moduleDefinition = change.getModuleDefinition();

        for (ModuleStateChangeListener moduleStateChangeListener : listeners) {
            String moduleName = moduleStateChangeListener.getModuleName();

            boolean notify = true;

            if (moduleName != null) {
                if (!moduleName.equals(moduleDefinition.getName())) {
                    notify = false;
                }
            }

            if (notify) {
View Full Code Here

            Collection<ModuleDefinition> oldChildren,
            Collection<ModuleDefinition> newChildren,
            List<ModuleStateChange> transitions) {
   
        for (ModuleDefinition oldChild : oldChildren) {
            ModuleDefinition newChild = ModuleDefinitionUtils.getModuleFromCollection(newChildren, oldChild.getName());

            if (newChild == null) {
                newParent.addChildModuleDefinition(oldChild);
                oldChild.setParentDefinition(newParent);
            }
View Full Code Here

  protected ModuleDefinition buildModuleDefinition(
      ModuleDefinition parentDefinition, String moduleName) {
    Properties properties = moduleProperties.get(moduleName);
    String type = getType(properties);
    TypeReader reader = typeReadeRegistry.getTypeReader(type);
    ModuleDefinition definition = reader.readModuleDefinition(parentDefinition, moduleName, properties);
    definition.setParentDefinition(parentDefinition);
    return definition;
  }
View Full Code Here

    }

    protected ApplicationContext internalGetParentApplicationContext(
            ModuleDefinition definition) {
        ConfigurableApplicationContext parentContext = null;
        ModuleDefinition parentDefinition = definition.getParentDefinition();
       
        while (parentDefinition != null) {
           
            final String parentName = parentDefinition.getName();
            final RuntimeModule parentModule = getModuleStateHolder().getModule(parentName);
            if (parentModule instanceof SpringRuntimeModule) {
                SpringRuntimeModule springRuntimeModule = (SpringRuntimeModule) parentModule;
                parentContext = springRuntimeModule.getApplicationContext();
                break;
            }
           
            parentDefinition = parentDefinition.getParentDefinition();         
        }
        return parentContext;
    }
View Full Code Here

TOP

Related Classes of org.impalaframework.module.ModuleDefinition

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.