This project provides a starting point for writing blotter integration adapters based on Caplin's Java DataSource API and Caplin's Java Blotter API. For a detailed guide on using the Java Blotter API, see Serving blotter data with the Java Blotter API.
This template is a Gradle project. To avoid compatibility issues between the version of Gradle required by the project and the version of Gradle installed on your system, always run the project's Gradle tasks using the Gradle Wrapper from the root of the project: ./gradlew task
Note: the Gradle Wrapper requires an Internet connection. For more information, see Executing a build with the Wrapper in the Gradle documentation.
Follow the instructions below to create a new adapter project based on the Blotter Adapter Template.
-
Clone, or download and extract the latest version of the Caplin Project Templates repository:
-
Clone:
$ git clone https://github.com/caplin/project-templates.git
-
Download:
$ wget http://github.com/caplin/project-templates/archive/master.zip $ unzip -qoa master.zip
-
-
Copy the template directory
blotter-template
and rename it to the name of your new project (for example, MyBlotterAdapter):$ cp -r ./blotter-template ~/src/MyBlotterAdapter
-
Edit the file
~/src/MyBlotterAdapter/settings.gradle
, and change the value of therootProject.name
variable to the name of your adapter project (MyBlotterAdapter). When you later export your project as an adapter blade, the project name will be used as the name for the blade. -
If you have a Caplin website account and Internet access to https://repository.caplin.com, follow the steps below to enable automatic downloading of this project's Caplin dependencies:
-
In your
~/.gradle/gradle.properties
file (create it if it does not exist), add the following lines, replacing<username>
and<password>
with your Caplin credentials:caplinNexusUser=<username> caplinNexusSecret=<password>
-
-
If you don't have a Caplin website account and Internet access to https://repository.caplin.com, follow the steps below to manage this project's Caplin dependencies manually:
-
In this project's
build.gradle
file, comment out themaven
block for https://repository.caplin.com:/*maven { credentials { username "$caplinNexusUser" password "$caplinNexusSecret" } url "https://repository.caplin.com" }*/
-
In this project's
build.gradle
file, uncomment theimplementation fileTree(...)
line in thedependencies
block:dependencies { implementation fileTree(dir: 'lib', include: '*.jar') ... }
-
Copy the following Caplin libraries to this project's
lib
directory:-
Java DataSource API 7.1.x:
datasource-version-jar-with-dependencies.jar
-
Java Blotter API 7.1.x:
BlotterJava-version.jar
-
-
Follow the instructions below to import your new adapter project into Eclipse or IntelliJ IDEA.
These instructions require the Buildship Gradle Integration plugin. To install the plugin, click Help > Eclipse Marketplace and search for Buildship
.
To import your project into Eclipse, follow the steps below:
-
In Eclipse, click File > Import. The Import dialog appears.
-
Click Existing Gradle Project. The Import Gradle Project dialog appears.
-
Under Project location, deselect Use default location.
-
In the Location field, select your adapter's project directory:
~/src/MyBlotterAdapter
-
Click Finish.
To import your project into IntelliJ IDEA, follow the steps below:
-
Click File > New > Project from existing sources
-
Select the project's Gradle build file:
~/src/MyBlotterAdapter/build.gradle
Integration adapters are designed to run within the context of a Deployment Framework (DFW), but they can be configured to run within an IDE during their development. This saves you time and allows you to take advantage of your IDE's debugging tools.
Regardless of whether your adapter is running in your IDE or in a DFW, it needs a working directory and the configuration details of the Liberator or Transformer it connects to. How these requirements are met within an IDE depends on whether the Liberator or Transformer is local or remote to your development machine.
This section describes how to connect an adapter in an IDE to a Liberator or Transformer in a Deployment Framework (DFW) on your local machine.
To provide Liberator or Transformer with your adapter's configuration, follow the steps below:
-
From the root of your project, run
./gradlew assemble -PconfigOnly
. This command packages your adapter's configuration (but not the binary) within a config-only blade underbuild/distributions/
. -
Copy the config-only blade to the
kits
directory of your local DFW. -
From the root of the local DFW, run the command
./dfw deploy
to deploy the config-only blade. -
From the root of the local DFW, run the command
./dfw versions
to confirm that the config blade has been deployed.
Note: if you change your adapter's configuration, you must repeat the steps above.
To provide your adapter with a working directory and the configuration of the Liberator or Transformer it connects to, follow the steps below:
-
In your IDE, create a run configuration for the main class of your project:
-
Set the run configuration's working directory to
dfw_location/active_blades/adapter_name/DataSource
, wheredfw_location
is the path to your local DFW, andadapter_name
is the name of your adapter.Note: on Microsoft Windows, which does not recognise Unix-style symbolic links, use the path
dfw_location\kits\adapter_name\adapter_name-version\DataSource
-
Create a run-configuration environment variable
CONFIG_BASE
with the valuedfw_location/global_config/
, wheredfw_location
is the path to your local DFW. This provides your adapter with the path to the configuration of the Liberator or Transformer it connects to.Note: the value of
CONFIG_BASE
must end with a trailing slash.
-
-
Run the adapter using the new run configuration.
This section describes how to connect an adapter in an IDE to a Liberator or Transformer in a Deployment Framework (DFW) on a remote host.
To provide Liberator or Transformer with your adapter's configuration, follow the steps below:
-
From the root of your project, run
./gradlew assemble -PconfigOnly
. This command packages your adapter's configuration (but not the binary) within a config-only blade underbuild/distributions/
. -
Copy the config-only blade to the
kits
directory of the remote DFW. -
From the root of the remote DFW, run the command
./dfw deploy
to deploy the config-only blade. -
From the root of the remote DFW, run the command
./dfw versions
to confirm that the config blade has been deployed.
To provide your adapter with a working directory and the configuration of the Liberator or Transformer it connects to, follow the steps below:
-
From the root of your project, run
./gradlew setupWorkingDirectory
, specifying one or more of the properties listed below.The
setupWorkingDirectory
task creates a minimal execution environment for your adapter underbuild/env
. The environment includes a working directory and the minimal configuration required to connect to the remote Liberator or Transformer.The
setupWorkingDirectory
build task accepts the following Gradle properties:-
-PthisLeg=value
: defaults to1
. Change this if you want to connect to the failover leg. -
-PliberatorHost=value
: defaults tolocalhost
. This must be changed to the host that Liberator runs on. -
-PliberatorDsPort=value
: defaults to15001
. Change this if the Liberator uses a different DataSource port number. -
-PtransformerHost=value
: defaults tolocalhost
. This must be changed to the host Transformer runs on. -
-PtransformerDsPort=value
: defaults to15002
. Change this if the Transformer uses a different DataSource port number.
-
-
Open the generated configuration file
build/env/blade_config/environment-ide.conf
and check that the configuration has been generated correctly. Make manual corrections to the file as required. -
In your IDE, create a run configuration with the working directory set to
build/env/DataSource
. -
Run the adapter using the new run configuration.
Note: if you change your adapter's configuration, you must repeat the steps above.
To pass options to the Java virtual machine (JVM) that runs your adapter in your IDE, add the JVM options to the adapter's run configuration.
To pass options to the Java virtual machine (JVM) that the Deployment Framework uses to run your adapter, export environment variable CAPLIN_BLADE_JAVA_OPTIONS. For example, to specify that the JVM has an initial heap size of 128MB and a maximum heap size of 256MB, add -Xms128m -Xmx256m
as options to the java
command, as shown below:
export CAPLIN_BLADE_JAVA_OPTIONS="-Xms128m -Xmx256m"
The JVM heap sizes in this example are illustrative only. Profile your adapter to determine the optimal values for your use cases.
Follow the steps below to build and deploy your adapter.
-
From the root of your project, run
./gradlew assemble
. This command packages your adapter in an adapter blade underbuild/distributions/
. -
Deploy the adapter blade to each Deployment Framework in your deployment infrastructure. For instructions on how to deploy an adapter blade to a Deployment Framework, see Deploy a custom blade.
To report an issue with the template, please contact Caplin Support or raise an issue on GitHub.