Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tutorial:plugins [2020/07/16 15:45] – admin | tutorial:plugins [2024/01/03 19:56] (current) – removed admin | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Tutorial: Custom Plugins ====== | ||
- | |||
- | ====Learning Objectives==== | ||
- | * What does a plugin do? | ||
- | * Develop custom plugin | ||
- | * Deploy custom plugin | ||
- | * Sharing custom plugin | ||
- | |||
- | ===== Develop custom plugin ===== | ||
- | Custom plugins are just java classes. | ||
- | |||
- | Before we can start building our custom plugin, we need to set up the java development environment: | ||
- | * create a java project | ||
- | * add toplugin.jar to the project' | ||
- | |||
- | Now we are ready to build our first custom plugin in Eclipse: | ||
- | * create a plugin java package to hold your custom plugin java classes, e.g. com.mine.plugin | ||
- | * create your custom plugin java class by inheriting from // | ||
- | * add @TO_PLUGIN annotation to your java class | ||
- | * implement required methods | ||
- | * add your plugin functions, declare as public functions | ||
- | |||
- | Below is an example of the java class: | ||
- | |||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | |||
- | @Override | ||
- | public String getPluginID() { | ||
- | | ||
- | } | ||
- | |||
- | @Override | ||
- | public String getPluginDesc() { | ||
- | | ||
- | } | ||
- | |||
- | @NOT_MSCRIPT_METHOD | ||
- | @Override | ||
- | | ||
- | System.out.println(" | ||
- | |||
- | } | ||
- | |||
- | @NOT_MSCRIPT_METHOD | ||
- | @Override | ||
- | public void close() { | ||
- | | ||
- | } | ||
- | |||
- | public String doSomething (String something_p) { | ||
- | | ||
- | | ||
- | } | ||
- | } | ||
- | |||
- | By default, all public methods declared as well as inherited are exposed as MScript function. | ||
- | |||
- | Don't forget to write junit test to test the plugin functions. | ||
- | |||
- | |||
- | ===== Deploy Custom Plugin ===== | ||
- | Export project as jar file | ||
- | Copy plugin jar file to /lib folder in // | ||
- | Register your plugin package in config.properties: | ||
- | |||
- | | ||
- | |||
- | Above registry tells // | ||
- | |||
- | Restart TestOptimal server to make the changes effective. | ||
- | |||
- | ===== Use Custom Plugin ===== | ||
- | Open an existing model or create a new model | ||
- | Select SCRIPT tab | ||
- | Click on " | ||
- | Check the checbox for your custom plugin | ||
- | Your plugin should show up on CodeAssist list as // | ||
- | |||
- | |||