Package util

Class UrlModelService<T,​U>

  • Type Parameters:
    T - POJO model of the request to be sent to external API
    U - POJO model of the response to be received from the external API

    public abstract class UrlModelService<T,​U>
    extends Object
    Caller for external model that is executed via post requests to a URL;
    usage; Create an anonymous (child) class with
    UrlModelService<RequestModel,ResponseModel> myService = new UrlModelService<RequestModel,ResponseModel>(urlString) {}
    Author:
    Christoph Schimeczek
    • Field Detail

      • DEFAULT_TIMEOUT

        public static final int DEFAULT_TIMEOUT
        Default timeout: indefinite
        See Also:
        Constant Field Values
      • parameters

        public static final de.dlr.gitlab.fame.agent.input.Tree parameters
        Inputs specific for UrlModelServices
    • Constructor Detail

      • UrlModelService

        public UrlModelService​(String url,
                               int timeout)
        Create a new UrlModelService as an anonymous (child) class, see also OracleDocs
        Parameters:
        url - of the model service API
        timeout - max delay in milliseconds for the service to respond
        Throws:
        IllegalArgumentException - if URL is malformed
      • UrlModelService

        public UrlModelService​(String url)
        Create a new UrlModelService as an anonymous (child) class, see also OracleDocs
        Parameters:
        url - of the model service API
      • UrlModelService

        public UrlModelService​(de.dlr.gitlab.fame.agent.input.ParameterData input)
                        throws de.dlr.gitlab.fame.agent.input.ParameterData.MissingDataException
        Create a new UrlModelService as an anonymous (child) class, see also OracleDocs
        Parameters:
        input - covering at least the remote service URL
        Throws:
        de.dlr.gitlab.fame.agent.input.ParameterData.MissingDataException - if service URL is missing
    • Method Detail

      • call

        public U call​(T input)
        Marshalls given input to JSON, issues request to configured service and unmarshalls response to output format. See JSONObject for help regarding the annotation of fields in input and response classes.
        Parameters:
        input - POJO to be sent to service
        Returns:
        response from service as POJO
      • getTimeout

        public int getTimeout()
        Returns:
        max delay for service to respond in milliseconds
      • setTimeout

        public void setTimeout​(int timeout)
        Set max delay for service to respond
        Parameters:
        timeout - in milliseconds