Skip Navigation

Call Java service from TypeScript

Web Modules can call Java services defined inside the Red App and registered as Flow Extension Point callbacks.

Defining Callback Service

First, define a simple interface with some method with both return type and parameter with FlowExtPointCommand.

FlowExtPointCommand execute(FlowExtPointCommand extPointCommand);

Then, create interface implementation as shown below:

@Override
public FlowExtPointCommand execute(FlowExtPointCommand extPointCommand)
{
    // Provide logic
    // ...

    return extPointCommand;
}

Registration of the Service in Flow Extension Point Registry

Register service by using extension point com.sabre.edge.dynamo.flow.flowextpoint.registry in plugin.xml

Example:

<extension point="com.sabre.edge.dynamo.flow.flowextpoint.registry">
    <flowExtensionPoint
        callbackService="com.sabre.example.ISampleService:execute"
        extensionPointId="execute"
        flowId="dynamo.api.executor">
    </flowExtensionPoint>
</extension>

In above example: callbackService attribute defines interfaceName:methodName to register as callback.

Calling Service from Web module

To call Java Service use the send() method from ICommandMessageService.

The command to send must be in the following pattern: "NGV://REDAPP/SERVICE/<callback service - interfaceName:methodName>"

Example:

getService(ICommandMessageService).send('NGV://REDAPP/SERVICE/com.sabre.example.ISampleService:execute');
Note
See com.sabre.redapp.example3.desktop.serviceregistry and com.sabre.redapp.example3.desktop.hint samples for implementation.