MartiniMethods
The MartiniMethods
class contains Gloop-specific
one-liners for managing Martini packages and
endpoints programmatically. It includes methods for:
- creating, importing, updating, deleting packages;
- manipulating package states;
- getting the
package.xml
of a package; - getting package dependencies;
- creating, updating, deleting endpoints;
- manipulating endpoint states; and
- validating endpoints.
MartiniMethods
one-liners are for Gloop-use only
Most, if not all, of the methods 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 one-liners are meant to make it easy to do the same in Gloop.
MartiniMethods
uses built-in models from core
Martini includes pre-declared Gloop models in the core
package. Some of these models
are used by one-liners from MartiniMethods
as inputs or outputs.
Managing packages programmatically
Below are the methods included in the MartiniMethods
class for handling Martini packages in Gloop.
savePackage
Use the MartiniMethods.savePackage(GloopModel)
method 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(...)
methods 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 MartiniMethods.getPackageXml(String)
one-liner 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 MartiniMethods.getChildPackages(String)
one-liner 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 MartiniMethods.getParentPackages(String)
method 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 MartiniMethods.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 Gloop model |
Usage
getPackages
The MartiniMethods.getPackages()
one-liner 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 MartiniMethods.startPackage(String)
one-liner 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 MartiniMethods.stopPackage(String)
one-liner 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 MartiniMethods.unloadPackage(String, Boolean)
one-liner 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 MartiniMethods.loadPackage(String, boolean)
one-liner 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 MartiniMethods.deletePackage(String)
one-liner 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 MartiniMethods.unloadPackage(String,Boolean)
one-liner first before deleting a
loaded package; otherwise an exception will be thrown.
Managing endpoints programmatically
Below are the methods included in the MartiniMethods
extension class for interacting with Martini endpoints in
Gloop.
deleteEndpoint
Use the MartiniMethods.deleteEndpoint(String, String)
one-liner 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 MartiniMethods.disableEndpoint(String, String)
method 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 MartiniMethods.enableEndpoint(String, String)
method 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 MartiniMethods.saveEndpoint(String, GloopModel)
one-liner 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 MartiniMethods.startEndpoint(String, String)
one-liner 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 MartiniMethods.stopEndpoint(String, String)
one-liner 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 MartiniMethods.validateEndpoint(String, GloopModel)
method 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 |