Extending an Adapter

Following on from the previous tutorial — Creating a RET Adapter — we will now extend the Calendar Adapter.

Convenient extension points exist throughout the adapter code. Extension points enable you to extend the functionality of an adapter, tailoring it to your needs.

Download the presentations for this course.


In this tutorial, you will achieve the following objectives:

  • Modify tenor dates by implementing new functionality at an extension point.

  • Test the new extension by making and viewing subject requests in the Liberator Explorer

Extension points are adapter features which can be overridden by custom code that is loaded via a configuration class. Each extension point is defined by an interface. This interface is used to determine the behaviour of that particular feature.

Configuring an extension point

All adapter classes in the RET Adapter Toolkit are configured in the same way, where extensions are added via methods on an interface. In the case of the Calendar Adapter, a builder named CalendarConfigurationBuilder is created by calling the newConfigurationBuilder() method on CalendarConfiguration. Extensions are then called via this method. Once all extensions have been set up, we call build() on the builder to create a CalendarConfiguration object.

All extension points have a default implementation. So the class CalendarAdapterExample would run according to its default behaviour - with the following as its main method:

new CalendarAdapter().start();

Take a look at the CalendarAdapterExample class in your Calendar Adapter workspace. This class creates a CalendarConfigurationBuilder and also adds two custom implementations to your configuration. The CalendarConfiguration should be passed as an argument in to the CalendarAdapter constructor when any defaults have been overridden. When start() is called the adapter will be initialised, and the extensions as well as any other defaults will be created:

CalendarConfiguration calendarConfiguration = CalendarConfiguration.newConfigurationBuilder()
    .setUserManager(new FileBasedUserManager())
    .setDataTransformer(new ExampleDataTransformer())

CalendarAdapter adapter = new CalendarAdapter(calendarConfiguration);

The source code for the default extensions can be found in <RETAdapterToolikt>/src/, and serves as a useful starting-point for development.

Extending the Calendar

The Refinitiv Electronic Trading system responds to requests for settlement and tenor dates with a set of ISO 8601 formatted dates.

You can change the format of the dates by implementing the CalendarDataTransformer interface and passing an instance of your class to the CalendarConfigurationBuilder.setDataTransformer() method.

The example Calendar includes ExampleDataTransformer, and implementation of CalendarDataTransformer. In this section we will customise ExampleDataTransformer to modify the format of tenor dates.

Follow the steps below:

  1. Begin by opening the file src/main/java/com/caplin/example/ret/ExampleDataTransformer.java

  2. Next, you will transform the date string values in the Tenor String map — tenorDates — using a method that can be used to transform the String map. Instead of an ISO 8601 date format, you will provide dates in the format year/day-of-year.

    Do this by updating the onTenorDatesReceived() method with the following code:

    public Map<Tenor, String> onTenorDatesReceived(String currencyPair, Map<Tenor, String> tenorDates) {
        for (Map.Entry<Tenor, String> date : tenorDates.entrySet()) {
            try {
                Date retDate = ISO_FORMAT.parse(date.getValue());
            } catch (ParseException ignored) {}
        return tenorDates;

    Save the file when you’re done.

  3. Open a command-line interface and rebuild the adapter by executing the following command:

    java -jar <cis-blade-toolkit> build CalendarAdapter
  4. Now run the adapter using this command:

    java -jar <cis-blade-toolkit> run CalendarAdapter -m com.caplin.example.ret.CalendarAdapterExample

    The adapter is now ready to receive a request.

  5. Finally, test the changes you just made using the Liberator Explorer. Navigate to http://localhost:18080/, click Diagnostics, then click the liberatorexplorer URL link.

    If prompted for a username/password, use admin/admin.
  6. In the field labelled 'Record', type /CALENDAR/TENORDATES/GBPUSD and click Go. This will make a request to the Calendar Adapter to send back Tenor Dates for GBPUSD.

    You can view the changes to fields in the Tenor column.

Making and Receiving Requests

A simple way to test an adapter is to make a request via the Liberator Explorer as you did earlier with Tenor formats. However, a permissions level might be required when making such requests. In this part we will look at making changes to user permissions by assigning groups.

Follow the steps below:

  1. Open the Liberator explorer and log in as an Admin. Do this by navigating to http://localhost:18080/, clicking on Diagnostics, and clicking on the liberatorexplorer URL link.

    If you are prompted for a username/password, use admin/admin.
  2. Next, open the file logins.xml in the Permissioning Adapter and add the group Global to the admin users set of groups:

        <user ssoName="admin" password="admin" groups="Global LiberatorStatus" />
  3. Restart the Permissioning Adapter and Liberator. Do this by opening a Bash terminal on your machine and navigating to your Deployment Framework’s topmost directory. Then execute the following command:

    ./dfw start

    More information on this process is available in this guide: Start and stop components and blades

  4. Finally, navigate back to the Liberator Explorer (Step 1). In the Record field, enter the subject /CALENDAR/TENORDATES/GBPUSD. You should then receive a response with your custom formatted data (from previous instructions) in the Tenor field.

The object mapping and data service for the subject /CALENDAR/TENORDATES are configured in the file <workspace>/CalendarAdapter/Blade/overrides/CalendarAdapter/Liberator/etc/rttpd.conf.

Abridged examples/CalendarAdapter/Blade/overrides/CalendarAdapter/Liberator/etc/rttpd.conf
#  Calendar configuration
object-map            "/CALENDAR/TENORDATES/%1" "/CALENDAR/TENORDATES/%1/%u"

  service-name        calendar-data
  include-pattern     "^/CALENDAR/SETTLEMENTDATE"
  include-pattern     "^/CALENDAR/TENORDATES"
  discard-timeout     300
  request-timeout     0

      label             CalendarAdapterService