Package org.impalaframework.module

Examples of org.impalaframework.module.ModuleLoader


    return getModuleLoader(type, true);
  }

  public ModuleLoader getModuleLoader(String type, boolean failIfNotFound) {
    Assert.notNull(type, "type cannot be null");
    ModuleLoader moduleLoader = moduleLoaders.get(type.toLowerCase());

    if (failIfNotFound) {
      if (moduleLoader == null) {
        throw new NoServiceException("No " + ModuleLoader.class.getName()
            + " instance available for module definition type " + type);
View Full Code Here


  public ConfigurableApplicationContext loadContext(ModuleDefinition definition, ApplicationContext parent) {

    Assert.notNull(moduleLoaderRegistry, ModuleLoaderRegistry.class.getName() + " cannot be null");
    ConfigurableApplicationContext context = null;
   
    final ModuleLoader moduleLoader = moduleLoaderRegistry.getModuleLoader(definition.getType(), false);
    final DelegatingContextLoader delegatingLoader = moduleLoaderRegistry.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

  }

  public boolean process(ModuleStateHolder moduleStateHolder, RootModuleDefinition newRootDefinition,
      ModuleDefinition moduleDefinition) {

    ModuleLoader moduleLoader = moduleLoaderRegistry.getModuleLoader(newRootDefinition.getType());
    ConfigurableApplicationContext parentContext = moduleStateHolder.getRootModuleContext();

    ClassLoader classLoader = parentContext.getClassLoader();

    RootModuleDefinition existingModuleDefinition = moduleStateHolder.getRootModuleDefinition();
    Resource[] existingResources = moduleLoader.getSpringConfigResources(existingModuleDefinition, classLoader);
    Resource[] newResources = moduleLoader.getSpringConfigResources(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(parentContext,
        newRootDefinition);
    beanDefinitionReader.loadBeanDefinitions(toAddList.toArray(new Resource[toAddList.size()]));

    return true;
  }
View Full Code Here

  void findAndStartBundle(ModuleDefinition currentDefinition) {
    Assert.notNull(currentDefinition, "moduleDefinition cannot be null");
       
    //install if not present
    final ModuleLoader moduleLoader = moduleLoaderRegistry.getModuleLoader(currentDefinition.getType());
    final Resource[] bundleLocations = moduleLoader.getClassLocations(currentDefinition);   

    //find bundle with name
    Bundle bundle = findBundle(currentDefinition);

    if (bundleLocations == null || bundleLocations.length == 0) {
      throw new InvalidStateException("Module loader '" + moduleLoader.getClass().getName()
          + "' returned " + (bundleLocations != null ? "empty": "null") +
          " bundle class locations. Cannot install bundle for module '"
          + currentDefinition.getName() + "'");
    }
View Full Code Here

TOP

Related Classes of org.impalaframework.module.ModuleLoader

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.