MartiniFunctions
The Martini class contains Gloop-specific
functions for managing Martini packages and
endpoints programmatically. It includes functions for:
- creating, importing, updating, deleting packages;
- manipulating package states;
- getting the
package.xmlof a package; - getting package dependencies;
- creating, updating, deleting endpoints;
- manipulating endpoint states; and
- validating endpoints.
Martini functions are for Gloop-use only
Most, if not all, of the functions in this class require and/or return Gloop-specific objects. More importantly, Martini already provides Groovy/Java classes that are capable of performing the functions above. These functions are meant to make it easy to do the same in Gloop.
Martini uses built-in models from core
Martini includes pre-declared Data models in the core package. Some of these models
are used by functions from MartiniFunctions as inputs or outputs.
Managing packages programmatically
Below are the functions included in the MartiniFunctions class for handling Martini packages in Gloop.
savePackage
Use the Martini.savePackage(GloopModel) function to create a new package or modify an existing one.
Parameters
| Name | Index | Type | Description |
|---|---|---|---|
martiniPackage |
0 | io.toro.martini.package.Package |
The to-be-created or to-be-updated package |
Usage

importPackage
Use either of the importPackage(...) functions below to add one or more existing packages to your Martini instance
from a ZIP archive:
MartiniPackage.importPackage(InputStream, PackageState, boolean, boolean)MartiniPackage.importPackage(Path, PackageState, boolean, boolean)
Parameters
| Name | Index | Type | Description |
|---|---|---|---|
path |
0 | java.nio.file.Path |
Package ZIP file |
inputStream |
0 | java.io.InputStream |
Package ZIP stream |
stateOnCreate |
1 | io.toro.martini.ipackage.PackageState |
Indicates what state the newly imported package(s) are to be in when imported. Allowable choices are UNLOADED, LOADED, and STARTED |
resolveParent |
2 | java.lang.Boolean |
If stateOnCreate is STARTED or LOADED and resolveParent is true, Martini will automatically start any parent package(s) as well, otherwise an exception is thrown if any parent packages are not properly started or loaded |
replaceExisting |
3 | java.lang.Boolean |
Replace existing package(s). This will unload, and remove any existing package(s) prior to importing any packages |
Return value
| Property | Type | Description |
|---|---|---|
martiniPackages |
io.toro.martini.package.Package |
Collection of imported packages |
Usage


getPackageXml
The Martini.getPackageXml(String) function allows the caller to get the string content of a specified
package's package.xml file.
Parameters
| Name | Type | Description |
|---|---|---|
packageName |
java.lang.String |
The name of the package whose package descriptor file is to be fetched |
Return value
| Name | Type | Description |
|---|---|---|
output |
java.lang.String |
The content of the package's package.xml file |
Usage

getChildPackages
Use the Martini.getChildPackages(String) function to get the list of packages dependent on the named
package.
Parameters
| Name | Index | Type | Description |
|---|---|---|---|
packageName |
0 | java.lang.String |
The name of the package whose dependencies will be fetched |
Return value
| Name | Type | Description |
|---|---|---|
martiniPackages |
io.toro.martini.package.Package[] |
The collection of dependent packages |
Usage

getParentPackages
The Martini.getParentPackages(String) function is used to get the list of packages a given Martini package
requires (depends on).
Parameters
| Name | Type | Description |
|---|---|---|
packageName |
java.lang.String |
The name of the package whose dependencies will be fetched |
Return value
| Property | Type | Description |
|---|---|---|
martiniPackages |
io.toro.martini.package.Package[] |
The list of packages the Martini package is dependent on |
Usage

getPackage
Use Martini.getPackage(String) to get a package by its name.
Parameters
| Name | Type | Description |
|---|---|---|
packageName |
java.lang.String |
The name of the package to get |
Return value
| Name | Type | Description |
|---|---|---|
martiniPackage |
io.toro.martini.package.Package |
The package represented as a data model |
Usage

getPackages
The Martini.getPackages() function allows the caller to obtain all currently installed Martini packages in
the Martini instance.
Return value
| Name | Type | Description |
|---|---|---|
martiniPackages |
io.toro.martini.package.Package[] |
A list of all residing Martini packages in the instance |
Usage

