Martini Runtime Functions
The MartiniFunctions class provides a suite of functions designed for managing Martini packages and endpoints through code. These functions allow for various operations such as:
- Creation, import, update, and deletion of packages.
- Manipulation of package states.
- Retrieval of package details, including
package.xmland dependencies. - Creation, update, deletion, and validation of endpoints.
Contextual Note
These functions are primarily intended for use within the Martini platform context. They interact closely with Martini's built-in data models and core functionalities.
Managing Packages Programmatically
The MartiniFunctions class includes several methods for handling Martini packages. One of the key methods is savePackage, which is used to create or modify a package.
savePackage
The savePackage function is utilized for either creating a new package or updating an existing one within Martini.
Usage
1 | |
Parameters
The function takes the following parameter:
| Name | Index | Type | Description |
|---|---|---|---|
martiniPackage |
0 | io.toro.martini.package.Package |
The package to be created or updated. |
importPackage
The importPackage methods in the MartiniPackage class are designed to facilitate the importing of one or more existing packages into a Martini instance. These packages are imported from a ZIP archive, and there are two primary variations of the importPackage method to accommodate different sources of the package archive.
Usage
Martini provides two overloaded methods for importing packages:
1. Import from an InputStream:
1 | |
2. Import from a Path:
1 | |
Parameters
The functions take the following parameters:
| Name | Index | Type | Description |
|---|---|---|---|
inputStream |
0 | java.io.InputStream |
An InputStream representing the package ZIP stream. |
path |
0 | java.nio.file.Path |
A Path object representing the location of the package ZIP file. |
stateOnCreate |
1 | io.toro.martini.package.PackageState |
Specifies the state of the newly imported package(s). Valid states are UNLOADED, LOADED, and STARTED. |
resolveParent |
2 | java.lang.Boolean |
If true and the stateOnCreate is either STARTED or LOADED, Martini will also start any parent packages. An exception is thrown if parent packages are not in the proper state. |
replaceExisting |
3 | java.lang.Boolean |
If set to true, this will replace any existing package(s), unloading and removing them before importing the new package(s). |
Return Value
The function returns the following:
| Property | Type | Description |
|---|---|---|
martiniPackages |
io.toro.martini.package.Package |
A collection of the imported packages |
getPackageXml
The getPackageXml function in the Martini platform is designed to retrieve the XML content of a specific package's package.xml file. This function is particularly useful for examining package configurations and dependencies.
Usage
To get the XML content of a package's descriptor file, use the getPackageXml method:
1 | |
Parameters
This function requires the following parameter:
| Name | Type | Description |
|---|---|---|
packageName |
java.lang.String |
The name of the package for which the package descriptor is needed. |
Return Value
The function returns the XML content of the specified package's package.xml file:
| Name | Type | Description |
|---|---|---|
output |
java.lang.String |
The XML content of the package's package.xml file. |
getChildPackages
The getChildPackages function in Martini is used to retrieve a list of packages that are dependent on a specified package. This is useful for understanding package dependencies and relationships within the Martini environment.
Usage
To obtain the list of child packages or dependents of a given package, use the getChildPackages method:
1 | |
Parameters
This function requires the following parameter:
| Name | Index | Type | Description |
|---|---|---|---|
packageName |
0 | java.lang.String |
The name of the package for which dependent packages are sought. |
Return Value
The function returns an array of Package objects, representing the dependent packages:
| Name | Type | Description |
|---|---|---|
martiniPackages |
io.toro.martini.package.Package[] |
An array of packages that depend on the specified package. |
getParentPackages
The getParentPackages function in the Martini platform is designed to identify the list of packages that a specific Martini package depends on. This function is essential for understanding the dependency hierarchy and package relationships within Martini.
Usage
To retrieve the list of parent packages or dependencies of a given package, use the getParentPackages method:
1 | |
Parameters
This function takes the following parameter:
| Name | Type | Description |
|---|---|---|
packageName |
java.lang.String |
The name of the package for which the parent packages are sought. |
Return Value
The function returns an array of Package objects, representing the packages on which the specified package depends:
| Property | Type | Description |
|---|---|---|
martiniPackages |
io.toro.martini.package.Package[] |
An array of packages that the specified package depends on. |
getPackage
The getPackage function in the Martini platform is utilized to retrieve a specific package by its name. This function is key for accessing package details programmatically.
Usage
To obtain a Martini package by its name, use the getPackage method:
1 | |
Parameters
This function requires the following parameter:
| Name | Type | Description |
|---|---|---|
packageName |
java.lang.String |
The name of the package to retrieve. |
Return Value
The function returns a Package object representing the requested package:
| Name | Type | Description |
|---|---|---|
martiniPackage |
io.toro.martini.package.Package |
The package retrieved, represented as a data model. |
getPackages
The getPackages function in Martini is designed to provide a comprehensive list of all the currently installed Martini packages within a given Martini instance. This function is particularly useful for obtaining a global view of the package landscape in your environment.
Usage
To retrieve all installed Martini packages, use the getPackages method:
1 | |
Return Value
The function returns an array of Package objects, each representing an installed Martini package:
| Name | Type | Description |
|---|---|---|
martiniPackages |
io.toro.martini.package.Package[] |
An array containing all the Martini packages in the instance. |
startPackage
The startPackage function in the Martini platform is used to start a specified package by its name. This function is essential for initiating package operations within Martini.
Usage
To start a package within Martini, use the startPackage method:
1 | |
Parameters
The function requires the following parameter:
| Name | Type | Description |
|---|---|---|
packageName |
java.lang.String |
The name of the package to be started. |
stopPackage
The stopPackage function in the Martini platform is designed to stop a specified package by its name. This function is crucial for managing package operations, particularly when needing to halt a package's activities within Martini.
Usage
To stop a package within Martini, use the stopPackage method:
1 | |
Parameters
The function requires the following parameter:
| Name | Type | Description |
|---|---|---|
packageName |
java.lang.String |
The name of the package to be stopped. |
unloadPackage
The unloadPackage function in the Martini platform allows for unloading a specified package by its name. Additionally, it offers the option to determine the unloading of dependent packages.
Usage
To unload a package within Martini, use the unloadPackage method:
1 | |
Parameters
The function requires the following parameters:
| Name | Index | Type | Description |
|---|---|---|---|
packageName |
0 | java.lang.String |
The name of the package to be unloaded. |
resolveChild |
1 | java.lang.Boolean |
Flag to determine whether dependent packages should be unloaded. |
loadPackage
The loadPackage function in the Martini platform is utilized to load a package by its name. It also provides the option to control the loading of the package's dependencies.
Usage
To load a package in Martini, use the loadPackage method:
1 | |
Parameters
This function requires the following parameters:
| Name | Index | Type | Description |
|---|---|---|---|
packageName |
0 | java.lang.String |
The name of the package to be loaded. |
resolveParent |
1 | java.lang.Boolean |
Flag to determine whether package dependencies should be loaded. |
deletePackage
The deletePackage function in the Martini platform enables the deletion of packages by name. This function is crucial for managing the lifecycle of packages within Martini.
Usage
To delete a package in Martini, use the deletePackage method:
1 | |
Parameters
This function requires the following parameter:
| Name | Index | Type | Description |
|---|---|---|---|
packageName |
0 | java.lang.String |
The name of the package to be deleted. |
Precondition for Deletion
Before a package can be deleted, it must be unloaded. Attempting to delete a loaded package will result in an exception. Use the Martini.unloadPackage(String, Boolean) function to unload the package first.
Managing Endpoints Programmatically
The following functions are included in the MartiniFunctions extension class for managing Martini endpoints:
- [Function names and descriptions specific to endpoint management]
deleteEndpoint
The deleteEndpoint function in the Martini platform is designed to delete a specific endpoint by name. This function is essential for managing the lifecycle of endpoints within Martini applications.
Usage
To delete an endpoint in Martini, use the deleteEndpoint method:
1 | |
Parameters
This function requires the following parameters:
| Name | Index | Type | Description |
|---|---|---|---|
packageName |
0 | java.lang.String |
The name of the package that owns the endpoint to be deleted. |
endpointName |
1 | java.lang.String |
The name of the endpoint to delete. |
Precondition for Deletion
Before an endpoint can be deleted, it must be stopped. Attempting to delete a running endpoint will result in an exception. Ensure the endpoint is not active before proceeding with deletion.
disableEndpoint
The disableEndpoint function in the Martini platform is used to disable a specified endpoint by name. This function is vital for managing endpoint activity and availability within Martini applications.
Usage
To disable an endpoint in Martini, use the disableEndpoint method:
1 | |
Parameters
This function requires the following parameters:
| Name | Index | Type | Description |
|---|---|---|---|
packageName |
0 | java.lang.String |
The name of the package that owns the endpoint to be disabled. |
endpointName |
1 | java.lang.String |
The name of the endpoint to disable. |
enableEndpoint
The enableEndpoint function in the Martini platform is utilized to enable a specific endpoint by its name. This function is essential for managing the operational state of endpoints within Martini applications.
Usage
To enable an endpoint in Martini, use the enableEndpoint method:
1 | |
Parameters
This function requires the following parameters:
| Name | Index | Type | Description |
|---|---|---|---|
packageName |
0 | java.lang.String |
The name of the package that owns the endpoint to be enabled. |
endpointName |
1 | java.lang.String |
The name of the endpoint to enable. |
saveEndpoint
The saveEndpoint function in the Martini platform is designed to create a new endpoint or modify an existing one within a specified package. This function is crucial for the dynamic management of endpoints in Martini applications.
Usage
To create or edit an endpoint in Martini, use the saveEndpoint method:
1 | |
Parameters
This function requires the following parameters:
| Name | Type | Description |
|---|---|---|
packageName |
java.lang.String |
The name of the package that owns the endpoint. |
endpoint |
io.toro.martini.package.Endpoint |
The endpoint object to be created or updated. |
stopEndpoint
The stopEndpoint function in the Martini platform is used to stop a specific endpoint by name. This function is essential for managing the activity and availability of endpoints within Martini applications.
Usage
To stop an endpoint in Martini, use the stopEndpoint method:
1 | |
Parameters
The function requires the following parameters:
| Name | Index | Type | Description |
|---|---|---|---|
packageName |
0 | java.lang.String |
The name of the package that owns the endpoint to be stopped. |
endpointName |
1 | java.lang.String |
The name of the endpoint to stop. |
validateEndpoint
The validateEndpoint function in the Martini platform is used to verify the validity of a specified endpoint. This function plays a crucial role in ensuring the integrity and proper configuration of endpoints within Martini applications.
Usage
To validate an endpoint in Martini, use the validateEndpoint method:
1 | |
Parameters
This function requires the following parameters:
| Name | Type | Description |
|---|---|---|
packageName |
java.lang.String |
The name of the package that owns the endpoint. |
endpoint |
io.toro.martini.package.Endpoint |
The endpoint object to be validated. |
Function Behavior
- Return Value: The function returns
trueif the endpoint is valid. - Exception Handling: If the endpoint is not valid, the function throws an exception. This helps in identifying issues with endpoint configurations.