Class MartiniMethods


  • public final class MartiniMethods
    extends Object
    Collection of one-liners for use by Gloop services, for managing Martini packages and endpoints.
    • 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 package
        resolveParent - 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 package
        resolveChild - 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

        @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, and version.
        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, and version.
        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
      • 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 belongs
        endpoint - 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 belongs
        endpoint - 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 belongs
        endpointName - 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 package
        endpointName - 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 package
        endpointName - 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 package
        endpointName - 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 package
        endpointName - 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. Returns null if the endpoint is not existing.
        Parameters:
        packageName - the name of the Martini package
        endpointName - 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