Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
tutorial:plugins [2020/07/16 16:08]
admin [What does a plugin do?]
tutorial:plugins [2021/01/10 17:58] (current)
admin [Using Custom Plugin]
Line 6: Line 6:
   * [[#Deploy custom plugin]]   * [[#Deploy custom plugin]]
   * [[#Using custom plugin]]   * [[#Using custom plugin]]
 +
  
 ===== What does a plugin do?===== ===== What does a plugin do?=====
Line 16: Line 17:
  
 Before we can start building our custom plugin, we need to set up the java development environment: Before we can start building our custom plugin, we need to set up the java development environment:
-  * create a java project +  * create a java maven project 
-  * add toplugin.jar to the project's build path - copy toplugin.jar can be found in //lib// folder+  * add following maven dependency to pom.xml 
 + 
 +    <dependency> 
 +      <groupId>com.github.testoptimal</groupId> 
 +      <artifactId>JavaConnector</artifactId> 
 +      <version>1.0.2</version> 
 +    </dependency> 
  
 Now we are ready to build our first custom plugin in Eclipse: Now we are ready to build our first custom plugin in Eclipse:
Line 24: Line 32:
   * add @TO_PLUGIN annotation to your java class   * add @TO_PLUGIN annotation to your java class
   * implement required methods   * implement required methods
-  * add your plugin functionsdeclare as public functions+  * add your plugin functions declare them as public functions
  
 Below is an example of the java class: Below is an example of the java class:
Line 65: Line 73:
    }    }
  
-By default, all public methods declared as well as inherited are exposed as MScript function.  To exclude certain methods from being exposed as MScript function, add annotation //@NOT_MSCRIPT_METHOD// to the method. Add annotation //@IGNORE_INHERITED_METHOD// to the plugin class to exclude inherited methods from exposed as MScript functions.+By default, all public methods declared as well as inherited are exposed as MScript function.  To exclude certain methods from being exposed as MScript function, add annotation //@NOT_MSCRIPT_METHOD// to the method. Add annotation //@IGNORE_INHERITED_METHOD// to the plugin class to exclude inherited methods from being exposed as MScript functions.
  
 Don't forget to write junit test to test the plugin functions. Don't forget to write junit test to test the plugin functions.
Line 71: Line 79:
  
 ===== Deploy Custom Plugin ===== ===== Deploy Custom Plugin =====
-Export project as jar file +  * Export project as jar file 
-Copy plugin jar file to /lib folder in //TestOptimal// server +  Copy the plugin jar file to /lib folder in //TestOptimal// server 
-Register your plugin package in config.properties:+  Register your plugin package in //config/config.properties//:
  
    plugin.packages=com.mine.plugin    plugin.packages=com.mine.plugin
Line 79: Line 87:
 Above registry tells //TestOptimal// server where to look for your custom plugins.  If you have multiple custom plugins in the same java package, they will all be found automatically. Above registry tells //TestOptimal// server where to look for your custom plugins.  If you have multiple custom plugins in the same java package, they will all be found automatically.
  
-Restart TestOptimal server to make the changes effective.+  * Restart TestOptimal server to make the changes effective.
  
 ===== Using Custom Plugin ===== ===== Using Custom Plugin =====
-Open an existing model or create a new model +Plugins must be activated before they can be used in the script.  Below is the steps to activate the plugins: 
-Select SCRIPT tab + 
-Click on "P" icon on SCRIPT tab toolbar +  * Open an existing model or create a new model 
-Check the checbox for your custom plugin +  Select //SCRIP//tab 
-Your plugin should show up on CodeAssist list as //$'pluginID'//+  Click on "P" icon on the upper-right toolbar 
 +  Check the checkbox for your custom plugin 
 +  * Close Plugin Activation dialog 
 + 
 +Press //Ctrl-Space// to open //CodeAssist//  Your plugin should show up on //CodeAssist// list as //$'pluginID'//