Class NextGen

java.lang.Object
de.spraener.nxtgen.NextGen
All Implemented Interfaces:
Runnable

public class NextGen extends Object implements Runnable
The begining of all the hacks...

NextGen is started with a simple parameter, the URI of a Model-File.

It starts to locate (with the ServiceLoader-Machanism) a implementation of ModelLoader and asks each of them if it can handel a model with the given URI. Typically there is only one ModelLoader, that can handle the given model URI.

After that it loads all Cartridges (again ServiceLoader).

Each Cartridge is called with a new instance M of the model laoded by the ModelLoader After that the Transformations of the Cartridge are startet. This results in an enhanced Model M'.

After that the Cartridge has to map Generators to ModelElements on the model M'.

If that mapping is done, NextGen will start the generation for each mapped ModelElement.

The result of a generation call is a CodeBlock. CodeBlocks can contain Java, TypsScript,XML, YAML... whatever your application needs.

Each CodeBlock is than given to the Cartridge to write the content into your project.

  • Field Details

    • LOGGER

      public static final Logger LOGGER
  • Method Details

    • scheduleInvocation

      public static void scheduleInvocation(NextGenInvocation invocation)
    • setWorkingDir

      public static void setWorkingDir(String workingDir)
    • getProtectionStrategie

      public static ProtectionStrategie getProtectionStrategie()
    • runCartridgeWithName

      public static void runCartridgeWithName(String cartridgeName)
    • addCartridge

      public static void addCartridge(Cartridge c)
    • addModelLoader

      public static void addModelLoader(ModelLoader ml)
    • loadCartridges

      public static List<Cartridge> loadCartridges()
    • run

      public void run()
      Specified by:
      run in interface Runnable
    • getWorkingDir

      public static String getWorkingDir()
    • setActiveLoader

      public static void setActiveLoader(ModelLoader loader)
    • getActiveLoader

      public static ModelLoader getActiveLoader()
    • evaluate

      public static String evaluate(String cartridgeName, Model model, ModelElement me, Stereotype sType, String aspect)

      A Cartridge wants to make use of another cartridge to generate some output. If the given cartridge name can be resolved and the cartridge supports evaluation, the method calls the desired cartridge and let it evaluate the given aspect.

      The first usecas of this method wath to generate a docker-compose file from the cloud cartridge. The cloud cartridge generates sub models for each cloud module and let another cartridge generate the code inside this module. Later the cloud cartridge needs to generate a docker-compose file which contains a service block for each cloud module. The generation of this service block is delegated back to the module cartridge via this method.

      Without this method the cloud cartridge has to know how to generate a docker-compose service block for each included cartridge. This method avoids this dependency.

      Parameters:
      cartridgeName - the name of a cartridge. Should be on the classpath
      model - The model to be used for evaluation
      me - the model element that should be used for evaluation
      aspect - an optional (can be null) parameter to narrow the needed evaluation. For example "docker-compose"
      Returns:
      a String with the output of the evaluation.
    • main

      public static void main(String[] args)