Class ServiceInvoker


  • public class ServiceInvoker
    extends java.lang.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 Summary

      Constructors 
      Constructor Description
      ServiceInvoker()
      Create a service invoker object.
      ServiceInvoker​(SvcDef svcDef)
      Create a service invoker object.
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      java.lang.Object invoke()
      Invoke the service specified by the service definition name, version and client code and return the resulting object.
      java.lang.Object invoke​(java.lang.String paramName, java.lang.Object paramValue)
      Invoke the service specified by the service definition name, version and client code and return the resulting object.
      java.lang.Object invoke​(java.util.Map<java.lang.String,​java.lang.Object> params)
      Invoke the service specified by the service definition name, version and client code, with the given params and return the resulting object.
      ServiceInvoker setClientCode​(java.lang.String clientCode)
      Set the service definition organization client code to invoke.
      ServiceInvoker setLogger​(Logger logger)
      Set the service logger.
      ServiceInvoker setServiceName​(java.lang.String serviceName)
      Set the service definition name to invoke.
      ServiceInvoker setSvcDef​(SvcDef svcDef)
      Set the service definition to invoke.
      ServiceInvoker setVersion​(java.lang.String version)
      Set the service definition version to invoke.
      ServiceInvoker setVersionNumber​(int versionNumber)
      Deprecated.
      ServiceInvoker withHighestVersion()
      Set flag to invoke the service with highest version number.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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​(java.lang.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​(java.lang.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​(java.lang.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 java.lang.Object invoke​(java.util.Map<java.lang.String,​java.lang.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 java.lang.Object invoke​(java.lang.String paramName,
                                       java.lang.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 java.lang.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