Delegate Modules

A delegate module is a JAR file containing the custom Java delegates for a simulation. Moxie loads the delegate module at the start of the simulation, and executes the delegate code contained within when it evaluates the corresponding opaque expressions in the state machines.

Building

Once you have created the project structure for your custom delegate module, you will need to build and deploy a JAR file, which Moxiw will load at the start of the simulation. The JAR file contains delegate providers and the custom delegate code that will execute as the opaque expressions in your state machines are evaluated. Gradle is the build tool we use, as it has support for a number of IDEs, including Eclipse, IntelliJ, and others. You can even use it from the command line. Moxie provides a build.gradle script with the samples and tutorials included in the installation; for more information, check out the README.txt file in the same location. However, you may build delegate modules using any Java build tool you prefer.

To learn more about Gradle, go to https://gradle.org.

Deploying

In order for Moxie to load the classes in your JAR file, you must either copy the JAR file to a subdirectory in your delegate module home directory or use the MoxieDelegateModulePaths stereotype to specify the directory that directly contains the JAR file. Your home directory is specified by the DelegateModuleHomePath that you may have configured during installation. You can use the install task in the sample Gradle build script to automatically copy the JAR file to a subdirectory in the directory you specify in the gradle.properties file.

Moxie will load JAR files in directories that exist directly under your delegate module home directory when running simulations. An example is <DelegateModuleHomePath>\com.agi.moxie.samples.balloonride\sample-balloon-ride.jar. Moxie will not load JAR files located directly in the root of your delegate module home directory or in subdirectories more than one level below it.

Moxie's hot code reloading capability enables you to rebuild and reinstall your delegate module JAR File while overwriting the previous version at the same time. Best of all, the new delegate code is loaded automatically when you rerun your simulation without having to restart your No Magic modeling tool.

Debugging

As you write your delegates, you will likely want to have the ability to debug them as your simulation executes. You can easily do so by using the sample Gradle build script included with the moxie installation at \samples\build\build.gradle. To learn how, check out the README.txt file in the same location. This capability enables you to set breakpoints and step through your code in your preferred IDE at simulation time.