Class NextGen
- All Implemented Interfaces:
Runnable
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 Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic voidstatic voidstatic Stringevaluate(String cartridgeName, Model model, ModelElement me, Stereotype sType, String aspect) A Cartridge wants to make use of another cartridge to generate some output.static ModelLoaderstatic ProtectionStrategiestatic Stringstatic voidvoidrun()static voidrunCartridgeWithName(String cartridgeName) static voidscheduleInvocation(NextGenInvocation invocation) static voidsetActiveLoader(ModelLoader loader) static voidsetWorkingDir(String workingDir)
-
Field Details
-
LOGGER
-
-
Method Details
-
scheduleInvocation
-
setWorkingDir
-
getProtectionStrategie
-
runCartridgeWithName
-
addCartridge
-
addModelLoader
-
loadCartridges
-
run
public void run() -
getWorkingDir
-
setActiveLoader
-
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 classpathmodel- The model to be used for evaluationme- the model element that should be used for evaluationaspect- 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
-