There are cases when custom task must be executed in the batch (command line) mode. For example, if you want to run MagicDraw or other modeling tool application, open some project, execute code generation and exit application.
API provides two ways to run the tool in the batch mode depending on the required functionality.
- Functionality is provided by an application core. You need to extend the com.nomagic.magicdraw.commandline.CommandLine class.
- Functionality is provided by a plugin. Plugin loading is managed by the application core so it is undesirable to add core and plugin classes into the same class path. The different approach accessing plugin functionality is used. You need to implement the com.nomagic.magicdraw.commandline.CommandLineAction interface.
You can find the code examples in
- <modeling tool installation directory>\openapi\examples\imagegenerator. It takes a project file and destination directory as arguments and generates images for all diagrams.
- <modeling tool installation directory>\openapi\examples\commandlineplugin. Just prints the program arguments to the application log file.
The application cannot be run on the headless device even in a batch mode. The graphical environment is required.
For more information on the launching batch mode programs, see Specifying batch mode program classpath.
For more information on creation of batch mode programs, see Implementing command line launchers.
More information is available in javadoc.