Search in sources :

Example 26 with LoadContext

use of com.developmentontheedge.be5.metadata.serialization.LoadContext in project be5 by DevelopmentOnTheEdge.

the class AppValidate method loadModules.

private void loadModules() throws MojoFailureException {
    LoadContext loadContext = new LoadContext();
    // List<ProjectElementException> errors = new ArrayList<>();
    try {
        // final Project model = be5Project;
        // List<Project> moduleProjects = ModuleLoader2.loadModules(model, logger, loadContext);
        // errors.addAll( validateDeps(moduleProjects) );
        // ModuleLoader2.mergeAllModules( model, moduleProjects, loadContext );
        ModuleLoader2.mergeModules(be5Project, logger);
    } catch (ProjectLoadException e) {
        throw new MojoFailureException("Can not load project modules", e);
    }
    checkErrors(loadContext, "Modules have %d error(s)");
}
Also used : ProjectLoadException(com.developmentontheedge.be5.metadata.exception.ProjectLoadException) MojoFailureException(org.apache.maven.plugin.MojoFailureException) LoadContext(com.developmentontheedge.be5.metadata.serialization.LoadContext)

Example 27 with LoadContext

use of com.developmentontheedge.be5.metadata.serialization.LoadContext in project be5 by DevelopmentOnTheEdge.

the class ModuleLoader2 method loadAllProjects.

public static void loadAllProjects(List<URL> urls) {
    modulesMap = new HashMap<>();
    try {
        replaceAndAddURLtoSource(urls);
        for (URL url : urls) {
            LoadContext loadContext = new LoadContext();
            Project module;
            String ext = url.toExternalForm();
            if (// usual file in directory
            ext.indexOf('!') < 0) {
                Path path = Paths.get(url.toURI()).getParent();
                module = Serialization.load(path, loadContext);
                log.fine("Load module from dir: " + path);
            } else // war or jar file
            {
                String jar = ext.substring(0, ext.indexOf('!'));
                // = FileSystems.getFileSystem(URI.create(jar));
                FileSystem fs;
                try {
                    fs = FileSystems.newFileSystem(URI.create(jar), Collections.emptyMap());
                } catch (FileSystemAlreadyExistsException e) {
                    fs = FileSystems.getFileSystem(URI.create(jar));
                    log.info("Get exists FileSystem after exception");
                }
                Path path = fs.getPath("./");
                module = Serialization.load(path, loadContext);
                log.fine("Load module from " + url.toExternalForm() + ", path=" + path);
            }
            loadContext.check();
            modulesMap.put(module.getAppName(), module);
        }
    } catch (ProjectLoadException | IOException | URISyntaxException e) {
        e.printStackTrace();
    }
}
Also used : Path(java.nio.file.Path) Project(com.developmentontheedge.be5.metadata.model.Project) ProjectLoadException(com.developmentontheedge.be5.metadata.exception.ProjectLoadException) FileSystem(java.nio.file.FileSystem) FileSystemAlreadyExistsException(java.nio.file.FileSystemAlreadyExistsException) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException) URL(java.net.URL)

Example 28 with LoadContext

use of com.developmentontheedge.be5.metadata.serialization.LoadContext in project be5 by DevelopmentOnTheEdge.

the class ModuleLoader2 method mergeAllModules.

public static void mergeAllModules(final Project model, List<Project> modules, final LoadContext context) throws ProjectLoadException {
    modules = new LinkedList<>(modules);
    for (Project module : modules) {
        module.mergeHostProject(model);
    }
    final Project compositeModule = foldModules(model, modules, context);
    if (compositeModule != null) {
        model.merge(compositeModule);
    }
}
Also used : Project(com.developmentontheedge.be5.metadata.model.Project)

Example 29 with LoadContext

use of com.developmentontheedge.be5.metadata.serialization.LoadContext in project be5 by DevelopmentOnTheEdge.

the class ModuleLoader2 method mergeModules.

public static void mergeModules(Project be5Project, ProcessController logger) throws ProjectLoadException {
    long startTime = System.nanoTime();
    LoadContext loadContext = new LoadContext();
    try {
        ModuleLoader2.mergeAllModules(be5Project, logger, loadContext);
    } catch (ProjectLoadException e) {
        throw new ProjectLoadException("Merge modules", e);
    }
    loadContext.check();
    log.info(ModuleLoader2.logLoadedProject(be5Project, startTime));
}
Also used : ProjectLoadException(com.developmentontheedge.be5.metadata.exception.ProjectLoadException)

Aggregations

YamlDeserializer (com.developmentontheedge.be5.metadata.serialization.yaml.YamlDeserializer)10 Project (com.developmentontheedge.be5.metadata.model.Project)9 LoadContext (com.developmentontheedge.be5.metadata.serialization.LoadContext)7 ProjectLoadException (com.developmentontheedge.be5.metadata.exception.ProjectLoadException)5 ReadException (com.developmentontheedge.be5.metadata.exception.ReadException)5 URL (java.net.URL)4 Path (java.nio.file.Path)4 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)4 BeConnectionProfile (com.developmentontheedge.be5.metadata.model.BeConnectionProfile)3 Query (com.developmentontheedge.be5.metadata.model.Query)3 LinkedHashMap (java.util.LinkedHashMap)3 Map (java.util.Map)3 Yaml (org.yaml.snakeyaml.Yaml)3 Entity (com.developmentontheedge.be5.metadata.model.Entity)2 Module (com.developmentontheedge.be5.metadata.model.Module)2 IOException (java.io.IOException)2 URISyntaxException (java.net.URISyntaxException)2 MojoFailureException (org.apache.maven.plugin.MojoFailureException)2 Before (org.junit.Before)2