Package util
Class UrlModelService<T,U>
- java.lang.Object
-
- util.UrlModelService<T,U>
-
- Type Parameters:
T
- POJO model of the request to be sent to external APIU
- 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 Summary
Fields Modifier and Type Field Description static int
DEFAULT_TIMEOUT
Default timeout: indefinitestatic de.dlr.gitlab.fame.agent.input.Tree
parameters
Inputs specific forUrlModelService
s
-
Constructor Summary
Constructors Constructor Description UrlModelService(de.dlr.gitlab.fame.agent.input.ParameterData input)
Create a newUrlModelService
as an anonymous (child) class, see also OracleDocsUrlModelService(String url)
Create a newUrlModelService
as an anonymous (child) class, see also OracleDocsUrlModelService(String url, int timeout)
Create a newUrlModelService
as an anonymous (child) class, see also OracleDocs
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description U
call(T input)
Marshalls given input to JSON, issues request to configured service and unmarshalls response to output format.int
getTimeout()
void
setTimeout(int timeout)
Set max delay for service to respond
-
-
-
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 forUrlModelService
s
-
-
Constructor Detail
-
UrlModelService
public UrlModelService(String url, int timeout)
Create a newUrlModelService
as an anonymous (child) class, see also OracleDocs- Parameters:
url
- of the model service APItimeout
- max delay in milliseconds for the service to respond- Throws:
IllegalArgumentException
- if URL is malformed
-
UrlModelService
public UrlModelService(String url)
Create a newUrlModelService
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 newUrlModelService
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. SeeJSONObject
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
-
-