PAK Core – ILiteServiceProvider
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 ILiteServiceProvider
interface.
1. Basics
ILiteServiceProvider
is extending the ILiteService
interface, which makes it a LiteService. This Service can therefore be injected
by using the @LiteService
annotation and works only in Java Commands. It’s an interface for fetching LiteServices.
2. Usage
There are two methods within the ILiteServiceProvider
interface:
-
getCommandRestService()
, returns an instance ofICommandRestService
, if it is available within the Context. If not, null is returned. -
find(Class<T extends ILiteService> clazz)
, finds other custom registered Services, extendingILiteService
within the Context. Returns null, if the Service does
not exist.
3. Register
Don’t forget to register the implementing class of ILiteServiceProvider
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 ServiceProviderCommand {
@LiteService (1)
ILiteServiceProvider liteServiceProvider;
/**
* @workflowDocu Store response in this map
*/
@Persistent(scope = FieldScope.WRITE_ONLY)
Map<String, Object> resultMap;
@Run
public void run() {
final IEndpointClientService endpointClientService = this.liteServiceProvider.getCommandRestService()
.createEndpointClientServiceFor("myRequesterId"); (2)
[...]
}
}
1 | Use of @LiteService , to inject ILiteServiceProvider . |
2 | Build an instance of IEndpointClientService , by getting an instance of ICommandRestService from ILiteServiceProvider ,using the method getCommandRestService() . |