Once you deployed the launch configuration as a JAR file, you can execute it from a Java program using MDWorkbench APIs.
To use MDWorkbench APIs in a Java program, the classpath must include the following jars:
EMF jars:
/plugins/org.eclipse.emf.common_<version>.jar
/plugins/org.eclipse.emf.ecore_<version>.jar
/plugins/org.eclipse.emf.ecore.xmi_<version>.jar
MDWorkbench core engine and third-party jars:
/plugins/com.sodius.mdw.core_<version>/com.sodius.mdw.core.jar
/plugins/com.sodius.mdw.core_<version>/lib/flexlm.jar
/plugins/com.sodius.mdw.core_<version>/lib/EccpressoAll.jar
/plugins/com.sodius.mdw.core.ml_<version>.jar
/plugins/com.sodius.mdw.core.profile_<version>.jar
Metamodels and connector jars:
/plugins/com.sodius.mdw.metamodel.uml21_<version>.jar
These jars are located in the folder <MDWorkbench directory>\eclipse\plugins
.
Here is a snippet of Java code to execute a launch configuration:
import java.io.File; import com.sodius.mdw.core.CoreException; import com.sodius.mdw.core.MDWorkbench; import com.sodius.mdw.core.MDWorkbenchFactory; import com.sodius.mdw.core.eval.EvaluationManager; import com.sodius.mdw.core.eval.launch.LaunchConfiguration; public class LaunchSnippet { public static void main(String[] args) throws CoreException { // Create an MDWorkbench engine MDWorkbench mdw = MDWorkbenchFactory.create(); EvaluationManager manager = mdw.getEvaluationManager(); try { // Load a launch configuration File file = new File("c:\\deploy\\myLaunch.launch"); LaunchConfiguration configuration = manager.loadLaunchConfiguration(file); // Execute the launch configuration manager.evaluate(configuration, null); } finally { // Shutdown MDWorkbench (to release licenses) mdw.shutdown(); } } }
You can run the above snippet of code like any regular Java program.
You just have to configure the license source MDWorkbench must use to retrieve its license features.
This is done using a System
property mdw.license
:
java -Dmdw.license=@myServer -classpath <...> LaunchSnippet
This System
property value (e.g. @myserver
) must match what is set in the MDWorkbench IDE
(menu Window > Preferences and MDWorkbench > License).
It can be:
5678@somehost
@somehost
1234@rs1,2345@rs2,3456@rs3
c:\licenses\license.lic
*
), e.g. c:\licenses\*.lic
Please note that the predefined class LaunchRunner
let you execute a launch configuration in a way similar to the above snippet:
java -Dmdw.license=@myServer -classpath <...> com.sodius.mdw.core.eval.launch.LaunchRunner -launch c:\deploy\myLaunch.launch
Changing launch arguments
Customizing log and progress report