Developing application specific plugins
Demo
Procedure
- Follow the instructions for a Tersus Studio - Cross Platform Installation, replacing the Eclipse Platform Runtime Binary build specified there, with an Eclipse SDK build (or another build supporting Java development).
- Start with a Java project and add a folder models to make it a Tersus project as well.
- Create a Java class that extends tersus.runtime.Plugin (the attached demo project includes 3 such classes: Factorial, Fibonacci, Transform).
- Create a TPD file describing the plugin created in the previous step. At a minimum, the TPD file should contain a reference to the Java class that implements the plugin (see in models/Plugins folder in the attached demo project).
- Connect an action to the plugin, by dragging a Basic/Action to the model, and changing its plugin property. Setting the property to Plugins/X means the TPD file is located in either models/Plugins/X/X.tpd or models/Plugins/X.tpd - whichever exists. The folder models/Plugins/X/ is typically used to hold icon files and/or documentation.
- Add the necessary triggers and exits, per the plugin implementation.
- (Optional) Add icons (always nice, but time-consuming)
- (Optional) Create a template/prototype (if the plugin is only used once this is redundant)
Notes
- Whenever the Java implementation is changed, the Tersus application needs to be restarted in order to load the new version.
- 3rd party Jar files can be added to a jars folder in the project (as in the demo project)
- The whole project can be packaged as a library (.tersus) file, via File > Export > Tersus > Tersus Project File, and re-used in other Tersus projects.
- The API for interacting with Tersus is somewhat complicated but results in relatively efficient access (all element access is using fixed array indices rather than hash lookups):
- The plugin's initializeFromModel method is called when the application is started, and is used to initialize objects that represent triggers, exits, data types and data elements.
- All data structures are represented by abstracted Objects. For atomic values, these are the actual data types. For composite value (Data Structures), these are arrays (each element has a fixed position in the array).
- Actual access to data structure components is done using ElementHandlers (each elements contains the relevant index) - see demo project.
- Repetitive elements are represented by java.util.List objects
步骤
按照 Tersus Studio - 跨平台安装的说明,用 Eclipse SDK 构建(或其他支持 Java 开发的构建)替换其中指定的 Eclipse Platform Runtime Binary 构建。
从 Java 项目开始,添加文件夹模型,使其也成为 Tersus 项目。
创建一个扩展 tersus.runtime.Plugin 的 Java 类(所附演示项目包含 3 个此类类: Factorial、Fibonacci、Transform)。
创建一个 TPD 文件,描述上一步创建的插件。 TPD 文件至少应包含对实现该插件的 Java 类的引用(参见所附演示项目中的 models/Plugins 文件夹)。
通过将一个 Basic/Action 拖动到模型并更改其插件属性,将一个动作连接到插件。将属性设置为 Plugins/X 意味着 TPD 文件位于 models/Plugins/X/X.tpd 或 models/Plugins/X.tpd 中(以存在者为准)。 models/Plugins/X/ 文件夹通常用于存放图标文件和/或文档。
根据插件实现添加必要的触发器和退出。
(可选)添加图标(总是很好,但耗时)
(可选)创建模板/原型(如果插件只使用一次,则此操作多余)
注意
每当 Java 实现发生变化时,Tersus 应用程序都需要重新启动以加载新版本。
第三方 Jar 文件可添加到项目中的 jars 文件夹(如演示项目)
,整个项目可通过文件 > 导出 > Tersus > Tersus 项目文件打包为库(.tersus)文件,并在其他 Tersus 项目中重复使用。
与 Tersus 交互的 API 有点复杂,但访问效率相对较高(所有元素访问都使用固定数组索引,而不是散列查找):
插件的 initializeFromModel 方法在应用程序启动时被调用,用于初始化表示触发器、退出、数据类型和数据元素的对象。
所有数据结构都由抽象对象表示。 对于原子值,这些是实际的数据类型。 对于复合值(数据结构),它们是数组(每个元素在数组中都有固定位置)。
对数据结构组件的实际访问是通过 ElementHandlers 完成的(每个元素都包含相关索引)--请参见演示项目。
重复元素由 java.util.List 对象表示
参考tersus项目介绍http://tersus.com/#Id=7987,开发一个插件;接收post请求的body部分传值给Callable Service