Package org.impalaframework.spring.module

Examples of org.impalaframework.spring.module.SpringModuleLoader


  }

  public void process(Application application, RootModuleDefinition newRootDefinition, ModuleDefinition moduleDefinition) {

    final ModuleLoader loader = moduleLoaderRegistry.getModuleLoader(ModuleRuntimeUtils.getModuleLoaderKey(newRootDefinition));
    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
    List<Resource> existingResourceList = newResourceList(existingResources);
    List<Resource> newResourceList = newResourceList(newResources);
    List<Resource> toAddList = new ArrayList<Resource>();

    for (Resource resource : newResourceList) {
      if (!existingResourceList.contains(resource)) {
        toAddList.add(resource);
      }
    }

    BeanDefinitionReader beanDefinitionReader = moduleLoader.newBeanDefinitionReader(applicationId,
        parentContext, newRootDefinition);
    beanDefinitionReader.loadBeanDefinitions(toAddList.toArray(new Resource[toAddList.size()]));
  }
View Full Code Here


        Assert.notNull(moduleLoaderRegistry, ModuleLoaderRegistry.class.getName() + " cannot be null");
        Assert.notNull(delegatingContextLoaderRegistry, DelegatingContextLoaderRegistry.class.getName() + " cannot be null");
        ConfigurableApplicationContext context = null;
       
        final ModuleLoader loader = moduleLoaderRegistry.getModuleLoader(ModuleRuntimeUtils.getModuleLoaderKey(definition), false);
        final SpringModuleLoader moduleLoader = ObjectUtils.cast(loader, SpringModuleLoader.class);
       
        final DelegatingContextLoader delegatingLoader = delegatingContextLoaderRegistry.getDelegatingLoader(definition.getType());

        try {

            if (moduleLoader != null) {
                if (logger.isDebugEnabled()) logger.debug("Loading module " + definition + " using ModuleLoader " + moduleLoader);
                context = loadApplicationContext(application, classLoader, moduleLoader, parent, definition);
               
                final String applicationId = application.getId();
                moduleLoader.afterRefresh(applicationId, context, definition);
            }
            else if (delegatingLoader != null) {
                if (logger.isDebugEnabled()) logger.debug("Loading module " + definition + " using DelegatingContextLoader " + moduleLoader);
                context = delegatingLoader.loadApplicationContext(parent, definition);
            }
View Full Code Here

       
        Assert.notNull(moduleLoaderRegistry, ModuleLoaderRegistry.class.getName() + " cannot be null");       
        final ModuleLoader loader = moduleLoaderRegistry.getModuleLoader(ModuleRuntimeUtils.getModuleLoaderKey(moduleDefinition), false);
       
        if (loader instanceof SpringModuleLoader) {
            SpringModuleLoader springModuleLoader = (SpringModuleLoader) loader;
            springModuleLoader.beforeClose(applicationId, applicationContext, moduleDefinition);
        }
       
        if (applicationContext instanceof ConfigurableApplicationContext) {
            ConfigurableApplicationContext configurableContext = (ConfigurableApplicationContext) applicationContext;
            configurableContext.close();
View Full Code Here

        Assert.notNull(moduleLoaderRegistry, ModuleLoaderRegistry.class.getName() + " cannot be null");
        Assert.notNull(delegatingContextLoaderRegistry, DelegatingContextLoaderRegistry.class.getName() + " cannot be null");
        ConfigurableApplicationContext context = null;
       
        final ModuleLoader loader = moduleLoaderRegistry.getModuleLoader(ModuleRuntimeUtils.getModuleLoaderKey(definition), false);
        final SpringModuleLoader moduleLoader = ObjectUtils.cast(loader, SpringModuleLoader.class);
       
        final DelegatingContextLoader delegatingLoader = delegatingContextLoaderRegistry.getDelegatingLoader(definition.getType());

        try {

            if (moduleLoader != null) {
                if (logger.isDebugEnabled()) logger.debug("Loading module " + definition + " using ModuleLoader " + moduleLoader);
                context = loadApplicationContext(application, classLoader, moduleLoader, parent, definition);
               
                final String applicationId = application.getId();
                moduleLoader.afterRefresh(applicationId, context, definition);
            }
            else if (delegatingLoader != null) {
                if (logger.isDebugEnabled()) logger.debug("Loading module " + definition + " using DelegatingContextLoader " + moduleLoader);
                context = delegatingLoader.loadApplicationContext(parent, definition);
            }
View Full Code Here

       
        Assert.notNull(moduleLoaderRegistry, ModuleLoaderRegistry.class.getName() + " cannot be null");       
        final ModuleLoader loader = moduleLoaderRegistry.getModuleLoader(ModuleRuntimeUtils.getModuleLoaderKey(moduleDefinition), false);
       
        if (loader instanceof SpringModuleLoader) {
            SpringModuleLoader springModuleLoader = (SpringModuleLoader) loader;
            springModuleLoader.beforeClose(applicationId, applicationContext, moduleDefinition);
        }
       
        if (applicationContext instanceof ConfigurableApplicationContext) {
            ConfigurableApplicationContext configurableContext = (ConfigurableApplicationContext) applicationContext;
            configurableContext.close();
View Full Code Here

        Assert.notNull(moduleLoaderRegistry, ModuleLoaderRegistry.class.getName() + " cannot be null");
        Assert.notNull(delegatingContextLoaderRegistry, DelegatingContextLoaderRegistry.class.getName() + " cannot be null");
        ConfigurableApplicationContext context = null;
       
        final ModuleLoader loader = moduleLoaderRegistry.getModuleLoader(ModuleRuntimeUtils.getModuleLoaderKey(definition), false);
        final SpringModuleLoader moduleLoader = ObjectUtils.cast(loader, SpringModuleLoader.class);
       
        final DelegatingContextLoader delegatingLoader = delegatingContextLoaderRegistry.getDelegatingLoader(definition.getType());

        try {

            if (moduleLoader != null) {
                if (logger.isDebugEnabled()) logger.debug("Loading module " + definition + " using ModuleLoader " + moduleLoader);
                context = loadApplicationContext(moduleLoader, parent, definition);
                moduleLoader.afterRefresh(context, definition);
            }
            else if (delegatingLoader != null) {
                if (logger.isDebugEnabled()) logger.debug("Loading module " + definition + " using DelegatingContextLoader " + moduleLoader);
                context = delegatingLoader.loadApplicationContext(parent, definition);
            }
View Full Code Here

        verify(applicationContext, moduleLoader);
    }

    public void testCloseContextWithSpringModuleLoader() throws Exception {
       
        SpringModuleLoader sm = (SpringModuleLoader) moduleLoader;
        moduleLoaderRegistry.addItem("spring-APPLICATION", moduleLoader);
       
        sm.beforeClose("id", applicationContext, definition);
        applicationContext.close();
       
        replay(applicationContext, moduleLoader);
        loader.closeContext("id", definition, applicationContext);
        verify(applicationContext, moduleLoader);
View Full Code Here

    Assert.notNull(moduleLoaderRegistry, ModuleLoaderRegistry.class.getName() + " cannot be null");
    Assert.notNull(delegatingContextLoaderRegistry, DelegatingContextLoaderRegistry.class.getName() + " cannot be null");
    ConfigurableApplicationContext context = null;
   
    final ModuleLoader loader = moduleLoaderRegistry.getModuleLoader(ModuleRuntimeUtils.getModuleLoaderKey(definition), false);
    final SpringModuleLoader moduleLoader = ObjectUtils.cast(loader, SpringModuleLoader.class);
   
    final DelegatingContextLoader delegatingLoader = delegatingContextLoaderRegistry.getDelegatingLoader(definition.getType());

    try {

      if (moduleLoader != null) {
        if (logger.isDebugEnabled()) logger.debug("Loading module " + definition + " using ModuleLoader " + moduleLoader);
        context = loadApplicationContext(moduleLoader, parent, definition);
        moduleLoader.afterRefresh(context, definition);
      }
      else if (delegatingLoader != null) {
        if (logger.isDebugEnabled()) logger.debug("Loading module " + definition + " using DelegatingContextLoader " + moduleLoader);
        context = delegatingLoader.loadApplicationContext(parent, definition);
      }
View Full Code Here

TOP

Related Classes of org.impalaframework.spring.module.SpringModuleLoader

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.