PAK Core – ICommandRestService
The PAK-Core harbors the core functionality of the PAK-framework. It enables the creation, fetching and execution of Commands.
Every component within the core-module, plays a vital part in PAK. This chapter describes the functionality of the ICommandRestService
interface.
1. Basics
ICommandRestService
is extending the ILiteService
interface, which makes it a LiteService. This service can therefore be injected
by using the @LiteService
annotation, by the Java-Interpreter. Otherwise, it is available in the IServiceProvider
, to be used by other
services/ components. It’s a low-code solution to conduct rest-calls within a command.
2. Usage
Those rest-calls can be created with the help of IEndpointClientFactory
, which is an instance within ICommandRestService
.
IEndpointClientFactory
, is a basic factory-class. It enables the user to create different instances of IEndpointClientService
,
by passing different parameters via its constructor.
3. Register
Don’t forget to register the implementing class of ICommandRestService
to the PAK-framework. This: Guide
will show you how.
Listing 1 shows how to inject and use ICommandRestService
ICommandRestService
/**
* @workflowDocu Sample-command, using ICommandRestService
*/
@JavaCommand
@CommandGroup("LiteService")
public class RestServiceCommand {
@LiteService (1)
private ICommandRestService commandRestService;
/**
* @workflowDocu Store response in this map
*/
@Persistent(scope = FieldScope.WRITE_ONLY)
private Map<String, Object> resultMap;
@Run
public void run() {
final IEndpointClientService endpointClientService = this.commandRestService
.createEndpointClientServiceFor("myRequesterId"); (2)
[...]
}
}
1 | Use of @LiteService , to inject ICommandRestService . |
2 | Build an instance of IEndpointClientService , by using injected rest-service. |