Custom Main
To create your own application using EvoAl, you can create a custom main class.
Therefore, you implement the MainClass and annotate the class with @Application: its name
selects the main class on the command line, and its documentation is printed by
bin/evoal-print-help.sh.
import jakarta.enterprise.context.ApplicationScoped;
import de.evoal.core.api.cdi.Application;
import de.evoal.core.api.cdi.MainClass;
@ApplicationScoped
@Application(
name = DataGenerator.NAME,
documentation = """
Generates the data of my experiment.
""")
public class DataGenerator implements MainClass {
/**
* The name of the application, the value of -Bcore:main.
*/
public static final String NAME = "com.example.optimisation.my-main";
@Override
public void run() {
// your main application code goes here
}
}
You have to pass the parameter -Bcore:main=com.example.optimisation.my-main to EvoAl, so it creates, initialises, and starts your main class.
The parameters your application reads are declared in a class that implements
BlackboardEntries. A field annotated with @Commandline is listed by the help under the
applications that main names (main = "" lists it under the general parameters):
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Named;
import de.evoal.core.api.board.BlackboardEntries;
import de.evoal.core.api.cdi.Commandline;
@ApplicationScoped
@Named("com.example.optimisation.my-entries")
public class MyEntries implements BlackboardEntries {
@Commandline(main = DataGenerator.NAME, name = "my:output-file", doc = "The file the data is written to.")
public static final String OUTPUT_FILE = "my:output-file";
}
Use the name constant of the application in main, so that a typo does not compile. If a
main names an application that is not installed, the help logs an error.