Skip to main content

Java Back-end Services with Callback Flow Extension Points

Flow extension points provide ability for Red Apps to provide back-end service callbacks for flows defined in Sabre Red 360.

When a command or flows invoked from UI, registered services will be executed by the flow executor.

Below you can see the flow diagram that explains the Flow Extension points.

image85

The following steps are about registration and usage of the Flow Extension point callbacks.

  1. Defining Callback Service

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

FlowExtPointCommand execute(FlowExtPointCommand extPointCommand);

        Then, implement interface as shown below:

@Override
public FlowExtPointCommand execute(FlowExtPointCommand extPointCommand)
{
    // Read request
    extPointCommand.getRequestInput().getAny().get(0);

    // Prepare response structure
    FlowExtPointData dt = new FlowExtPointData();
    dt.setStructure(new SampleFlightStructure());
    extPointCommand.getResponse().add(dt);

    return extPointCommand;
}

In an example above, request is extracted by using extPointCommand.getRequest() and response is populated by using extPointCommand.getResponse().add();

To serialize SampleFlightStructure class to JSON, refer to topic Data Types and Serialization.

Below you can find the attributes present in FlowExtensionPointCommand

        pcc - agent PCC

        agentId - agent EPR

      aaaPcc - agent AAA PCC

      request - Requested command structure

      extensionPointName - extension point name

      response - list of FlowExtPointData objects. Refer to above example for usage

      result - FlowExtPointResult. Contains Result of flow execution. Refer to Java documentation for more details.

  1. 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

        Ex:

<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.  

  1. Calling Service from Web module

static SERVICE_NAME: string = 'NGV://REDAPP/SERVICE/com.sabre.example.ISampleService:execute';

cf(SERVICE_NAME)
    .setLocalPreference('silent', true)
    .send()

In the above example, cf is using NGV://REDAPP/SERVICE/<callback service - interfaceName:methodName>

To add a request to cf use addRequestDataObject and to retrieve data from cf used retrieveData methods respectively.

return cf(SERVICE_NAME)
    .addRequestDataObject(new SampleRq(payload))
    .setLocalPreference('silent', true)
    .retrieveData(SampleData)