examples
package: Invoking Gloop in Groovy and Groovy in Gloop
There are three primary types of services in Martini: Gloop,
Groovy, and Flux; and all three can be used in conjunction with each other. The
examples
package shows how you can use Gloop and Groovy together. In particular, how to call
Groovy services in services and vice versa.
Related articles
Please see the following articles for more information:
Try it!
To see how to invoke Groovy in Gloop, open and run the
invokeGloop.gloop.InvokeGroovy.gloop
service. For invoking Gloop in Groovy, open and run
invokeGloop.groovy.GloopInvoker.groovy
instead.
Both can be found under the invokeGloop
package, as seen below:
1 2 3 4 5 6 7 8 9 10 |
|
Explanation
Invoking Groovy in Gloop
To invoke a Groovy method in Gloop, you just need to drag and drop the method to the service, like so:
Doing this will create an invoke step in your service, as seen in
invokeGloop.gloop.InvokeGroovy.gloop
.
Invoking Gloop in Groovy
To invoke a service from a Groovy method, a special instance extension method has been included in Martini to make your code easier to read and more concise. The syntax looks similar to:
1 |
|
This method will return a GloopModel
object, from which you can extract the outputs of the service.
Custom service invocation
Check out the GloopInvoker
class
to see the other extension methods you can use to invoke Gloop in Groovy.