Package io.toro.martini
Class MartiniMethods
- java.lang.Object
-
- io.toro.martini.MartiniMethods
-
public final class MartiniMethods extends Object
Collection of one-liners for use by Gloop services, for managing Martini packages and endpoints.
-
-
Constructor Summary
Constructors Constructor Description MartiniMethods(io.toro.martini.ipackage.EndpointStateAttacher endpointStateAttacher, PackageManager packageManager, io.toro.martini.ipackage.MartiniPackageSerializer martiniPackageSerializer, io.toro.martini.ipackage.MartiniPackageDependencyResolver martiniPackageDependencyResolver, io.toro.martini.ipackage.PackageImportService packageImportService, io.toro.martini.ipackage.PackageInfoService packageInfoService, com.google.common.base.Converter<io.toro.martini.ipackage.PackageDescriptor,GloopModel> packageDescriptorGloopModelConverter, com.google.common.base.Converter<io.toro.martini.ipackage.PackageConfig,GloopModel> packageConfigGloopModelConverter, com.google.common.base.Converter<MartiniPackage,GloopModel> martiniPackageGloopModelConverter)
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static GloopModel
addPackage(GloopModel martiniPackage, String stateOnCreate, boolean resolveParent)
Add a new package to the current instance using data from the provided package model.static GloopModel
addPackage(String packageName, String id, String version, String stateOnCreate, boolean resolveParent)
Deprecated.Prefer usingaddPackage(GloopModel, String, boolean)
.static void
deleteEndpoint(String packageName, String endpointName)
Delete the endpoint matching the provided name and package.static void
deletePackage(String packageName)
Delete the package matching the provided name.static void
disableEndpoint(String packageName, String endpointName)
Disable the endpoint matching the provided name and package.static void
enableEndpoint(String packageName, String endpointName)
Enable the endpoint matching the provided name and package.static GloopModel
getChildPackages(String packageName)
Get the packages dependent on (child packages of) the package matching the provided name.static GloopModel
getEndpoint(String packageName, String endpointName)
Get the endpoint matching the provided name and package.static GloopModel
getEndpoints(String packageName)
Get all the endpoints on the matching package.static GloopModel
getPackage(String packageName)
Get the package matching the provided name, if it exists.static GloopModel
getPackages()
Get all the packages installed on the current Martini instance.static String
getPackageXml(String packageName)
Get the XML descriptor of the package matching the provided name as a string.static GloopModel
getParentPackages(String packageName)
Gets the dependencies of the package matching the provided name.static MartiniPackage
getRealPackage(String packageName)
Get the package matching the provided name, if it exists.static GloopModel
importPackage(InputStream inputStream, String stateOnCreate, boolean resolveParent, boolean replaceExisting)
Import the package from the provided stream.static GloopModel
importPackage(Path path, String stateOnCreate, boolean resolveParent, boolean replaceExisting)
Import the package from the provided path.static void
loadPackage(String packageName, boolean resolveParent)
Load the package matching the provided name.static GloopModel
packageConfigToGloopModel(MartiniPackage martiniPackage)
Fetch the configuration of the provided package, and then return it as a Gloop model.static GloopModel
packageConfigToGloopModel(io.toro.martini.ipackage.PackageConfig packageConfig)
Return the provided package configuration as a Gloop model.static void
saveEndpoint(String packageName, GloopModel endpoint)
Save an endpoint to the package matching the provided name.static void
savePackage(GloopModel martiniPackage)
Save a package using data from the provided package model.static void
startEndpoint(String packageName, String endpointName)
Start the endpoint matching the provided name and package.static void
startPackage(String packageName)
Start the package matching the provided name.static void
stopEndpoint(String packageName, String endpointName)
Stop the endpoint matching the provided name and package.static void
stopPackage(String packageName)
Stop the package matching the provided name.static void
unloadPackage(String packageName, boolean resolveChild)
Unload the package matching the provided name.static void
validateEndpoint(String packageName, GloopModel endpoint)
Validate the endpoint of a package; throwing an exception if the endpoint turns out to be invalid.
-
-
-
Constructor Detail
-
MartiniMethods
@Autowired public MartiniMethods(io.toro.martini.ipackage.EndpointStateAttacher endpointStateAttacher, PackageManager packageManager, io.toro.martini.ipackage.MartiniPackageSerializer martiniPackageSerializer, io.toro.martini.ipackage.MartiniPackageDependencyResolver martiniPackageDependencyResolver, io.toro.martini.ipackage.PackageImportService packageImportService, io.toro.martini.ipackage.PackageInfoService packageInfoService, @Qualifier("packageDescriptorConverter") com.google.common.base.Converter<io.toro.martini.ipackage.PackageDescriptor,GloopModel> packageDescriptorGloopModelConverter, @Qualifier("packageConfigConverter") com.google.common.base.Converter<io.toro.martini.ipackage.PackageConfig,GloopModel> packageConfigGloopModelConverter, @Qualifier("martiniPackageConverter") com.google.common.base.Converter<MartiniPackage,GloopModel> martiniPackageGloopModelConverter)
-
-
Method Detail
-
getPackages
@GloopObjectParameter("martiniPackages{\n martiniPackages#io.toro.martini.package.Package[]{\n }\n}") public static GloopModel getPackages()
Get all the packages installed on the current Martini instance.- Returns:
- array of models representing each installed package
- Since:
- 1.0
-
getPackage
@GloopObjectParameter("martiniPackage{\n martiniPackage#io.toro.martini.package.Package{\n }\n}") public static GloopModel getPackage(@GloopParameter(allowNull=false) String packageName)
Get the package matching the provided name, if it exists.- Parameters:
packageName
- the name of the Martini package- Returns:
- model representing the matched package
- Since:
- 1.0
-
getRealPackage
public static MartiniPackage getRealPackage(@GloopParameter(allowNull=false) String packageName)
Get the package matching the provided name, if it exists.- Parameters:
packageName
- the name of the Martini package- Returns:
- the real package object
- Since:
- 1.1
-
loadPackage
public static void loadPackage(@GloopParameter(allowNull=false) String packageName, @GloopParameter(defaultValue="true") boolean resolveParent) throws io.toro.martini.ipackage.exception.PackageLifeCycleException
Load the package matching the provided name.- Parameters:
packageName
- the name of the Martini packageresolveParent
- flag determining whether or not to also load the dependencies of the specified package- Throws:
io.toro.martini.ipackage.exception.PackageLifeCycleException
- Since:
- 1.0
-
unloadPackage
public static void unloadPackage(@GloopParameter(allowNull=false) String packageName, @GloopParameter(defaultValue="true") boolean resolveChild) throws io.toro.martini.ipackage.exception.PackageLifeCycleException
Unload the package matching the provided name.- Parameters:
packageName
- the name of the Martini packageresolveChild
- flag determining whether or not to also unload packages dependent on the specified package- Throws:
io.toro.martini.ipackage.exception.PackageLifeCycleException
- Since:
- 1.0
-
addPackage
@Deprecated @GloopObjectParameter("martiniPackage{\n martiniPackage#io.toro.martini.package.Package{\n }\n}") public static GloopModel addPackage(@GloopParameter(allowNull=false) String packageName, @GloopParameter(allowNull=false) String id, @GloopParameter(allowNull=false) String version, @GloopParameter(choices={"STARTED","LOADED","UNLOADED"},allowNull=false) String stateOnCreate, @GloopParameter(defaultValue="true") boolean resolveParent) throws io.toro.martini.ipackage.exception.PackageLifeCycleException
Deprecated.Prefer usingaddPackage(GloopModel, String, boolean)
.Add a new package to the current instance with the specified attributes.- Parameters:
packageName
- the name of the Martini packageid
- TORO Marketplace ID of the Martini packageversion
- version of the Martini package- Returns:
- the newly added Martini package as a model
- Throws:
io.toro.martini.ipackage.exception.PackageLifeCycleException
- Since:
- 1.0
-
addPackage
@GloopObjectParameter("martiniPackage{\n martiniPackage#io.toro.martini.package.Package{\n }\n}") public static GloopModel addPackage(@GloopObjectParameter("martiniPackage#io.toro.martini.package.PackageDescriptor::false{\n}") GloopModel martiniPackage, @GloopParameter(choices={"STARTED","LOADED","UNLOADED"},allowNull=false) String stateOnCreate, @GloopParameter(defaultValue="true") boolean resolveParent) throws io.toro.martini.ipackage.exception.PackageLifeCycleException
Add a new package to the current instance using data from the provided package model. This one-liner requires the package model to provide at least the following properties:name
,id
, andversion
.- Parameters:
martiniPackage
- a model representing the package to be added- Returns:
- the newly added Martini package
- Throws:
io.toro.martini.ipackage.exception.PackageLifeCycleException
- Since:
- 1.0
-
savePackage
public static void savePackage(@GloopObjectParameter("martiniPackage#io.toro.martini.package.Package::false{\n}") GloopModel martiniPackage)
Save a package using data from the provided package model. This one-liner requires the package model to provide at least the following properties:name
,id
, andversion
.- Parameters:
martiniPackage
- a model representing the package to be saved- Since:
- 1.0
-
deletePackage
public static void deletePackage(@GloopParameter(allowNull=false) String packageName)
Delete the package matching the provided name.- Parameters:
packageName
- the name of the Martini package- Since:
- 1.0
-
startPackage
public static void startPackage(@GloopParameter(allowNull=false) String packageName) throws io.toro.martini.ipackage.exception.PackageLifeCycleException
Start the package matching the provided name.- Parameters:
packageName
- the name of the Martini package- Throws:
io.toro.martini.ipackage.exception.PackageLifeCycleException
- Since:
- 1.0
-
stopPackage
public static void stopPackage(@GloopParameter(allowNull=false) String packageName) throws io.toro.martini.ipackage.exception.PackageLifeCycleException
Stop the package matching the provided name.- Parameters:
packageName
- the name of the Martini package- Throws:
io.toro.martini.ipackage.exception.PackageLifeCycleException
- Since:
- 1.0
-
getChildPackages
@GloopObjectParameter("martiniPackages{\n martiniPackages#io.toro.martini.package.PackageDescriptor[]{\n }\n}") public static GloopModel getChildPackages(@GloopParameter(allowNull=false) String packageName)
Get the packages dependent on (child packages of) the package matching the provided name.- Parameters:
packageName
- the name of the Martini package- Returns:
- array of models representing resolved dependent packages
- Since:
- 1.0
-
getPackageXml
public static String getPackageXml(@GloopParameter(allowNull=false) String packageName)
Get the XML descriptor of the package matching the provided name as a string.- Parameters:
packageName
- the name of the Martini package- Returns:
- string representation of the Martini package's XML descriptor
- Since:
- 1.0
-
getParentPackages
@GloopObjectParameter("martiniPackages{\n martiniPackages#io.toro.martini.package.PackageDescriptor[]{\n }\n}") public static GloopModel getParentPackages(@GloopParameter(allowNull=false) String packageName)
Gets the dependencies of the package matching the provided name.- Parameters:
packageName
- the name of the Martini package- Returns:
- array of models representing resolved package dependencies
- Since:
- 1.0
-
importPackage
@GloopObjectParameter("martiniPackages{\n martiniPackages#io.toro.martini.package.Package[]{\n }\n}") public static GloopModel importPackage(@GloopParameter(allowNull=false) Path path, @GloopParameter(choices={"STARTED","LOADED","UNLOADED"}) String stateOnCreate, @GloopParameter(defaultValue="true") boolean resolveParent, @GloopParameter(allowNull=false,defaultValue="false") boolean replaceExisting) throws IOException
Import the package from the provided path.- Parameters:
path
- the path of the to-be-imported packagestateOnCreate
- the desired state of the package upon successful importreplaceExisting
- flag determining whether or not to replace an existing package of the same name, if any- Returns:
- a model representing the newly imported package
- Throws:
IOException
- Since:
- 1.0
-
importPackage
@GloopObjectParameter("martiniPackages{\n martiniPackages#io.toro.martini.package.Package[]{\n }\n}") public static GloopModel importPackage(@GloopParameter(allowNull=false) InputStream inputStream, @GloopParameter(choices={"STARTED","LOADED","UNLOADED"}) String stateOnCreate, @GloopParameter(defaultValue="true") boolean resolveParent, @GloopParameter(allowNull=false,defaultValue="false") boolean replaceExisting) throws IOException
Import the package from the provided stream.- Parameters:
inputStream
- the stream containing the to-be-imported packagestateOnCreate
- the desired state of the package upon successful importreplaceExisting
- flag determining whether or not to replace an existing package of the same name, if any- Returns:
- a model representing the newly imported package
- Throws:
IOException
- Since:
- 1.0
-
validateEndpoint
public static void validateEndpoint(@GloopParameter(allowNull=false) String packageName, @GloopObjectParameter("endpoint#io.toro.martini.package.Endpoint::false{\n}") GloopModel endpoint)
Validate the endpoint of a package; throwing an exception if the endpoint turns out to be invalid.- Parameters:
packageName
- the name of the Martini package where the endpoint belongsendpoint
- name of endpoint
-
saveEndpoint
public static void saveEndpoint(@GloopParameter(allowNull=false) String packageName, @GloopObjectParameter("endpoint#io.toro.martini.package.Endpoint::false{\n}") GloopModel endpoint)
Save an endpoint to the package matching the provided name.- Parameters:
packageName
- the name of the Martini package where the endpoint belongsendpoint
- name of endpoint
-
startEndpoint
public static void startEndpoint(@GloopParameter(allowNull=false) String packageName, @GloopParameter(allowNull=false) String endpointName)
Start the endpoint matching the provided name and package.- Parameters:
packageName
- the name of the Martini package where the endpoint belongsendpointName
- name of endpoint
-
enableEndpoint
public static void enableEndpoint(@GloopParameter(allowNull=false) String packageName, @GloopParameter(allowNull=false) String endpointName)
Enable the endpoint matching the provided name and package.- Parameters:
packageName
- the name of the Martini packageendpointName
- name of endpoint
-
disableEndpoint
public static void disableEndpoint(@GloopParameter(allowNull=false) String packageName, @GloopParameter(allowNull=false) String endpointName)
Disable the endpoint matching the provided name and package.- Parameters:
packageName
- the name of the Martini packageendpointName
- name of endpoint
-
stopEndpoint
public static void stopEndpoint(@GloopParameter(allowNull=false) String packageName, @GloopParameter(allowNull=false) String endpointName)
Stop the endpoint matching the provided name and package.- Parameters:
packageName
- the name of the Martini packageendpointName
- name of endpoint
-
deleteEndpoint
public static void deleteEndpoint(@GloopParameter(allowNull=false) String packageName, @GloopParameter(allowNull=false) String endpointName)
Delete the endpoint matching the provided name and package.- Parameters:
packageName
- the name of the Martini packageendpointName
- name of endpoint
-
getEndpoints
@GloopObjectParameter("endpoints{\n endpoints#io.toro.martini.package.Endpoint[]{\n }\n}") public static GloopModel getEndpoints(@GloopParameter(allowNull=false) String packageName) throws io.toro.martini.ipackage.exception.PackageIllegalStateException
Get all the endpoints on the matching package.- Parameters:
packageName
- the name of the Martini package- Returns:
- array of models representing each endpoint
- Throws:
io.toro.martini.ipackage.exception.PackageIllegalStateException
- if package is not loaded- Since:
- 1.1
-
getEndpoint
@GloopObjectParameter("endpoint{\n endpoint#io.toro.martini.package.Endpoint{\n }\n}") public static GloopModel getEndpoint(@GloopParameter(allowNull=false) String packageName, @GloopParameter(allowNull=false) String endpointName) throws io.toro.martini.ipackage.exception.PackageIllegalStateException
Get the endpoint matching the provided name and package. Returnsnull
if the endpoint is not existing.- Parameters:
packageName
- the name of the Martini packageendpointName
- name of endpoint- Returns:
- model representing the matched endpoint
- Throws:
io.toro.martini.ipackage.exception.PackageIllegalStateException
- if package is not loaded- Since:
- 1.1
-
packageConfigToGloopModel
public static GloopModel packageConfigToGloopModel(MartiniPackage martiniPackage)
Fetch the configuration of the provided package, and then return it as a Gloop model.- Parameters:
martiniPackage
- the package whose configuration will be retrieved- Returns:
- the package configuration of the provided package as a Gloop model
-
packageConfigToGloopModel
public static GloopModel packageConfigToGloopModel(io.toro.martini.ipackage.PackageConfig packageConfig)
Return the provided package configuration as a Gloop model.- Parameters:
packageConfig
- the package configuration- Returns:
- the package configuration as a Gloop model
-
-