startPackage
Use the Martini.startPackage(String) function to start a package by name.
Parameters
| Name | Type | Description |
|---|---|---|
packageName |
java.lang.String |
The name of the package to start |
Usage

stopPackage
Use the Martini.stopPackage(String) function to stop a package by name.
Parameters
| Name | Type | Description |
|---|---|---|
packageName |
java.lang.String |
The name of the package to stop |
Usage

unloadPackage
Use the Martini.unloadPackage(String, Boolean) function to unload a package by name.
Parameters
| Name | Index | Type | Description |
|---|---|---|---|
packageName |
0 | java.lang.String |
The name of the package to unload |
resolveChild |
1 | java.lang.Boolean |
Determines whether to also unload dependent packages or not |
Usage

loadPackage
Use the Martini.loadPackage(String, boolean) function to load package by their name.
Parameters
| Name | Index | Type | Description |
|---|---|---|---|
packageName |
0 | java.lang.String |
The name of the package to load |
resolveParent |
1 | java.lang.Boolean |
Determines whether to also load package dependencies or not |
Usage

deletePackage
Use the Martini.deletePackage(String) function to delete packages by their name.
Parameters
| Name | Index | Type | Description |
|---|---|---|---|
packageName |
0 | java.lang.String |
The name of the package to delete |
Usage

A package must be unloaded before it can be deleted
You should call the Martini.unloadPackage(String,Boolean) function first before deleting a
loaded package; otherwise an exception will be thrown.
Managing endpoints programmatically
Below are the functions included in the MartiniFunctions extension class for interacting with Martini endpoints in
Gloop.
deleteEndpoint
Use the Martini.deleteEndpoint(String, String) function to delete an endpoint by name.
Parameters
| Name | Index | Type | Description |
|---|---|---|---|
packageName |
0 | java.lang.String |
The name of the package owning the endpoint to be deleted |
endpointName |
1 | java.lang.String |
The name of the endpoint to delete |
Usage

Stop the endpoint first before deleting
Martini will thrown an exception if you try to delete a running endpoint.
disableEndpoint
Use the Martini.disableEndpoint(String, String) function to disable an endpoint by name.
Parameters
| Name | Index | Type | Description |
|---|---|---|---|
packageName |
0 | java.lang.String |
The name of the package owning the endpoint to be disabled |
endpointName |
1 | java.lang.String |
The name of the endpoint to disable |
Usage

enableEndpoint
Use the Martini.enableEndpoint(String, String) function to enable an endpoint by name.
Parameters
| Name | Index | Type | Description |
|---|---|---|---|
packageName |
0 | java.lang.String |
The name of the package owning the endpoint to be enabled |
endpointName |
1 | java.lang.String |
The name of the endpoint to enable |
Usage

saveEndpoint
Use the Martini.saveEndpoint(String, GloopModel) function to create a new endpoint or edit an existing one.
Parameters
| Name | Type | Description |
|---|---|---|
packageName |
java.lang.String |
The name of the package owning the endpoint |
endpoint |
io.toro.martini.package.Endpoint |
The endpoint to be saved |
Usage

startEndpoint
Use the Martini.startEndpoint(String, String) function to start an endpoint by name.
Parameters
| Name | Index | Type | Description |
|---|---|---|---|
packageName |
0 | java.lang.String |
The name of the package owning the endpoint to be started |
endpointName |
1 | java.lang.String |
The name of the endpoint to start |
Usage

stopEndpoint
Use the Martini.stopEndpoint(String, String) function to stop an endpoint by name.
Parameters
| Name | Index | Type | Description |
|---|---|---|---|
packageName |
0 | java.lang.String |
The name of the package owning the endpoint to be stopped |
endpointName |
1 | java.lang.String |
The name of the endpoint to stop |
Usage

validateEndpoint
The Martini.validateEndpoint(String, GloopModel) function returns true when the given endpoint is valid;
otherwise, it throws an exception.
Parameters
| Name | Type | Description |
|---|---|---|
packageName |
java.lang.String |
The name of the package owning the endpoint |
endpoint |
io.toro.martini.package.Endpoint |
The endpoint to be validated |
Return value
| Name | Type | Description |
|---|---|---|
output |
boolean |
Whether or not the endpoint is valid |
Usage
