Java Command Annotations – @JavaCommand
Java command annotations are used for the developing Java commands in PAK.
This chapter describes the functionality of the @JavaCommand
annotation.
It also gives an example of how you can use this annotation in your implementation.
1. Basics
The @JavaCommand
annotation marks a Java class as command.
Thus, only the classes that have this annotation are recognized as commands by the annotation processor.
2. Properties
There is a String property called displayname
defined for the @JavaCommand
annotation.
Usually, the command name is derived from the class name.
However, if a value is assigned to the displayname
property the PAK BPMN Editor and Workflow Executor display this value as command name instead of the class name.
The usage of that property is shown in Listing 2.
The default value is an empty String which means that the class name is displayed in the PAK BPMN Editor and Workflow Executor.
The class name is split with spaces between capital letters, while sequential uppercase letters are not split.
Therefore, class name GetElementByJSON
, for example, results in the command name „Get Element By JSON“.
3. Usage
@JavaCommand
has to annotate a class that should represent a command.
In the following example in Listing 1, line 4 the @JavaCommand
annotation is used.
As the default for the displayname
property is an empty String and nothing else is defined for that property, the command name in Listing 1 will be derived by the class name, i.e. „Get Element“.
/**
* @workflowDocu This command gets an element by its id.
*/
@JavaCommand (1)
@CommandGroup("Element")
public class GetElement {
[..]
}
1 | Use of the @JavaCommand annotation with default value of displayname |
In contrast to the example before, Listing 2 sets the displayname
property to „Get Existing Element“.
This customized command name will then be displayed in the BPMN Editor and Workflow Executor.
/**
* @workflowDocu This command gets an element by its id.
*/
@JavaCommand(displayname = "Get Existing Element") (1)
@CommandGroup("Element")
public class GetElement {
[..]
}
1 | Use of the @JavaCommand annotation with displayname set to „Get Existing Element“ |