examples
package: Using Gloop annotations in Groovy
It is important to document your services so other developers know their purpose and how they can be used. Groovy services can be called in Gloop, but comments in Groovy do not get carried over to the Gloop development environment (since they're not included in the resulting class file), and Groovy doesn't allow for as much metadata about a method and its parameters as Gloop does for a service and its inputs and outputs. To address this, Gloop has annotations that you can use to decorate your Groovy code, and add any required metadata for Gloop.
Invoking Groovy in Gloop
The examples
package contains services that
demonstrate how you can call Groovy in Gloop and vice versa.
The examples
package includes gloopDocs.GloopDocsDemo.groovy
, a Groovy class whose methods are
annotated with Gloop annotations so that extra metadata about them are visible in Gloop. It shows the use of the
following Gloop annotations:
Annotation | Description |
---|---|
@GloopComment |
Use this annotation to add a method or class-wide comment. |
@GloopParameter |
Use this annotation to document method parameters and return values in detail. |
@GloopHide |
Use this to hide a public static Groovy method from Gloop. |
@GloopObjectParameter |
Use this annotation to describe the structure of a Gloop model. |
You can easily check that these annotations work by creating a new service and then
dragging any of GloopDocsDemo.groovy
's methods to it, thereby creating a new invoke step.
In the screenshot below, note how the comment for the method appears (1) after the invoke step and the tooltip. Also note how the parameter annotations appear (2) in the Mapper and the tooltip.
Related articles
Please see the following articles for more information:
Try it!
To double-check if the annotations work, create a new service and invoke the
methods of GloopDocsDemo.groovy
in that service by dragging and dropping GloopDocsDemo.groovy
's methods from the
Navigator view to the Gloop step editor1.
Can all Groovy functions be dragged and dropped?
As long as a Groovy method is public
static
and isn't annotated with @GloopHide
,
it can be dragged and dropped from the Navigator.
-
You must expand
GloopDocsDemo.groovy
's tree in the Navigator view to do this. ↩