Skip to content

Home

Development

IDEs

JAR services

API Explorer

Functions

The term 'functions' is used to refer to the collection of utility classes that are shipped with and exposed to the Martini development environment out-of-the-box, typically via extension modules1. They provide functions intended to solve common application problems with literally one line of code, hence the name 'functions'.

Most function classes are located in the io.toro.martini package. They can all be used in Groovy services, but some functions are intended for use in Gloop only. These Gloop-specific functions are alternatively called 'Gloop core services' and are the set of functions shown in the Navigator view. To see them, expand the services directory of the core package:

Gloop core services, as seen in the Navigator view

Gloop core services, as seen in the Navigator view

Not all functions are displayed in the Navigator

The functions shown in the Navigator view are those that are for use in services. Functions for Groovy are not displayed entirely.

Martini makes these core services easier and quicker to use by allowing them to be dragged and dropped into opened services:

Dragging Core services to a service

Dragging Core services to a service

Additionally, you can also view a function's Javadoc by right-clicking on it in the Navigator view and selecting Open Javadoc:

||| "Martini Desktop" Opening the Javadoc of a function class

Collection of functions

Most functions are made and maintained by TORO and are specifically for use in Martini. These functions are listed and described in the following table:

Name For Groovy For Gloop Description
io.toro.martini.Array No Yes Contains extension functions for performing operations on iterables.
io.toro.martini.Boolean No Yes Contains utility functions for handling boolean primitives and Boolean objects.
io.toro.martini.Cache Yes Yes Contains extension functions for managing caches.
io.toro.martini.Core Yes No Contains extension functions for invoking services and getting objects from Martini's application context.
io.toro.martini.Csv Yes No Contains extension functions for CSV-related operations.
io.toro.martini.Email Yes Yes Contains utility functions for reading and sending emails.
io.toro.martini.File Yes Yes Contains extension functions for reading and writing to files.
io.toro.martini.FlatFile No Yes Contains utility functions for reading and writing to flat files.
io.toro.martini.Flux Yes Yes Contains extension functions for executing, terminating, sending events, adding and removing tags, and getting the contexts of Flux services.
io.toro.martini.Gloop No Yes Contains a variety of handy functions for use inside Gloop services.
io.toro.martini.Groovy Yes Yes Contains extension functions that help manage packages, package properties, instance properties, and others.
io.toro.martini.HttpClient Yes No Contains extension functions for HTTP operations.
io.toro.martini.Http No Yes Contains utility functions for mapping HTTP-based operations in Gloop.
io.toro.martini.Jabber Yes Yes Contains extension functions for sending and receiving instant messages from Jabber endpoints.
io.toro.martini.DatabaseConnectionPool No Yes Contains extension functions for managing the lifecycle of database connection pools.
io.toro.martini.Jms Yes Yes Contains extension functions for publishing and responding to JMS messages.
io.toro.martini.Json No Yes Contains utility functions for creating a Gloop object from a JSON string and vice versa.
io.toro.martini.KafkaClients Yes Yes Contains extension functions for interacting with Kafka.
io.toro.martini.Logger Yes Yes Contains extension functions for logging messages.
io.toro.martini.Marshaller Yes No Contains extension functions for converting objects to and from JSON or XML.
io.toro.martini.Martini No Yes Contains utility functions for managing Martini packages and endpoints in Gloop.
io.toro.martini.MongoDb No Yes Contains utility functions for performing MongoDB operations.
io.toro.martini.Monitor Yes Yes Contains extension functions for searching invoke documents, managing monitor rules, and checking and setting API costs.
io.toro.martini.Number Yes Yes Exposes Apache Commons Lang's NumberUtils class as a one-liner.
io.toro.martini.ProxyRequest Yes Yes Contains extension functions used to proxy incoming HTTP requests to another server; helpful when dealing with legacy APIs.
io.toro.martini.RemoteDeployment No Yes Contains utility functions for remotely deploying packages from one instance to another.
io.toro.martini.Rest Yes No Contains extension functions for executing requests against REST endpoints.
io.toro.martini.Rss Yes Yes Contains extension functions for fetching RSS feeds.
io.toro.martini.Solr Yes Yes Contains extension functions for querying and writing to Solr cores and creating Solr schemas.
io.toro.martini.Sql Yes Yes Contains extension functions for connecting to JDBC databases.
io.toro.martini.Stream No Yes Contains utility functions for mapping Streams in Gloop.
io.toro.martini.String Yes Yes Contains extension functions for manipulating streams; exposes Apache Commons Lang's StringUtils class as a one-liner.
io.toro.martini.Throttling Yes Yes Contains extension functions for managing throttling rules.
io.toro.martini.Tracker Yes Yes Contains extension functions for adding, searching, updating, and deleting documents in the Tracker search index.
io.toro.martini.Url Yes Yes Contains extension functions for manipulating URLs.
io.toro.martini.UserGroup No Yes Contains extension functions for managing access control.
io.toro.martini.Util Yes Yes Contains extension functions for formatting and converting double and long values to string values.
io.toro.martini.Velocity Yes Yes Contains extension functions for parsing Velocity templates.
io.toro.martini.Vfs Yes Yes Contains extension functions for sending and fetching files, especially files from remote servers.
io.toro.martini.WebSocket Yes Yes Contains extension functions for sending web socket messages.
io.toro.martini.WidgetPage Yes Yes Contains extension functions for fetching pages and widgets made from the Report Builder.
io.toro.martini.Xml No Yes Contains utility functions for creating a Gloop object from an XML string and vice versa.
io.toro.martini.Yaml No Yes Contains utility functions for creating a Gloop object from a YAML string and vice versa.

Why are some classes not meant for use in Gloop or Groovy?

All functions are written in Groovy or Java and thus, can be used in Groovy code2. As a consequence, they can also be used in Gloop invoke and some script steps. There are no restrictions in where or when to use functions but TORO recommends using Gloop or your chosen language's built-in features when they provide more or less the same benefit as using a function.

Some functions are not needed in Groovy because Groovy already provides the means to perform their operations inherently using a single line of code; likewise, some functions are not recommended for use in Gloop because Gloop already has the constructs necessary to perform those functions natively.

The following helper classes from Apache Commons are also exposed, for use in both Gloop and Groovy:

Additionally, Martini exposes the Groovy class org.codehaus.groovy.runtime.DefaultGroovyFunctions which is comprised of a variety of functions for modifying strings, performing operations on collections, reading and writing to files, and more.

Create your own functions!

Martini allows you to register your own custom extension modules.


  1. Gloop-specific functions are actually just regular public static functions available for use for all classes. Functions usable in Groovy are those that are exposed via extension modules as instance extension functions

  2. When using Gloop-specific functions in Groovy, call the function services as static functions as they are technically not extension functions.