Date: Fri, 29 Mar 2024 03:14:16 +0100 (CET) Message-ID: <1888689952.1383.1711678456843@nm-docs> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_1382_1385545212.1711678456843" ------=_Part_1382_1385545212.1711678456843 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
MagicDraw or other modeling tool run in OSGI Framework= . This implies that batch mode programs or any applications that start Magi= cDraw or other modeling tool have to run in OSGI Framework as well.
In order to launch the program, the launcher is started using a java command line which then starts the program inside the framework.= The initial classpath have to include only jars needed to start the framew= ork launcher. Here is the list of required jars on the classpath:
lib/com.nomagic.osgi.launcher-<latest version>.jar
lib/bundles/org.eclipse.osgi_<latest version>.jar
lib/bundles/com.nomagic.magicdraw.osgi.fragment_<latest version= >.jar
lib/md_common_api.jar
lib/md_common.jar
lib/md_api.jar
lib/md.jar
lib/jna.jar
The rest of batch mode program is configured using system properties. Ma= gicDraw or other modeling tool jars are specified using the system property= md.class.path. The preferred way to specify this classpath is as = follows:
file: <absolute or relative URL to MagicDraw or other modeling =
tool configuration properties file> [?base=3D<path to MagicDraw or ot=
her modeling tool installation directory>]#<classpath property name&g=
t;
In case the current directory is the MagicDraw or other modeling tool in=
stallation directory, the base
parameter does not have to=
be specified. The classpath property name for MagicDraw or other modeling =
tool property file is CLASSPATH
.
There are other mandatory properties that have to be specified as well:<= /p>
-Dcom.nomagic.osgi.config.dir=3Dconfiguration
-Desi.system.config=3Ddata/application.conf
-Dlogback.configurationFile=3Ddata/logback.xml
They here are specified as paths relative to <modeling tool insta= llation directory> therefore you either have to make your current d= irectory before launching your program or to specify absolute paths for abo= ve listed properties.
The main class to run is com.nomagic.osgi.launcher.ProductionFramewo= rkLauncher which is the OSGI framework launcher that starts the progra= m in OSGI Framework.
The following system properties depends on the type of the batch mode pr= ogram.
md.additional.class.path
- the jar(s) const=
ituting batch mode program specific classpath is specified using this syste=
m property. The jar's are separated using the platform specific path separa=
tor in the same way as for a regular classpath.
com.nomagic.magicdraw.launcher
- specifies the batch mo=
de program (implementation of com.nomagic.magicdraw.commandline.Command=
Line) you want to launch, for example, -Dcom.nomagic.magicdraw.l=
auncher=3Dcom.nomagic.magicdraw.examples.imagegenerator.ExportDiagramImages=
-Dcom.nomagic.magicdraw.launcher=3Dcom.nomagic.magicdraw.comma=
ndline.CommandLineActionLauncher
com.nomagic.magicdraw.commandline.action
- specifies th=
e batch mode action (implementation of com.nomagic.magicdraw.commandlin=
e.CommandLineAction) you want to execute, for example, -Dcom.nom=
agic.magicdraw.commandline.action=3Dcom.nomagic.magicdraw.examples.commandl=
ineplugin.CommandLineActionExample
The examples of complete command lines that launches the batch mode prog= ram:
C:\Program Files\= MagicDraw>java -Xmx1200M -Xss1024K ^ -cp lib/com.nomagic.osgi.launcher-17.0.5-SNAPSHOT.jar;^ lib/bundles/org.eclipse.osgi_3.12.50.v20170928-1321.jar;^ lib/bundles/com.nomagic.magicdraw.osgi.fragment_1.0.0.201911181409.jar;^ lib/md_api.jar;lib/md_common_api.jar;lib/md.jar;lib/md_common.jar;lib/jna.j= ar ^ -Dmd.class.path=3Dfile:bin/magicdraw.properties#CLASSPATH ^ -Dcom.nomagic.osgi.config.dir=3Dconfiguration ^ -Desi.system.config=3Ddata/application.conf ^ -Dlogback.configurationFile=3Ddata/logback.xml ^ -Dmd.additional.class.path=3Dopenapi/examples/imagegenerator/imagegenerator= .jar ^ -Dcom.nomagic.magicdraw.launcher=3Dcom.nomagic.magicdraw.examples.imagegene= rator.ExportDiagramImages ^ com.nomagic.osgi.launcher.ProductionFrameworkLauncher project_file=3Dprojec= t.mdzip destination_dir=3Dout
C:\Program Files\= MagicDraw>java -Xmx1200M -Xss1024K ^ -cp lib/com.nomagic.osgi.launcher-17.0.5-SNAPSHOT.jar;^ lib/bundles/org.eclipse.osgi_3.12.50.v20170928-1321.jar;^ lib/bundles/com.nomagic.magicdraw.osgi.fragment_1.0.0.201911181409.jar;^ lib/md_api.jar;lib/md_common_api.jar;lib/md.jar;lib/md_common.jar;lib/jna.j= ar ^ -Dmd.class.path=3Dfile:bin/magicdraw.properties#CLASSPATH ^ -Dcom.nomagic.osgi.config.dir=3Dconfiguration ^ -Desi.system.config=3Ddata/application.conf ^ -Dlogback.configurationFile=3Ddata/logback.xml ^ -Dcom.nomagic.magicdraw.launcher=3Dcom.nomagic.magicdraw.commandline.Comman= dLineActionLauncher ^ -Dcom.nomagic.magicdraw.commandline.action=3Dcom.nomagic.magicdraw.examples= .commandlineplugin.CommandLineActionExample ^ com.nomagic.osgi.launcher.ProductionFrameworkLauncher argument1 argument2= pre>
> cd MagicDraw= _190_sp3_no_install > java -Xmx1200M -Xss1024K \ -Dmd.class.path=3Dfile:bin/magicdraw.properties#CLASSPATH \ -Dcom.nomagic.osgi.config.dir=3Dconfiguration \ -Desi.system.config=3Ddata/application.conf \ -Dlogback.configurationFile=3Ddata/logback.xml \ -Dcom.nomagic.magicdraw.launcher=3Dcom.nomagic.magicdraw.examples.im= agegenerator.ExportDiagramImages \ -cp lib/com.nomagic.osgi.launcher-17.0.5-SNAPSHOT.jar:\ ` `lib/bundles/org.eclipse.osgi_3.12.50.v20170928-1321.jar:\ ` `lib/bundles/com.nomagic.magicdraw.osgi.fragment_1.0.0.2019111814= 09.jar:\ ` `lib/md_api.jar:lib/md_common_api.jar:lib/md.jar:lib/md_common.ja= r:lib/jna.jar \ -Dmd.additional.class.path=3Dopenapi/examples/imagegenerator/imagege= nerator.jar \ com.nomagic.osgi.launcher.ProductionFrameworkLauncher project_file= =3Dproject.mdzip destination_dir=3Dout
> cd MagicDraw= _190_sp3_no_install > java -Xmx1200M -Xss1024K \ -Dmd.class.path=3Dfile:bin/magicdraw.properties#CLASSPATH \ -Dcom.nomagic.osgi.config.dir=3Dconfiguration \ -Desi.system.config=3Ddata/application.conf \ -Dlogback.configurationFile=3Ddata/logback.xml \ -Dcom.nomagic.magicdraw.launcher=3Dcom.nomagic.magicdraw.commandline= .CommandLineActionLauncher \ -Dcom.nomagic.magicdraw.commandline.action=3Dcom.nomagic.magicdraw.e= xamples.commandlineplugin.CommandLineActionExample \ -cp lib/com.nomagic.osgi.launcher-17.0.5-SNAPSHOT.jar:\ ` `lib/bundles/org.eclipse.osgi_3.12.50.v20170928-1321.jar:\ ` `lib/bundles/com.nomagic.magicdraw.osgi.fragment_1.0.0.2019111814= 09.jar:\ ` `lib/md_api.jar:lib/md_common_api.jar:lib/md.jar:lib/md_common.ja= r:lib/jna.jar \ com.nomagic.osgi.launcher.ProductionFrameworkLauncher argument1 argu= ment2
In case the command line program is not started from MagicDraw, the comm=
and line becomes a little bit more complex. The exemplary scripts tha=
t can be used to start the command line program are shown in the following =
script examples. Additionally, the scripts can be used with multiple MagicD=
raw versions since they construct a startup class path dynamically. In orde=
r to use them, the MagicDraw installation location has to be specified by s=
etting the MAGICDRAW_HOME
=
environment variable.
The shell script that starts a command line program on Mac OS-X, Linux, = and Windows cygwin/msys:
#!/bin/bash if [ -z "$MAGICDRAW_HOME" ]; then echo "MAGICDRAW_HOME environment variable not set, please set it to the= MagicDraw installation folder" exit 1 fi if [ "$OS" =3D Windows_NT ]; then md_home_url_leader=3D$(echo "$MAGICDRAW_HOME" | sed -e 's/^/\//' -e 's/= /%20/g' -e 's/\\/\//g') md_home_url_base=3D$(echo "$MAGICDRAW_HOME" | sed -e 's/:/%3A/g' -e 's/= /%20/g' \ -e 's/\//%2F/g' -e 's/\= \/%5C/g') =09cp_delim=3D";" else =09md_home_url_leader=3D$(echo "$MAGICDRAW_HOME" | sed -e 's/ /%20/g') =09md_home_url_base=3D$(echo "$MAGICDRAW_HOME" | sed -e 's/ /%20/g') =09cp_delim=3D":" fi md_cp_url=3Dfile:$md_home_url_leader/bin/magicdraw.properties?base=3D$md_ho= me_url_base#CLASSPATH OSGI_LAUNCHER=3D$(echo "$MAGICDRAW_HOME"/lib/com.nomagic.osgi.launcher-*.ja= r) OSGI_FRAMEWORK=3D$(echo "$MAGICDRAW_HOME"/lib/bundles/org.eclipse.osgi_*.ja= r) MD_OSGI_FRAGMENT=3D$(echo "$MAGICDRAW_HOME"/lib/bundles/com.nomagic.magicdr= aw.osgi.fragment_*.jar) CP=3D"${OSGI_LAUNCHER}${cp_delim}${OSGI_FRAMEWORK}${cp_delim}${MD_OSGI_FRAG= MENT}${cp_delim}\ ` `$MAGICDRAW_HOME/lib/md_api.jar${cp_delim}$MAGICDRAW_HOME/lib/md_common_= api.jar${cp_delim}\ ` `$MAGICDRAW_HOME/lib/md.jar${cp_delim}$MAGICDRAW_HOME/lib/md_common.jar$= {cp_delim}\ ` `$MAGICDRAW_HOME/lib/jna.jar" java -Xmx1200M -Xss1024K \ -Dmd.class.path=3D$md_cp_url \ -Dcom.nomagic.osgi.config.dir=3D"$MAGICDRAW_HOME/configuration" \ -Desi.system.config=3D"$MAGICDRAW_HOME/data/application.conf" \ -Dlogback.configurationFile=3D"$MAGICDRAW_HOME/data/logback.xml" \ -Dcom.nomagic.magicdraw.launcher=3Dcom.nomagic.magicdraw.examples.imag= egenerator.ExportDiagramImages \ -cp "$CP" \ -Dmd.additional.class.path=3D"$MAGICDRAW_HOME/openapi/examples/imagege= nerator/imagegenerator.jar" \ com.nomagic.osgi.launcher.ProductionFrameworkLauncher "$@"
A Windows batch file that starts a command line program on Windows:
@echo off setlocal EnableExtensions if "%MAGICDRAW_HOME%" =3D=3D "" ( echo MAGICDRAW_HOME environment variable not set, please set it to the = MagicDraw installation folder exit 1 ) setlocal enableDelayedExpansion set md_home_url_leader=3D!MAGICDRAW_HOME: =3D%%20! set md_home_url_leader=3D!md_home_url_leader:\=3D/! set md_home_url_leader=3D/!md_home_url_leader! set md_home_url_base=3D!MAGICDRAW_HOME::=3D%%3A! set md_home_url_base=3D!md_home_url_base: =3D%%20! set md_home_url_base=3D!md_home_url_base:/=3D%%2F! set md_home_url_base=3D!md_home_url_base:\=3D%%5C! setlocal disableDelayedExpansion set md_cp_url=3Dfile:%md_home_url_leader%/bin/magicdraw.properties?base=3D%= md_home_url_base%#CLASSPATH for /F %%a in ('dir /b "%MAGICDRAW_HOME%\lib\com.nomagic.osgi.launcher-*.ja= r"') do ^ set OSGI_LAUNCHER=3D%MAGICDRAW_HOME%\lib\%%a for /F %%a in ('dir /b "%MAGICDRAW_HOME%\lib\bundles\org.eclipse.osgi_*.jar= "') do ^ set OSGI_FRAMEWORK=3D%MAGICDRAW_HOME%\lib\bundles\%%a for /F %%a in ('dir /b "%MAGICDRAW_HOME%\lib\bundles\com.nomagic.magicdraw.= osgi.fragment_*.jar"') do ^ set MD_OSGI_FRAGMENT=3D%MAGICDRAW_HOME%\lib\bundles\%%a set CP=3D%OSGI_LAUNCHER%;%OSGI_FRAMEWORK%;%MD_OSGI_FRAGMENT%;^ %MAGICDRAW_HOME%\lib\md_api.jar;%MAGICDRAW_HOME%\lib\md_common_api.jar;^ %MAGICDRAW_HOME%\lib\md.jar;%MAGICDRAW_HOME%\lib\md_common.jar;^ %MAGICDRAW_HOME%\lib\jna.jar java -Xmx1200M -Xss1024K ^ -Dmd.class.path=3D%md_cp_url% ^ -Dcom.nomagic.osgi.config.dir=3D"%MAGICDRAW_HOME%\configuration" ^ -Desi.system.config=3D"%MAGICDRAW_HOME%\data\application.conf" ^ -Dlogback.configurationFile=3D"%MAGICDRAW_HOME%\data\logback.xml" ^ -Dcom.nomagic.magicdraw.launcher=3Dcom.nomagic.magicdraw.examples.imag= egenerator.ExportDiagramImages ^ -cp "%CP%" ^ -Dmd.additional.class.path=3D"%MAGICDRAW_HOME%\openapi\examples\imageg= enerator\imagegenerator.jar" ^ com.nomagic.osgi.launcher.ProductionFrameworkLauncher %*