Class ServiceInvoker


  • public class ServiceInvoker
    extends Object

    Provides a Service Definition service invoker class.

    Examples

    Please find the service invoker examples below.

    Service Invoke Example

    These Groovy examples show how to invoke service by name, client and version (current, highest, third).

     import com.avoka.tm.svc.ServiceInvoker
    
     Object currentVer = new ServiceInvoker()
                 .setServiceName("myServiceName")
                 .setClientCode("client")
                 .invoke();
    
     Object highestVer = new ServiceInvoker()
                 .setServiceName("myServiceName")
                 .setClientCode("client")
                 .withHighestVersion()
                 .invoke();
    
     Object thirdVer = new ServiceInvoker()
                 .setServiceName("myServiceName")
                 .setClientCode("client")
                 .setVersion("0.3.1")
                 .invoke() 
    Since:
    5.0.0
    • Constructor Detail

      • ServiceInvoker

        public ServiceInvoker()
        Create a service invoker object.
      • ServiceInvoker

        public ServiceInvoker​(SvcDef svcDef)
        Create a service invoker object.
        Parameters:
        svcDef - the service definition to invoke (required)
    • Method Detail

      • setSvcDef

        public ServiceInvoker setSvcDef​(SvcDef svcDef)
        Set the service definition to invoke.
        Parameters:
        svcDef - the service definition
        Returns:
        the service invoker
      • setServiceName

        public ServiceInvoker setServiceName​(String serviceName)
        Set the service definition name to invoke.
        Parameters:
        serviceName - the service definition name to invoke
        Returns:
        the service invoker
      • setVersionNumber

        @Deprecated
        public ServiceInvoker setVersionNumber​(int versionNumber)
        Deprecated.
        Set the service definition version number to invoke. If not specified, then the current one will be used
        Parameters:
        versionNumber - service definition version number to invoke
        Returns:
        the service invoker
      • setVersion

        public ServiceInvoker setVersion​(String version)
        Set the service definition version to invoke. If not specified, then the current one will be used
        Parameters:
        version - service definition version number to invoke (required)
        Returns:
        the service invoker
        Since:
        17.10.0
      • setClientCode

        public ServiceInvoker setClientCode​(String clientCode)
        Set the service definition organization client code to invoke.
        Parameters:
        clientCode - service definition client code to invoke
        Returns:
        the service invoker
      • setLogger

        public ServiceInvoker setLogger​(Logger logger)
        Set the service logger.
        Parameters:
        logger - the service logger
        Returns:
        the service invoker
        Since:
        17.10.0
      • withHighestVersion

        public ServiceInvoker withHighestVersion()
        Set flag to invoke the service with highest version number.
        Returns:
        the service invoker
      • invoke

        public Object invoke​(Map<String,​Object> params)
        Invoke the service specified by the service definition name, version and client code, with the given params and return the resulting object.
        Parameters:
        params - the map of parameter to invoke the groovy service with
        Returns:
        invoke the service and return the resulting object
      • invoke

        public Object invoke​(String paramName,
                             Object paramValue)
        Invoke the service specified by the service definition name, version and client code and return the resulting object. This invoke method will create a singleton map with the paramName and paramValue key/value pair.
        Parameters:
        paramName - the singleton map parameter name (required)
        paramValue - the singleton map parameter value (require)
        Returns:
        invoke the service and return the resulting object
        Since:
        17.10.0
      • invoke

        public Object invoke()
        Invoke the service specified by the service definition name, version and client code and return the resulting object.
        Returns:
        invoke the service and return the resulting object