instruction
stringlengths 5
72
| input
stringclasses 1
value | output
stringlengths 22
8.46k
|
---|---|---|
Calypso Development Environment | Section 1. Calypso Development Environment
Calypso components are contained in various jars that are scanned for Spring annotation to start the
servers. Therefore, client custom components must become part of jar files when starting the server.
To facilitate this, Calypso provides the Custom-Extensions directory located within the installation
directory.
Custom-Extensions contains the open-source tools used by Calypso to create, package and deploy the
Calypso binaries, as well as to maintain a changes audit trail.
Calypso requires all modifications to the platform to be made via the Custom-Extensions project.
|
|
Prerequisites | 1.1 Prerequisites
• Please refer to the Hardware and Software Recommendation Guide for proper JAVA.
• Eclipse (eclipse.org). Calypso uses the Neon 2 version of Eclipse. All examples and procedures
in this guide assume that your development environment also uses Eclipse Neon 2.
The procedures and example in this document were created with the Neon 2 version of Eclipse.
Setup your Calypso development environment by following the steps below. A working knowledge of
Eclipse IDE is required.
|
|
Naming Convention for Custom Code | 1.2 Naming Convention for Custom Code
Using a naming convention for custom code prevents clashes in name space and makes the support
process smoother by making it clear in stack traces, thread dumps, and when the customization is
visible to the user (i.e. Pricer name), that we are dealing with custom code as opposed to core code.
Below are the general guidelines Calypso requiring clients to follow as a best practice. Please note that
as the platform evolves some conventions may be more stringently enforced in future versions of
Calypso.
• Custom classes should be prefixed with a unique prefix preferably <company or company
abbreviation><classname> and in cases where the java pattern does not allow prefixing then a
suffix. (This should be applied to user interface components such as pricer names). For
example: myCompanySwapPricer.java.
• All classes should be implemented in packages starting with either calypsox or a client name (if
they have implemented CustomGetPackages). Clients should not use the com.calypso
package except in specific cases where Calypso’s extension points require it.
• All custom classes and customizations to configuration files must be placed in custom-
extensions. This ensures that all custom code is in one location and can be easily separated
from the rest of the code.
To ensure that the calypso package is scanned before all other packages, you can set environment
property ELEVATE_CALYPSOX_PACKAGE_POSITION = true. It is false by default.
|
|
Custom-Extensions Overview | 1.3 Custom-Extensions Overview
The Custom-Extensions directory (<calypso home>/custom-extensions) is intended to capture all
local modifications made to an installation of Calypso. Such modifications may range from a simple
configuration file change, the addition of new Java classes to extend platform functionality, or the
deployment of third-party libraries required by Calypso or new Java classes.
Also included are tools to assist in developing, compiling, packaging, and deploying components into
the Calypso binaries. The use of the Using Custom-Extensions directory helps ensure that any
modifications made to core Calypso are clearly separated to simplify the change management process
for clients. The provided tools ensure that a proper audit trail is made available for each change and
that potential incompatibilities are made visible during development rather than in production.
Calypso requires all modifications to the platform to be made via the Custom-Extensions project.
Build scripts contained in the Custom-Extensions directory provide support for Eclipse by preparing a
series of projects (organized into subdirectories) with the required classpaths for compiling extensions.
These projects can also simply contain modified configuration files or new classes and libraries.
The projects (and directories) are separated by the Calypso deployment artifacts including the
dataserver, engineserver, client and common shared library. This separation ensures that artifacts are
not distributed to components unless required.
Using Custom-Extensions Workspace provides a quick overview of using custom-extensions. Refer to
Custom Extensions by Example and to Custom Extensions Audit for detailed usage information.
|
|
Change Management | 1.4 Change Management
The default Calypso installation provides basic, disk based versioning which allows a client to roll back
any change performed by using the steps described above. This solution creates backup copies
(located in <calypso home>/patch-history) of all the binaries before any modification made by the
deployment tools. The tools also provide simple commands which allow automated rollback to a
specific backup by date, and a detailed audit log of the files being modified inside each binary pushed
to production.
Calypso recommends that clients manage any custom code, installation scripts and other build &
configuration files in some kind of Source Control Management (SCM) solution like SVN, Git, Hg, etc.
This helps ensure that there is a proper audit trail and roll back capability of changes made to the
Calypso build environment. There is no need to store Calypso binaries, such as war/jar/zip/dll/so files,
in a version control system. Calypso expects the client to use market tools & conventions along with
their own standard development & Build policies to maintain the Calypso environment in good stead
whilst meeting license requirements. Calypso is always willing to advise if needed.
With a proper SCM in place, clients may also leverage a Continuous Integration (CI) solution in order
to ensure change management is tracked correctly. The CI solution would take the responsibility of
building the final binaries for deployment into UAT and eventually promoted to Production are built by
a standard CI system.
|
|
Directory Layout | 1.5 Directory Layout
The custom-extensions directory contains the following sub-directories and files.
| bld
| bld.bat
| build.gradle
| README.txt
|
+---custom-projects
| | bld
| | bld.bat
| | build.gradle
| | gradle.properties
| | settings.gradle
| |
| +---custom-client
| | | build.gradle
| | |
| | \---src
| | +---calypso
| | | +---jars
| | | \---resources
| | \---main
| | +---java
| | \---resources
| +---custom-dataserver-services
| | | build.gradle
| | |
| | \---src
| | +---calypso
| | | +---jars
| | | \---resources
| | \---main
| | +---java
| | \---resources
| +---custom-engine
| | | build.gradle
| | |
| | \---src
| | +---calypso
| | | +---jars
| | | \---resources
| | \---main
| | +---java
| | \---resources
| +---custom-shared-lib
| | build.gradle
| |
| \---src
| +---calypso
| | +---jars
| | \---resources
| \---main
| +---java
| \---resources
+---dataserver
+---engineserver
+---lib
| calypso-extension-plugins.jar
|
\---samples
custom-dataserver-service.zip
edit-resources.zip
include-thirdparty-libraries.zip
custom-engine.zip
custom-webstart-jnlp.zip
deploy-customized-alerts.zip
Where:
• bld, bld.bat, build.gradle — Provides the commands to compile and patch Calypso
deployments with your custom code.
• custom-projects — Contains sub-directories organized by deployments.
• dataserver, engineserver — Contains old projects that can be deployed into Eclipse.
• samples — Contains zipped examples for reference (explained in later sections of this
document).
• lib/calypso-extension-plugins.jar - Contains the tasks which are used to perform build
and deploy operations for the custom-extensions.
For checking the tasks available as part of the custom-extensions, the following command can be used
$CALYPSO_HOME/custom-extensions > ../tools/gradle/bin/gradle tasks
Sample output snippet:
To use the workspace, you will add your code to the relevant sub-directories in <calypso
home>/custom-extensions/custom-projects:
• custom-shared-lib — Common to all servers, clients
• custom-client — Only for client (example, windows)
• custom-dataserver-services — Stateless session beans for data server services
• custom-engine — Custom engine code
Calypso recommends that after installation, you commit the installation directory (i.e., <calypso
home>) to a source code control system. Developers can then checkout the installation directory with
the workspace to develop extensions.
|
|
Using the Basic Custom-Extensions Workspace | 1.6 Using the Basic Custom-Extensions Workspace
This section provides a brief overview of using custom-extensions. Refer to Custom Extensions by
Example and Custom Extensions Audit for detailed information.
To use the workspace, add your code to the relevant sub-directories in <calypso home>/custom-
extensions/custom-projects:
To run and debug the Data Server and Engine Server, two Eclipse projects are provided ( dataserver
and engineserver) that needs to be loaded into the Eclipse.
Before that, first run deployLocal as
deployLocal.sh -Penv=env_name -PportOffset=port_offset
Where:
env = Calypso environment property file. In this example, a environment property file called
“calypsouser.properties.v17” must be present in <user home>/Calypso.
portOffset = A base port offset to add to all port offsets. 0 is used when not speficied. In this
example, the Data Server will use a port offset of 20 + 0 + 8080 = 8100, the Engine Server will use a
port offset of 60 + 0 + 8080 = 8140, the Risk Server will use a port offset of 80 + 0 + 8080 = 8160, etc.
Next, generate the Eclipse setup from the build scripts included in the custom-extensions directory.
1. cd <calypso home>/custom-extensions
2. bld eclipse
3. Import the projects into Eclipse.
dataserver
custom-dataserver-services
custom-shared-lib
engineserver
custom-engine
custom-client
4. Start authenticationServer and eventserver from <CALYPSO_HOME>/deploy-
local/xxxxxxxx_17/
5. Create “Run Configurations” for dataserver with details as follows
Project: dataserver
Main class: “com.calypso.apps.startup.StartCalypsoServer”
Program argument:
-env xxxxxxxx_17
--spring.config.location=classpath:/config/dataserver.properties
Similarly for the Engine Server, the arguments will be as follows:
Project: engineserver
Main: “com.calypso.apps.startup.StartCalypsoServer”
Program argument:
-env xxxxxxxx_17
--spring.config.location=classpath:/config/engineserver.
Where:
env = Must match the environment previously used when creating the servers using
deployLocal.sh.
spring.config.location = path to the configuration file of server
6. Develop/run with the extensions.
Finally, to package and update the Calypso artifacts with the extensions, use the following commands
to build a Calypso upgrade package and apply it to the Calypso artifacts using the patch script:
1. cd <calypso home>/custom-extensions
2. bld deploy
|
|
Custom Extensions by Example | Section 2. Custom Extensions by Example
The sections below describe the features of the custom extensions and tools provided with detailed
examples. Each example is provided as a zip file inside <calypso home>/custom-
extensions/samples.
In the examples below, <calypso home> represents the Calypso installation directory.
Please note that the samples provided are only examples and may modify existing custom-extensions.
It is expected that you will use these examples only in a fresh installation or clean development area.
|
|
Adding Third-Party Libraries | 2.1 Adding Third-Party Libraries
Calypso, as well as custom extensions developed by clients, may require third-party libraries to
function. These libraries may be as simple as a Market Data Provider’s custom libraries to technology
libraries, such as the MQ Series connectivity libraries.
Adding libraries involves the following:
• Copying the libraries (jars) into the appropriate jars directory of custom-extensions
Alternatively, the libraries can be specified using their Maven group/artifact/version.
− The public maven central repository is used by default.
− A different maven repository can be specified.
• Patching the libraries using the 'bld deploy' command.
The following examples illustrate the procedures to:
• Deploy a library to all deployments
• Deploy a library used only on the client side
• Upgrade a library
Note: Libraries provided by Calypso must not be upgraded. The examples provided here
illustrate the audit trail and checks performed when patching.
Refer to Sample Modifications — Libraries for a fully working sample of these changes.
|
|
Adding a Common Library | 2.1.1 Adding a Common Library
You may add a common library from either the local file system or via a repository. The notation used
in this example will add a library and any transitive dependencies.
To add a new library from the local file system, place the jar in <calypso home>/custom-
extensions/custom-projects/custom-shared-lib/src/calypso/jars.
Libraries added to this directory are added to all jars within a deployment.
Alternatively, you can add the library from a Maven repository. By default, the public Maven central
repository will be used. Refer to Adding a custom repository for the procedure to use an alternate
Maven repository.
The following line added to custom-extensions/custom-projects/custom-shared-
lib/build.gradle adds a library from a repository using Group:ArtifactId:Version notation. This
example would make google-collections available to all jars in the project:
dependencies {
includeInDistribution "com.google.code.google-collections:google-collect:snapshot-
20080321"
}
Alternatively, notation in this format would also add the library:
dependencies {
includeInDistribution group: "com.google.code.google-collections", name: "google-
collect", version: "snapshot-20080321"
}
|
|
Upgrading an Existing Common Library | 2.1.2 Upgrading an Existing Common Library
To upgrade a common library, edit the build script to specify the library. Deploying the custom project
removes the old version from the server and replaces it with the new version. Furthermore, the audit
will detail any class file change. Third party libraries provided by Calypso should not be upgraded. For
example, to update google-collect library we added in the previous step, we’ll just update the version
in the entry done in custom-extensions/custom-projects/custom-shared-lib/build.gradle:
dependencies {
includeInDistribution group: "com.google.code.google-collections", name: "google-
collect", version: "snapshot-20080530"
}
|
|
Adding a Deployment-Specific Library | 2.1.3 Adding a Deployment-Specific Library
Adding a deployment-specific library follows a process similar to the previous section.
This example adds the library to a deployment-specific project (custom-client) instead of the custom-
shared-lib.
To add the jgoodies library (a Java Swing library) to a client deployment, place it in: custom-
extensions/custom-projects/custom-client/build.gradle.
dependencies {
includeInDistribution "com.jgoodies:jgoodies-common:1.7.0"
}
|
|
Adding a Custom Repository | 2.1.4 Adding a Custom Repository
By default, the public maven central repository has been used as the repository which loads all new
libraries. To specify an additional repository, edit the gradle.properties file in <calypso
home>/custom-extensions/custom-projects and specify the URL of the repository (the property
repoUrl). If credentials are required to connect to the repository, specify the properties
repoUsername and repoPassword. The following gradle.properties lines provide an example of
adding a custom repository:
repoUrl=http://maven.example.com/repository
repoUsername=username
repoPassword=mypassword
|
|
Removing Unwanted Libraries | 2.1.5 Removing Unwanted Libraries
To remove an unwanted jar from a WAR file, you need to create a file named "custom-project-
distribution.cpc" in <calypso home>/custom-extensions.
Add the jar entries to be removed to the file as in the example below:
<?xml version="1.0" encoding="UTF-8"?>
<commands>
<!--<rm path="engineserver/WEB-INF/lib/XXX.jar"/> -->
</commands>
|
|
Deploying Library Changes | 2.1.6 Deploying Library Changes
With the newly updated template and files in place, the deployment tools can push the configuration
files into the deployment artifacts and ensure the proper audit trails are created.
Go to <calypso home>/custom-extensions:
$ bld deploy
bld deploy automatically adds the files to the correct location inside each deployment artifact.
|
|
Rolling Back Changes | 2.1.7 Rolling Back Changes
After running bld deploy, the installation contains artifacts from the custom-extensions. To remove
these artifacts, use patch.bat/.sh to roll back the installation.
|
|
Example Audit Trail — Library Changes | 2.1.8 Example Audit Trail — Library Changes
When the deployment is complete, the sample audit recorded for this change in any of the
deployment artifacts. The audit file will contain similar entries:
<patch date="Mon Apr 14 22:02:00 PDT 2014" file="custom-project-distribution-1.0.0-SNAPSHOT-
rel.zip" md5="c8e14ebd1029689c5c77f9b3bf1dc3e5" force="false" patchVersion="1.0.5">
<modification type="add" file="google-collect-snapshot-20080530.jar"
md5="5ed1ebdf132806f6b1cc0909ca3286fb" modifiedSinceLastPatch="true" source="patcher"/>
<modification type="upgrade" original="log4j-1.2.15.jar" updated="log4j-1.2.17.jar"
md5="04a41f0a068986f0f73485cf507c0f40" modifiedSinceLastPatch="true" source="patcher">
<file modificationType="modified"
className="org/apache/log4j/helpers/PatternParser$MDCPatternConverter.class"
previousMD5="99d1d86aa5e42867ddae8c8a2342d5bf" newMD5="7acfc64fa8fd9b1762470c448a7d459f"
source="patcher"/>
<file modificationType="modified"
className="org/apache/log4j/helpers/NullEnumeration.class"
previousMD5="a5f9eb2d3a7774c36dae6b7a2e82d6b3" newMD5="3343b806cb5c89849b14a5b94adc3bc0"
source="patcher"/>
<file modificationType="modified"
className="org/apache/log4j/helpers/BoundedFIFO.class"
previousMD5="2e21ac90aec938ef691fbe314a25de79" newMD5="78f4747b8ae27f7da059dac2bd22690b"
source="patcher"/>
<file modificationType="modified"
className="org/apache/log4j/helpers/PatternConverter.class"
previousMD5="82331cf335095d23da95bfc2900ddc28" newMD5="8e8694fb90cd9e000dce7d0734807c76"
source="patcher"/>
<file modificationType="modified"
className="org/apache/log4j/helpers/PatternParser$LiteralPatternConverter.class"
previousMD5="83de39bba166646fe0d5914573aaf637" newMD5="9a77cbd1400edf35cf077ce06d619fed"
source="patcher"/>
…
<file modificationType="added" className="org/apache/log4j/pattern/PatternParser.class"
md5="a122165f82ac24bcd6995ef29b9c46b6" source="patcher"/>
<file modificationType="added"
className="org/apache/log4j/pattern/NDCPatternConverter.class"
md5="a0cf528a2a609d2ef5a632a11c5c6940" source="patcher"/>
<file modificationType="added"
className="org/apache/log4j/pattern/RelativeTimePatternConverter.class"
md5="d5ccc7458c3fb566bdc06027efca8662" source="patcher"/>
<file modificationType="added"
className="org/apache/log4j/pattern/BridgePatternParser.class"
md5="fc57af32cedfc93b27af61466b7e12fd" source="patcher"/>
<file modificationType="added"
className="org/apache/log4j/pattern/FileDatePatternConverter.class"
md5="87e55b9413394b2e621ca5f9ebfb0836" source="patcher"/>
<file modificationType="added"
className="org/apache/log4j/pattern/NameAbbreviator$PatternAbbreviatorFragment.class"
md5="33707c5e898ae14dfea28998397cfde9" source="patcher"/>
<file modificationType="added"
className="org/apache/log4j/pattern/ThreadPatternConverter.class"
md5="0753495a2c4367be59823fc787e91ad4" source="patcher"/>
<file modificationType="added"
className="org/apache/log4j/pattern/NamePatternConverter.class"
md5="07a16699a4141ae8b915c76bee92a83a" source="patcher"/>
</modification>
</patch>
For the above changes, the local client audit file will contain an additional change, and will show an
audit log similar to the following:
<patch date="Mon Apr 14 22:03:25 PDT 2014" file="custom-project-distribution-1.0.0-SNAPSHOT-
rel.zip" md5="ba492490beb405debc70572f4eda1bf2" force="false" patchVersion="1.0.5">
<modification type="add" file="google-collect-snapshot-20080530.jar"
md5="5ed1ebdf132806f6b1cc0909ca3286fb" modifiedSinceLastPatch="true" source="patcher"/>
<modification type="upgrade" original="log4j-1.2.15.jar" updated="log4j-1.2.17.jar"
md5="04a41f0a068986f0f73485cf507c0f40" modifiedSinceLastPatch="true" source="patcher">
<file modificationType="modified"
className="org/apache/log4j/helpers/PatternParser$MDCPatternConverter.class"
previousMD5="99d1d86aa5e42867ddae8c8a2342d5bf" newMD5="7acfc64fa8fd9b1762470c448a7d459f"
source="patcher"/>
<file modificationType="modified"
className="org/apache/log4j/helpers/NullEnumeration.class"
previousMD5="a5f9eb2d3a7774c36dae6b7a2e82d6b3" newMD5="3343b806cb5c89849b14a5b94adc3bc0"
source="patcher"/>
<file modificationType="modified"
className="org/apache/log4j/helpers/BoundedFIFO.class"
previousMD5="2e21ac90aec938ef691fbe314a25de79" newMD5="78f4747b8ae27f7da059dac2bd22690b"
source="patcher"/>
<file modificationType="modified"
className="org/apache/log4j/helpers/PatternConverter.class"
previousMD5="82331cf335095d23da95bfc2900ddc28" newMD5="8e8694fb90cd9e000dce7d0734807c76"
source="patcher"/>
<file modificationType="modified"
className="org/apache/log4j/helpers/PatternParser$LiteralPatternConverter.class"
previousMD5="83de39bba166646fe0d5914573aaf637" newMD5="9a77cbd1400edf35cf077ce06d619fed"
source="patcher"/>
…
<file modificationType="added" className="org/apache/log4j/pattern/PatternParser.class"
md5="a122165f82ac24bcd6995ef29b9c46b6" source="patcher"/>
<file modificationType="added"
className="org/apache/log4j/pattern/NDCPatternConverter.class"
md5="a0cf528a2a609d2ef5a632a11c5c6940" source="patcher"/>
<file modificationType="added"
className="org/apache/log4j/pattern/RelativeTimePatternConverter.class"
md5="d5ccc7458c3fb566bdc06027efca8662" source="patcher"/>
<file modificationType="added"
className="org/apache/log4j/pattern/BridgePatternParser.class"
md5="fc57af32cedfc93b27af61466b7e12fd" source="patcher"/>
<file modificationType="added"
className="org/apache/log4j/pattern/FileDatePatternConverter.class"
md5="87e55b9413394b2e621ca5f9ebfb0836" source="patcher"/>
<file modificationType="added"
className="org/apache/log4j/pattern/NameAbbreviator$PatternAbbreviatorFragment.class"
md5="33707c5e898ae14dfea28998397cfde9" source="patcher"/>
<file modificationType="added"
className="org/apache/log4j/pattern/ThreadPatternConverter.class"
md5="0753495a2c4367be59823fc787e91ad4" source="patcher"/>
<file modificationType="added"
className="org/apache/log4j/pattern/NamePatternConverter.class"
md5="07a16699a4141ae8b915c76bee92a83a" source="patcher"/>
</modification>
<modification type="add" file="jgoodies-common-1.7.0.jar"
md5="4c224617d613557a823e31f39ebde0b1" modifiedSinceLastPatch="true" source="patcher"/>
</patch>
As seen in the above examples, the audit trail will track all class changes within a library if it is already
existing in the installation.
|
|
Sample Modifications — Libraries | 2.1.9 Sample Modifications — Libraries
<calypso home>/custom-extensions/samples/include-thirdparty-libraries.zip
contains the samples for this section. Extract sample files into the root of custom-extensions. All
previously mentioned modifications are present in this project. The main changes are:
• Added the following lines in <calypso home>/custom-extensions/custom-
projects/custom-shared-lib/build.gradle to include a dependency on google
collections and an updated log4j version:
dependencies {
provided project(":engineserver")
provided fileTree(dir:
project(":engineserver").projectDir.toString()+"/build/war/WEB-INF/lib", include:
"*.jar")
// To include a new library from the repository, the following notation can be
used
includeInDistribution "com.google.code.google-collections:google-collect:snapshot-
20080530"
// The following notation can also be used. Please note that a version of log4j
is already packaged with
// calypso, so this will upgrade the package. This can potentially cause
instability in the application.
includeInDistribution group: "log4j", name: "log4j", version: "1.2.17"
}
• Added the following lines in <calypso home>/custom-extensions/custom-
projects/custom-client/build.gradle to include a dependency on jgoodies:
dependencies {
compile project(':custom-shared-lib')
compile fileTree(dir: '../../../client/lib', include: "*.jar")
compile files(project.file('../../../client/resources').path)
// In order to include a library into a specific deployment in the calypso
installation,
// similar code can be placed into its respective project
includeInDistribution "com.jgoodies:jgoodies-common:1.7.0"
}
|
|
Extending Calypso | 2.2 Extending Calypso
The Calypso application provides a number of extension points. These extensions require code to be
written, compiled and patched into the deployments. The following sections illustrate the steps to add
an extension by building a simple service to print a log message in the dataserver. A custom client will
also be created to invoke the service.
|
|
Unpacking the Sample | 2.2.1 Unpacking the Sample
<calypso home>/custom-extensions/samples/custom-dataserver-service.zip contains
the samples for this section. Extract the files into the root of the custom-extensions. After the sample
has been unzipped, there will be several java files available which have been documented below.
|
|
Remote Interface | 2.2.2 Remote Interface
Because all deployments require the remote interface for invokation, the interface is in the custom-
shared-lib. The code for this example can be found in:
<calypso home>/custom-extensions/custom-projects/custom-shared-
lib/src/main/java/calypsox/tk/service/RemoteSampleService.java.
|
|
Annotated Bean | 2.2.3 Annotated Bean
Following the JavaEE specification, an annotated Spring Bean class was created to implement the
remote service. The example can be found in <calypso home>/custom-extensions/custom-
projects/custom-dataserver-
services/src/main/java/calypsox/tk/service/SampleServiceBean.java. Note that
because the implementation should only be made available in the dataserver the code was added to
custom-dataserver-services.
|
|
Spring Configurations | 2.2.4 Spring Configurations
A class is created with @Configuration annotation for Spring boot configuration to export the services.
The example can be found in <calypso home>/custom-extensions/custom-dataserver-
services/src/main/java/com/calypsox/springboot/CalypsoSampleServiceConfig.java
|
|
Sample Client | 2.2.5 Sample Client
The sample client connects to the dataserver, looks up the remote service and invokes it.
<calypso home>/custom-extensions/custom-projects/custom-
client/src/main/java/calypsox/apps/startup/LoggingClient.java contains the sample code for
this section.
After deploying the project, run the sample client using the following command from <calypso home>:
$ client/bin/calypso calypsox.apps.startup.LoggingClient
After running this application, the Dataserver log will contain the following line:
My Message
|
|
Deploy | 2.2.6 Deploy
With the newly updated template and files in place, use the deployment tools to push the
configuration files into the deployment artifacts and ensure that the proper audit trails are created. Go
to <calypso home>/custom-extensions:
$ bld deploy
Once this command is executed, the files will be automatically added to the correct location inside
each deployment artifact.
|
|
Rolling Back Changes | 2.2.7 Rolling Back Changes
After running bld deploy, the installation contains artifacts from the custom-extensions. To remove
these artifacts, use patch.bat/.sh to roll back the installation.
|
|
Example Audit Trail | 2.2.8 Example Audit Trail
Once the deployment is complete, the sample audit recorded for this change is visible in the
deployment artifacts. For most audit files, the following change will be recorded:
<patch date="Mon Apr 14 23:37:18 PDT 2014" file="custom-project-distribution-1.0.0-SNAPSHOT-
rel.zip" md5="7afd49faf0dcb9688e8c9c8dba4b29c9" force="false" patchVersion="1.0.5">
<modification type="add" file="custom-shared-lib-1.0.0-SNAPSHOT.jar"
md5="5cddf00fd9858025cf423f22cc10c78a" modifiedSinceLastPatch="true" source="patcher"/>
</patch>
The Local Client deployment audit file will contain the similar entries:
<patch date="Mon Apr 14 23:38:25 PDT 2014" file="custom-project-distribution-1.0.0-SNAPSHOT-
rel.zip" md5="7afd49faf0dcb9688e8c9c8dba4b29c9" force="false" patchVersion="1.0.5">
<modification type="add" file="custom-shared-lib-1.0.0-SNAPSHOT.jar"
md5="5cddf00fd9858025cf423f22cc10c78a" modifiedSinceLastPatch="true" source="patcher"/>
<modification type="add" file="custom-client-1.0.0-SNAPSHOT.jar"
md5="f3f264194a18d126bccf5bafb4f86399" modifiedSinceLastPatch="true" source="patcher"/>
</patch>
Finally, the dataserver.war audit file will show an audit log of the following:
<patch date="Mon Apr 14 23:37:48 PDT 2014" file="custom-project-distribution-1.0.0-SNAPSHOT-
rel.zip" md5="7afd49faf0dcb9688e8c9c8dba4b29c9" force="false" patchVersion="1.0.5">
<modification type="add" file="custom-shared-lib-1.0.0-SNAPSHOT.jar"
md5="5cddf00fd9858025cf423f22cc10c78a" modifiedSinceLastPatch="true" source="patcher"/>
<modification type="add" file="custom-dataserver-services-1.0.0-SNAPSHOT.jar"
md5="13899f85ec1f5602f9c2c64e9d082d54" modifiedSinceLastPatch="true" source="patcher"/>
</patch>
|
|
Custom Extensions Audit | 2.3 Custom Extensions Audit
As previously noted, changes to deployment artifacts are strictly documented in a standard audit file
associated with each deployment artifact. The audit file structure is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<hotfix>
<patch date="Thu Apr 03 12:15:53 PDT 2014" file="custom-installed-extensions-1.0-rel.zip"
md5="af40d138e6e3d79e6a37206d5aae2cda" force="false" patchVersion="1.0.4">
<modification type="add" file="ojdbc6.jar" md5="54c41acb9df6465f45a931fbe9734e1a"
modifiedSinceLastPatch="true" source="patcher"/>
</patch>
<patch date="Mon Apr 14 23:38:25 PDT 2014" file="custom-project-distribution-1.0.0-SNAPSHOT-
rel.zip" md5="7afd49faf0dcb9688e8c9c8dba4b29c9" force="false" patchVersion="1.0.5">
<modification type="add" file="custom-shared-lib-1.0.0-SNAPSHOT.jar"
md5="5cddf00fd9858025cf423f22cc10c78a" modifiedSinceLastPatch="true" source="patcher"/>
<modification type="add" file="custom-client-1.0.0-SNAPSHOT.jar"
md5="f3f264194a18d126bccf5bafb4f86399" modifiedSinceLastPatch="true" source="patcher"/>
</patch>
<patch date=" Mon Apr 15 09:03:35 PST 2014" file="calypso-
scheduler.patch140022sp2.r271737.cumulative.chf" md5="7bad49c990c98a590ef479ec77d0c1c1"
force="false" patchVersion="1.0.5">
<modification type="upgrade" original="calypso-scheduling-engine-api-1.2.18.jar"
updated="calypso-scheduling-engine-api-1.2.25.jar" md5="2ea8beb464cf351ebb89081f407ff457"
modifiedSinceLastPatch="true" source="patcher">
<file modificationType="modified"
className="com/calypso/tk/scheduling/service/RemoteSchedulingService.class"
previousMD5="564235a95ecdb06c9b957efd57fb4d3b" newMD5="7c93c99cedf3d70124dc97a770b78bef"
source="patcher"/>
<file modificationType="modified"
className="com/calypso/tk/scheduling/SchedulerConstants.class"
previousMD5="b3b9b9656f199699d4c258e68b408aa9" newMD5="55d542a57f473e708eac36899529ad53"
source="patcher"/>
</modification>
<warning type=”version” moduleName=”calypso-core” patchVersion=1.25.5.2
installedVersion=”1.25.5.6” source=”patcher”/>
</patch>
</hotfix>
Each <patch> node inside the hotfix tag represents a single patch process. This patch occurs any time
a CUP or ZIP is applied (when using custom-extensions, the 'bld deploy' command create a CUP file
internally before deploying). The patch node has several attributes, including the date and time the
patch was run, the distribution which was applied, an MD5 sum of the distribution, whether the --force
flag was applied, and the patch tool version used to apply the change.
Within each patch node, changes made by the patch tool are indicated by a <modification> element.
The type indicates a specific action performed by the patch tool. The types which can occur are “add,”
“upgrade,” or “delete.” If an add is performed, patch adds both the file and md5. In the event of a
modification, the previous md5 and the new md5 are both recorded. For a library, the versions of each
of the jars is also recorded, as well as any class or resource changes within the jar itself. If a file is
deleted, the MD5 sum before it was deleted is indicated. The patch tool also records any warnings
displayed to the user using the <warning> tag, such as failure to patch a jar due to a version being
older than the currently installed version.
Audit Log Location by Deployment
Each component encapsulates the audit file (calypso-hotfix-audit.xml) in the following
locations.
Deployment Location
Server <calypso home>/server/calypso-server-audit.xml
Local Client <calypso home>/client/calypso-hotfix-audit.xml
|
|
Connecting to the Data Server and Event Server | 3.1 Connecting to the Data Server and Event Server
When you create a client application that requires access to Calypso data such as domain data
(currency code list, reference index list, etc.) and persistent data (trades, curves, positions, etc.), the
client application must establish a connection to the Data Server. Furthermore, if a client application
must publish or subscribe to Calypso events, it must also establish a connection to the Event Server.
Once a Data Server connection is established, the application can access Calypso data using the data
services.
See Data Services for details.
The example below illustrates how to create a connection to the Data Server and the Event Server and
how to disconnect before the program exits.
Creating Connections to the Data Server and Event Server
• Use com.calypso.tk.util.ConnectionUtil::connect to create a Data Server connection. This
method returns a com.calypso.tk.service.DSConnection object.
• Use com.calypso.tk.event.ESStarter::startConnection to create an Event Server connection. This
method returns a com.calypso.tk.event.PSConnection object.
• Use PSConnection::stop to disconnect from the Event Server.
• Use DSConnection::disconnect to disconnect from the Data Server.
Tips
• The connect method in ConnectionUtil is overloaded and allows different arguments and
options to create a connection to the Data Server. Refer to
com.calypso.util.ConnectionUtil for details. If you do not want to use ConnectionUtil, you
may directly use the connect method in DSConnection.
• The startConnection method in ESStarter is overloaded to allow using different arguments and
options to create a connection to the Event Server. Refer to com.calypso.event.ESStarter for
details.
• Once connected, the DSConnection object contains all of the settings from your Calypso
environment. You can access those settings using the different get methods in DSConnection.
The static method DSConnection.getDefault returns the connection created, making it
unnecessary to pass or store the DSConnection object in your code.
• The static methods PSConnection.setCurrent and getCurrent allow you to store the
PSConnection created in your client application, thus permitting your client application to
access it from anywhere within your code.
• Socket connection to the Data Server has been removed and an RMI call will be retried in case
of network issues.
• Properties that control the retry behavior are
− TIMEOUT_RECONNECT = Number of miliseconds between retries.
− MAX_NUMBER_OF_RECONNECTION = Number of times an RMI failed due to network
related issues will be retried.
If using PSSubscriber anywhere to connect to the Event Sever, the APIs disconnected() and
reconnected() need to be used. The onDisconnect() callback is deprecated and will be removed in the
future. disconnected() is called when connection from the Event Server is broken and reconnected() is
called when the reconnection mechanism is able to connect back to the Event Server.
Sample Code
public class PSSample {
private static final String LOGCAT = "PSSample";
static public void main(String args[]) throws Exception {
Log.system(LOGCAT, "Connecting to ds...");
DSConnection ds = ConnectionUtil.connect(args, "PSSample");
// create a subscriber
MySubscriber eventListener = new MySubscriber();
// events we are interested in
Class[] subscriptionList = new Class[] {PSEventTrade.class,
PSEventMessage.class,
PSEventTime.class,
};
Log.system(LOGCAT, "Connecting to jms bus...");
PSConnection ps = ESStarter.startConnection(eventListener, subscriptionList);
Log.system(LOGCAT, "Waiting before publishing 5 events...");
Thread.sleep(3000);
for(int i=0; i < 5; i++) {
// build an event
PSEventTime eventTime = new PSEventTime();
eventTime.setTime(System.currentTimeMillis());
eventTime.setComment("PSSample generated event "+i);
Log.system(LOGCAT, "Publishing event "+eventTime+"...");
ps.publish(eventTime);
}
}
/**
* MySubscriber class will be the call back point for
* all incoming events. newEvent will be invoked when
* an event matching the subscription list is recieved.
*/
private static class MySubscriber implements PSSubscriber {
public void newEvent(PSEvent event) { Log.system(LOGCAT, "Recieved event"
+", id="+event.getId()
+", type="+event.getEventType()
+", event="+event
);
}
public void disconnected() {
Log.system(LOGCAT, "Event bus has been disconnected!");
}
public void reconnected() {
Log.system(LOGCAT, "Event bus has been re-connected");
}
}
}
|
|
Handling a Lost Connection to the Data Server | 3.2 Handling a Lost Connection to the Data Server
If the Data Server connection is lost, your application may require a notification and might
subsequently attempt to reconnect to the Data Server. The Data Server provides the following
mechanisms to auto-reconnect if a connection is lost:
• DSConnection.setAutoReconnect() — Performs automatic reconnections to the Data Server.
• ConnectionListener — Monitors the connection to the Data Server.
Using DSConnection.setAutoReconnect()
[Note: DSConnection.setAutoReconnect() has no effect and is slated for removal]
Set setAutoReconnect() to true and set the following parameters as applicable:
• RETRY = Number auto-reconnect attempts
• TIMEOUT_RECONNECT = The interval in milliseconds between attempts to reconnect to the
Data Server.
Implementing ConnectionListener
To implement ConnectionListener:
1. Implement com.calypso.tk.service.ConnectionListener in the client application.
2. Call DSConnection::addListener(…) to register the client application with the Data Server.
Sample Code in samples/
UseDSListener.java
Illustrates how to extend the client application from TestCon.java to auto-reconnect to the
Data Server.
|
|
Creating Custom Initialization Code | 3.3 Creating Custom Initialization Code
The Data Server provides two ways to invoke custom code:
• Session bean — Invokes initialization code when the Data Server is started.
• DSConnectionInit — Invokes initialization code on the client each time a DSConnection is
created.
Using a Session Bean
A session bean invokes your initialization code when the Data Server is started. One usage of this
mechanism is to allow the Data Server to preload frequently accessed data for the use of the client
application(s).
Create a class named tk.service.<class name> that depends on DataServerInitializer.
Sample Class tk.service.CustomDSStartUpBean
It implements the initialization code in the method init().
package com.calypso.tk.service;
import javax.annotation.PostConstruct;
import javax.ejb.DependsOn;
import javax.ejb.Singleton;
import javax.ejb.Startup;
import com.calypso.tk.core.CalypsoServiceException;
import com.calypso.tk.core.Log;
import com.calypso.tk.mo.TradeFilter;
import com.calypso.tk.util.TradeArray;
@Startup
@Singleton
@DependsOn("DataServerInitializer")
public class CustomDSStartUpBean {
private static final String LOG_CATEGORY = "CustomDSStartUpBean";
// Assume we have a filter called LoadTradeCache with the necessary criteria and
// the check box "Cache trades on load" checked. When loading the filters, we will
// push all of the trades loaded into the trade cache.
private static final String LoadTradeCache = "LoadTradeCache";
@PostConstruct
void init(){
TradeFilter loadTradeCache = null;
try {
loadTradeCache = DSConnection.getDefault().
getRemoteReferenceData().getTradeFilter(LoadTradeCache);
TradeArray trades = DSConnection.getDefault().
getRemoteTrade().getTrades(loadTradeCache, null);
Log.system(LOG_CATEGORY, "Load " + trades.size() +
" trades in CustomDSStartUpBean");
} catch (CalypsoServiceException e) {
Log.error(LOG_CATEGORY, "Failed to load trades using ALL filter", e);
}
}
}
Using DSConnectionInit
DSConnectionInit allows you to specify a custom initialization class for client applications which is
called after a DSConnection is created and started.
Create a class named tk.service.CustomDSConnectionInit that implements the
com.calypso.tk.service.DSConnectionInit interface.
com.calypso.tk.service.DSConnection invokes DSConnectionInit.
|
|
Customizing the Calypso Navigator Startup | 3.4 Customizing the Calypso Navigator Startup
You can customize the startup of the Calypso Navigator by creating a class named
apps.startup.MainEntryStartUp<name> that implements
com.calypso.apps.startup.MainEntryStartUp. For example,
apps.startup.MainEntryStartUpPreloadCache.
1. Implement the method onStartUp().
2. Use the Domain Values window to add the startup class name to the “MainEntry.Startup”
domain.
− Navigate to the MainEntry.Startup domain.
− Set Value to class_name, for example “PreloadCache.”
− Click << Add.
− Click Save.
|
|
Using the Data Server | 4.1 Using the Data Server
The Data Server is a single point of access for all Calypso data. No client application should ever
access the database directly. Once you have a connection to the Data Server as described in
“Connecting to the Data Server and Event Server”, the Data Server is accessed through a set of remote
services located under the com.calypso.tk.service package, each of which is responsible for a
different group of data:
• RemoteMarketData — Handles pricing information (e.g., interest rate curves).
• RemoteReferenceData — Handles static data (e.g., counterparty definitions).
• RemoteProduct — Handles financial instrument definitions (e.g., futures contracts).
• RemoteTrade — Handles trade information.
• RemoteAccess — Handles access permission and system security data.
• RemoteAccounting — Handles accounting rules data.
• RemoteBackOffice — Handles back office-specific data.
The Calypso online documentation provides detailed descriptions of the objects handled by each
service under com.calypso.tk.service.
The Data Server in turn accesses the database or the data stored in cache. Caches maintained by the
Data Server are configured and administrated from the Calypso Web Admin application. However, for
data that is frequently accessed such as reference data, it is more efficient to locally cache those data in
the client. The BOCache and LocalCache classes are provided for that purpose, respectively. It is their
responsibility to access the Data Server.
Hence, to access Calypso data:
Check whether BOCache or LocalCache handle those data and use BOCache and LocalCache.
If BOCache or LocalCache do not contain the data, then use the appropriate remote service.
|
|
Using a Local Cache | 4.2 Using a Local Cache
LocalCache allows client applications to maintain client caches for a number of static data including
Currency Indexes, Rate Indexes, Rate Index Defaults, Currencies, Domains, and FX resets, thereby
enhancing the performance.
When data retrieval from LocalCache is attempted, if the data is not available in the cache, LocalCache
then retrieves the data from the data server and updates the cache, thus making the data available for
subsequent requests.
For caching other types of static data, use “Event Services”.
Tips
• Using an instance of tk.util.CacheConnection allows you to automatically maintain cache
consistency. This class subscribes to the events PSEventDomainChange,
PSEventQuoteRemoved, PSEventQuote, and PSEventCreditRating to obtain updates for
cached data, and also updates cached data.
CacheConnection cacheConnection = new CacheConnection(DSConnection.getDefault());
• Use tk.service.RemoteReferenceData to retrieve static data not handled by LocalCache or
BOCache.
• Do not use LocalCache for code that will be executed within the Data Server.
[Warning: When the client application must modify domain values (e.g., for display purposes)
you must clone the data using cloneDomainValues(), and then modify the cloned data. Never
directly modify the returned list directly. Doing so changes the master list in LocalCache and
causes data inconsistency]
Sample Code
samples/UseLocalCache.java
Illustrates how to use LocalCache in a client application.
The code creates a connection to the Data Server and calls the appropriate static method on
LocalCache to retrieve the values of the “Principal Structure” domain without the Mortgage
value.
|
|
Using BOCache | 4.3 Using BOCache
BOCache allows client applications to maintain client caches for a number of static data including
Accounts, Books, Contacts, Legal Entities, Settlement and Delivery Instructions, Exchange Traded
Products, and Netting Configurations. BOCache also maintains client caches for quotes.
When data retrieval from BOCache is attempted, if the data is not available in the client cache,
BOCache retrieves the data from the data server and updates the client cache, thereby making the
data available for subsequent requests.
For example, for a loading a trade, you would use BOCache to load the relevant TradeFilter to be
passed to the getRemoteTrade().getTrades(TradeFilter, Jdatetime) method:
TradeFilter tf = BOCache.getTradeFilter(ds, “MyTradeFilter”);
For caching other types of static data, refer to Event Services.
Tips
• Using an instance of tk.util.CacheConnection will allow you to automatically maintain cache
consistency. This class subscribes to the the events PSEventDomainChange,
PSEventQuoteRemoved, PSEventQuote, and PSEventCreditRating to obtain updates for
cached data, and also updates cached data.
CacheConnection cacheConnection = new CacheConnection(DSConnection.getDefault());
• The class samples/TestMultiThreadQuotes.java illustrates how to obtain refreshed quotes
from BOCache.
• Use tk.service.RemoteReferenceData to retrieve static data not handled by LocalCache or
BOCache. See also “Extending BOCache” below.
• You may use BOCache for code that will be executed within the Data Server. The BOCache will
switch implementations between the client side and the server side and will make the
appropriate call to the SQL classes when on the Data Server.
Extending BOCache
If the data you want to access is not handled by BOCache or LocalCache, and you want to cache that
locally, you can extend BOCache by providing an implementation of CustomClientCache in
tk.bo.CustomClientCacheImpl.
BOCache invokes CustomClientCacheImpl.
You must also publish a PSEventDomainChange for modified data so that the BOCache publishes
updates to CustomClientCacheImpl. PSEventDomainChange contains a set of static integers used to
identify what data has changed (legal entity, book, etc.). You must add your own set of static integers
to identify changes specific to CustomClientCacheImpl.
Create a class named tk.event.PSEventDomainChangeCustom that extends
com.calypso.tk.event.PSEventDomainChange and defines integers for each custom data as in the
example shown below.
final static public int MY_DATA1 = ID_MAX+1;
final static public int MY_DATA2 = ID_MAX+2;
Publish a PSEventDomainChangeCustom for each custom data.
|
|
Providing Custom CacheClient and LocalCacheClient | 4.4 Providing Custom CacheClient and LocalCacheClient
You can set the environment property CACHE_CLIENT_EXTENDED = true to look for custom
implementations of CacheClient and LocalCacheClient.
For CacheClient, you can create a class named tk.bo.CacheClient that extends
com.calypso.tk.bo.CacheClient.
For LocalCacheClient, you can create a class named tk.service.LocalCacheClient that extends
com.calypso.tk.service.LocalCacheClient.
|
|
Using a Remote Service | 4.5 Using a Remote Service
The following example demonstrates how to obtain a trade and product from the Data Server and how
to subsequently save them as a new trade and product.
Using a remote service:
• Create a connection to the Data Server.
• Obtain the appropriate remote object from the Data Server connection.
• Use the appropriate method in the remote object to retrieve or save the desired data.
Tips
For objects having a unique ID, the ID is assigned by the Data Server the first time the object is saved.
The save methods in the remote services for those objects return the assigned ID after a successful
save. It is important to set the object’s ID to the returned ID after a successful the save. Otherwise, the
object retains its initial null ID and any subsequent saves will result in a new copy of the object being
created.
Sample Code in samples/cookbook/
UseDataServer.java
To output all of the IDs of the trades in a TradeFilter, call getTrades(TradeFilter, JDatetime) on
RemoteTrade to return all the trades associated with the TradeFilter and whose trade date is
before the JDatetime.
DSConnection ds = null; try {
ds = ConnectionUtil.connect(args, "UseRemoteBO");
}
catch (ConnectException e) { Log.error(Log.CALYPSOX, e);
System.out.println("ERROR: Connection to data server failed.");
System.exit(-1);
}
JDatetime now = new
JDatetime(); try {
TradeArray v = ds.getRemoteTrade().getTrades(tradeFilter, now);
for(int i=0;i<v.size();i++) {
Trade trade = (Trade) v.elementAt(i);
System.out.println("Trade : " + trade.getId());
}
}
catch (Exception exc) {}
To retrieve a price quote for a product, use the RemoteProduct interface to load the product
and the RemoteMarketData interface to load the quote. The getProduct(int) method of
RemoteProduct returns the product for a given Product ID. The getQuoteValue(QuoteValue)
method of RemoteMarketData returns a QuoteValue object that contains the quote value and
type.
DSConnection ds = null;
try {
ds = ConnectionUtil.connect(args, "UseRemoteBO");
}
catch (ConnectException e) { Log.error(Log.CALYPSOX, e);
System.out.println("ERROR: Connection to data server failed.");
System.exit(-1);
}
Product product = null;
try {
product = ds.getRemoteProduct().getProduct(inputProductId);
}
catch (Exception exc) {}
JDatetime now = new JDatetime();
JDate quoteDate = now.getJDate(TimeZone.getDefault());
// Initialize a QuoteValue object
// use quote type NONE - will be set by getQuoteValue method
QuoteValue q = new QuoteValue(quoteSetName,
product.getQuoteName(),
quoteDate,
QuoteValue.NONE,
0,
0);
try {
q = ds.getRemoteMarketData().getQuoteValue(q);
}
catch (Exception exc) {}
Sample Code in samples/
QuoteLoaderSample.java
|
|
Extending the Data Server | 4.6 Extending the Data Server
When a custom object that requires persistence is added to the system, the Data Server must be
extended to save, load, and cache the object. If necessary, the extension should also support event
publishing when the object is first saved or when it is modified.
The Calypso API provides two ways to extend the Data Server:
• The DSTransactionHandler
• Creating a custom remote service
The DSTransactionHandler is intended to accommodate a small number of custom objects. As
illustrated in the next section, the user must create a DSTransactionHandler and other related classes
for each custom object which is time consuming when a large number of custom classes is needed.
However, for a small number of custom objects, the DSTransactionHandler is an efficient mechanism to
extend the Data Server.
[NOTE: The extension of the Data Server is only required for custom objects that do not
extend from an existing persistent Calypso object. The system has other mechanisms to
support children of persistent Calypso objects and these dedicated mechanisms should be
used instead. For example adding a new product or market data does not require extending
the Data Server]
The following sections demonstrate how to extend the Data Server using both methods. In the
examples, we will extend the Data Server to handle the persistency, caching, and event publishing of a
custom “equity basket.”
Persistence
Handling persistence for the equity basket class requires you to write an SQL class and create a
database table. These steps are required regardless of which extension method is used.
Sample Code in samples/cookbook/
tk/product/EquityBasket.java
EquityBasket sample. The EquityBasket class example is only a sample, it is not suitable for
production.
Tips
• SQL Error Handling — The SQL methods should throw a PersistenceException so that the user
of the client application receives an error message if an SQL error occurs. The remote methods
that call your SQL methods will catch PersistenceException and then create and throw a
RemoteException containing that PersistenceException.
For example:
void sqlfoo() throws PersistenceException { try {
...
}
catch (SQLException e) {throw new PersistenceException(e.getMessage()):}
}
The typical RMI method that calls an SQL method will handle the error as follows:
void rmiCall() throws RemoteException {
try {
sqlfoo();
}
catch(Exception e) {throw new RemoteException(e.getMessage());}
}
• JResultSet — Calypso recommends using com.calypso.core.sql.JResultSet to work with
query results when you retrieve multiple records from the database. JResultSet is a wrapper
class (around a ResultSet object) that adds the methods getJDate() and getJDatetime() to
return a date or datetime from any cell in a table of query results.
The example below shows how one might use a JResultSet to compile a Vector of trades with
their Trade ID and Trade Date/Settle Date stamps. In this example, all Trade Date and Settle
Date stamps are expressed in the system’s local time zone:
static public Vector getAllTradeTimestamps() {
Vector tradeVector = new Vector();
Connection con = ioSQL.newConnection();
Statement stmt = null;
try {
stmt = ioSQL.newStatement(con);
JResultSet rs = new JResultSet(stmt.executeQuery("SELECT \ trade_id,
trade_date_time, settlement_date FROM trade,book \
where book.book_name=’TRADINGC’ and trade.book_id=book.book_id"));
int j; while(rs.next()) {
j=1;
Trade trade = new Trade();
tradeVector.addElement(trade);
trade.setId(rs.getInt(j++));
trade.setTradeDate(rs.getJDatetime(j++));
trade.setSettleDate(rs.getJDate(j++));
}
rs.close();
}
catch( Exception e ) { display(e); } finally {
try {ioSQL.close();}
catch (Exception e) {} ioSQL.releaseConnection(con); }
return tradeVector;
}
• Dates — Calypso distinguishes between timestamps stored in the database and those
displayed to users. Saved timestamps are expressed in the designated reference time zone,
while timestamps displayed to and set by users are expressed in the local time zone, which is
the time zone of the user's workstation. By default, the reference time zone for stored
timestamps is GMT.
When using SQL queries to retrieve information from the Calypso database, keep in mind that
all dates and times are expressed in the system's designated reference time zone. Thus any
dates and times in your WHERE clauses must be expressed in the reference time zone, and you
must convert all dates/times in your query results to the desired local time zone.
Calypso provides a set of methods to convert dates and times from system reference timezone
to local timezone. These methods are contained in the com.calypso.tk.core.Util class. To
convert a local date to a String for use in a WHERE clause, use the method date2SQLString() or
datetime2SQLString().
Alternatively, you can use Util.ReferenceTZ2Local(Date) to convert a date from the reference
time zone to the local time zone.
• Commit and Rollback — Whenever you have a commit in an SQL file, ensure that you also
have a rollback as shown in the example below.
Void save(myObject){
try {
Connection con=ioSQL.newConnection();
save(myObject, con);
commit(con);
// Update the Cache or any hash Only after commit
}
catch(PersistenceException e){ rollback(Con); Log.error(e,e)
}
finally{ releaseConnection(con)}
[NOTE: Do not put the commit inside save(myObject, con)]
|
|
Creating a Data Server Service | 4.7 Creating a Data Server Service
Data Server services are stateless session beans and follow the EJB 3.1 specification. To create a Data
Server service, you will need to create at least 3 types:
• Remote interface: Exposes methods for use by remote Data Server client applications
• Local interface: Exposes methods for use by classes within the Data Server
• Implementation class: Implementation of Data Server service
For example, the following code sample shows a sample remote interface (RemoteFeatureService), a
local interface (LocalFeatureService) and implementation (FeatureServiceImpl).
package com.calypso.tk.service.feature;
// Methods exposed for remote invocations by dataserver clients
public interface RemoteFeatureService {
int save(FeatureObject obj) throws FeatureServiceException;
FeatureObject getFeatureById(int id) throws FeatureServiceException;
}
// Methods exposed for local invocations within the dataserver
public interface LocalFeatureService extends RemoteFeatureService {
void amendFromWorkflow(FeatureObject obj) throws FeatureServiceException;
}
@Stateless(name="com.calypso.tk.service.feature.RemoteFeatureService")
@Remote(RemoteFeatureService.class)
@Local(LocalFeatureService.class)
public class FeatureServiceImpl implements RemoteFeatureService, LocalFeatureService {
public int save(FeatureObject obj) throws FeatureServiceException {
// implementation goes here
}
public FeatureObject getFeatureById(int id) throws FeatureServiceException {
// implementation goes here
}
public void amendFromWorkflow(FeatureObject obj) throws FeatureServiceException {
// implementation goes here
}
}
Use the following conventions when writing the service to allow the Calypso DSConnection API to
lookup the new service.
• Name of the stateless session bean must be the fully qualified name of the remote interface.
• The local interface must extend the remote interface. The local interface can add additional
methods that should be accessible only from within the Data Server (for example, from a
workflow) and not to remote clients.
• Do not throw RemoteException from the service methods.
Create the above service classes in the custom-extensions/custom-projects/custom-dataserver-
services project. The classes can be tested and deployed using the custom-extensions build.
|
|
Read-Only Data Servers | 4.8 Read-Only Data Servers
A read-only Data Server provides a mechanism to off-load work from the active Data Server for read
operations. High volume read operations, such as generating reports, or other similar tasks could have
a negative impact on Data Server performance. Using a read-only Data Server allows access to data,
while not impeding write operations. Read-only Data Servers do not operate as standalone servers,
they require the presence of an Active (i.e., a read/write) Data Server.
[NOTE: Read-only Data Servers do not update the cache. The cache is updated by listening
for events sent by the active Data Server and then reloading the information from the
database as needed. This requires database connectivity for the read-only Data Server]
The call to use events to update the cache for a read-only Data Server rather than RMI services, is
controlled by setUseCacheSubscriber(). If the DS_READ_ONLY property is true, indicating that the
Data Server is running in read-only mode, then setUseCacheSubscriber() also returns true. Note that
the DS_READ_ONLY property must be set prior to starting the Data Server.
Refer to the Calypso Installation and Upgrade Guide for complete information on setting up the Data
Server in read-only mode.
How to Customize SQL Query Testing
You can customize the testing of SQL Queries to see if they are allowed on a read-only Data Server.
Create a class named tk.core.sql.CustomReadOnlySQLTest that implements the interface
com.calypso.tk.core.sql.ReadOnlySQLTest.
This class will be invoked from com.calypso.tk.core.sql.CalypsoStatement.
|
|
Event Services | Section 5. Event Services
Calypso leverages a standard JMS bus to propagate events throughout the platform to listeners. The
implementation leverages a single JMS topic for all business related events. The ESStarter interface is
the starting point for all access to the event bus.
|
|
Subscribing to and Publishing Events | 5.1 Subscribing to and Publishing Events
Listeners and publishers must be created through the ESStarter class and must leverage the
PSConnection and PSSubscriber interfaces to interact with the underlying JMS connection as
publishers and subscribers.
See “Connecting to the Data Server and Event Server" for a high-level overview of how to leverage
the ESStarter interface and refer to the ESStarter java API for details.
PSEvent (com.calypso.tk.event.PSEvent) is the base class for all event types. Each derived class
represents a specific type of event. For example, PSEventTrade models the events published when a
user performs an operation on a trade.
[NOTE: All events are named PSEvent<event type> and are located under
com.calypso.tk.event]
|
|
Event Types and Filtering | 5.1.1 Event Types and Filtering
Events published to the bus are differentiated by their type. This type is represented by different
classes implementing each event container. All classes extend the PSEvent class, each derived class
represents a different specific event type.
Subscribers built via the ESStarter can register for specific event types. This event list must be defined
at the time of building the PSConnection and cannot be altered once defined. Any change to the list of
events requires you to rebuild the PSConnection.
|
|
Publishing Events | 5.1.2 Publishing Events
Once you have a PSConnection, you can:
• Publish non-persistent events using the publish() method on
com.calypso.tk.event.PSConnection.
• Publish persistent events using the saveAndPublish() method on
com.calypso.tk.service.RemoteTrade. This method saves and publishes an event, or a list of
events, as a single transaction so that events are published only if the database save operation
succeeds.
|
|
Subscribing to Events | 5.1.3 Subscribing to Events
Subscription to events requires the creation of a listener which implements the PSSubscriber interface.
This class will implement the basic event handling logic desired. An instance of this class will then be
passed to the ESStarter.startConnection method.
The subscriber class can do the following:
• Handle events received from the real-time event bus.
• React to a disconnect from the bus. The disconnect call back is provided in order to allow
implementors to react to this event and attempt to rebuild their PSConnection.
[NOTE: It is important to note that management of the PSConnection should not be done
within the event handling thread (in the PSSubscriber) and should be delegated to a separate
thread allowing the subscriber to continue its lifecycle to either consume events or complete
the tear down of the connection]
|
|
Creating a Custom Event | 5.2 Creating a Custom Event
New event types can be added to the system to accommodate the addition of custom objects. For
example, when we add the EquityBasket in the Data Server extension example (“Extending the Data
Server"), we must also add a new event type PSEventEquityBasket to notify the system when an
EquityBasket object is created or modified.
Overview of Steps
• Step 1 — Create an event class that extends PSEvent
• Step 2 — Register the new event class
Step 1 — Creating a custom PSEvent.
Create a class named tk.event.PSEvent<event type> that extends com.calypso.tk.event.PSEvent.
[NOTE: Since event objects are serialized for communication, each event class must have its
own unique serialVersionUID, and must be included in the class definition. Obtain the ID by
running %JAVA_HOME%\bin\serialver.exe on Windows or $JAVA_HOME/bin/serialver on Unix
platforms]
The following methods of PSEvent must be implemented:
• toString() — Returns a canonical string representing the event object. The result includes the
class name and identification number. However, the actual event subclasses will often want to
redefine this method to produce a more descriptive description of the event.
• getEventType() — Returns the event class name of the event. However, the actual event
subclasses will often have an event type that is more specific than the class name. Many
subclasses redefine this method to return a more precise event type designation.
Sample Code in calypsox/tk/event/
PSEventEquityBasket.java
Step 2 — Registering the new event class.
Add the new event class PSEventEquityBasket to the “eventClass” domain.
|
|
How to Create a Custom Daycount | 6.1 How to Create a Custom Daycount
Create a class named tk.core.CustomDayCountCalculator which implements the interface
com.calypso.tk.core.DayCountCalculator.
This class is invoked from com.calypso.tk.core.DayCount so that once it is compiled, the new
Daycount is made available in the system.
[NOTE: The maximum length of a daycount is nine characters]
Sample Code in calypsox/tk/core/
CustomDayCountCalculator.java
|
|
How to Create a Custom Tenor | 6.2 How to Create a Custom Tenor
Create a class named tk.core.CustomTenorCalculator which implements the interface
com.calypso.tk.core.TenorCalculator.
This class is invoked from com.calypso.tk.core.Tenor so that after compiling, the new Tenor is
available in the system.
|
|
How to Create a Custom Date Rule | 6.3 How to Create a Custom Date Rule
Create a class named tk.core.DateGenerator<custom_name> that implements the interface
com.calypso.tk.core.DateGenerator.
This class is invoked from com.calypso.tk.core.DateRule so that once it is compiled, the new Date
Rule is available in the system.
|
|
How to Create a Custom Frequency | 6.4 How to Create a Custom Frequency
Create a class named tk.core.CustomFrequencyCalculator that implements the interface
com.calypso.tk.core.FrequencyCalculator.
This class is invoked from com.calypso.tk.core.Frequency so that once it is compiled, the new
Frequency is available in the system.
|
|
How to Chain Exceptions | 6.5 How to Chain Exceptions
All calypso exceptions are derived from the class com.calypso.tk.core.CalypsoException.
Exceptions can be chained using setNext() and getNext(), which allows the system to throw multiple
exceptions.
In all SQL transactions under tk, the code catches all Throwable rather than just Exception.
|
|
How to Create a Comparator Class for Sorting Objects | 6.6 How to Create a Comparator Class for Sorting Objects
You can create a custom comparator class to order aggregation groups in ScenarioAnalysisViewer.
Create a class named tk.util.<name>Comparator that implements java.util.Comparator.
You can access the comparator class using ComparatorFactory.getCustomComparator(“<name>”).
|
|
Engines | Section 7. Engines
Engines in Calypso are special type of event listeners. These specialized listeners manage the
guaranteed delivery of persisted events, the event bus reconnect features as well as allow for multi-
threaded processing of events.
|
|
Creating a Custom Engine | 7.1 Creating a Custom Engine
A custom engine is implemented by extending the Engine base class. All jars for engines are included
in the custom-engine prohect and the engines are started with all of the jars and run as a springboot
server (referred to as the Engine Server). Within an Engine Server instance, there can be multiple
engines running. For example, Transfer engine, Message engine, Accounting engine can all be
running within the same Engine Server instance.
Custom engines can be registered from the Engine Manager in Web Admin.
By default, multiple engines run together in a single EngineerServer instance (implying a single JVM
instance). This deployment model is intended to simplify deployment for smaller clients with lower
volumes. Please be aware that engines can be split across multiple EngienServer instances in order to
scale across CPU and memory. Also note that custom engines should be thread-safe before being
merged into a single server. It is recommended that custom engines are separated from core engines.
It is also recommended that custom engines be individually separated until their thread safety is
validated.
|
|
Extend the Engine Base Class | 7.1.1 Extend the Engine Base Class
Create a class that extends com.calypso.engine.Engine. The custom engine class must follow the
following conventions:
• The class must implement the following constructor Engine(DSConnection dsCon, String
hostname, int port) where:
− dsCon - a valid DSConnection object
− hostname/port - Beginning in v12.0, the management of the event server connection is no
longer the responsibility of each engine class and therefore the custom engine class can
ignore these parameters and simply pass them to the parent constructor.
• The following methods of the Engine class must be implemented:
− init(EngineContext engineContext) - EngineContext provides access to parameters
specified in the Engine Manager. Must invoke super.init(engineContext) to allow the base
Engine class to complete its processing.
− getNonPersistentClasses() - Override to specify additional non-persistent event classes. By
default, PSEventTime, PSEventAdmin, PSEventEngineRequest and PSEventDomainChange
are subscribed.
− process(PSEvent event) - If the event is successfully processed, the method must return true
and mark the event as processed by invoking RemoteTrade.eventProcessed. If the event
cannot be processed, the method must return false.
The following code sample illustrates a custom engine class.
public class CustomEngine extends Engine {
// if this engine accepts a config parameter
private String configName;
// Must provide with the following constructor
// Used by the engineserver framework to instantiate all engines
public CustomEngine(DSConnection dsCon, String hostName, int port) {
super(dsCon, hostName, port);
}
// invoked before starting the engine
// EngineContext provides access to parameters
@Override
protected void init(EngineContext engineContext) {
super.init(engineContext);
configName = engineContext.getInitParameter("config", null);
// use configName to perform any engine initialization
}
public List<String> getNonPersistentClasses() {
List<String> nonpersistentclasses = new ArrayList<String>();
// if this engine requires access to PSEventCustom in addition
// to the default non-persistent event classes
nonpersistentclasses.add(PSEventCustom.class.getName());
// persistent event classes must be configured in the
// event config so that they are saved by the dataserver
// DO NOT ADD persistent classes to this list
return nonpersistentclasses;
}
// Engine is always started in batch mode to allow it to
// catch up with any events in DB
// override process(PSEvent) to perform processing
@Override
public boolean process(PSEvent event) {
return false;
}
}
[NOTE: The order of the events published by the Event server is not guaranteed. This means
that an engine may receive a trade version 1 (trade amendment) before trade version 0 of the
same trade (trade creation), which can cause issues – Receiver engines should handle out-of-
order events]
Tips
• Add publishing to an engine
Engines often publish events, as well as subscribe to events. To publish within an engine you
would simply add the following to the engine getPSConnection().publish().
• Suspend/Resume
Engine that are subscribed to PSEventAdmin and operating in real time (listening for events),
as opposed to batch mode (not listening to events), will respond to suspend/resume events.
MAX_QUEUE_SIZE controls the number of trades held in memory before an engine switches
to batch mode.
• Setting engine parameters
Engine parameters can be set from the Engine Manager in Web Admin.
Use the following methods on com.calypso.tk.service.RemoteAccess to load and save
engine parameters:
− saveEngineParams(EngineParamOptionsConfig)
− getEngineParams()
− getEngineParam(String engine, String param)
|
|
Registering the New Engine | 7.1.2 Registering the New Engine
To register a custom engine, bring up Web Admin, and choose Manage > Engines.
Then click “Create New Engine”:
Enter the engine name, engine class, event subscription, event filter and parameters as needed, and
save.
You can then start / stop the engine directly from the Engine Manager.
Please refer to Calypso Web Admin documentation for complete details.
|
|
How to Customize the Transfer Engine | 7.2 How to Customize the Transfer Engine
The Transfer engine uses a process based on a BOProductHandler for a given product, and the
Transfer rules if settlement instructions have been set up, to generate transfers as follows.
• The BOProductHandler creates all the transfers relating to a Trade using cash flows and
applying the settlement instructions.
If the Transfer Engine is processing a given Trade for the first time, all transfers are generated
from the beginning of the trade. If transfers for the trade were generated previously, the
Transfer Engine filters the Transfers to those having a settle date on or after the current day’s
date, and which do not have a CANCELED status. If the event is a PSEventProcessTrade, the
limit date for back-value payment regeneration is specified. You can create a custom date
filter, and you can also customize how to set the dates on the transfers.
• The Transfer Engine then compares the generated transfers to the existing transfers and
matches them based on the following criteria. If a transfer does not match, it is considered
unmatched.
• The NettingHandler will create netted transfers if netting is required by the transfers. The
Netting Type field on the Transfer indicates if netting is required and what type of netting
should occur. You can customize the netting selector. You can customize the netting handler
by netting type.
|
|
Creating a Custom BOProductHandler | 7.2.1 Creating a Custom BOProductHandler
The base class for producing trade cashflows and transfers with settlement instructions is
com.calypso.tk.bo.BOProductHandler. Each product will usually have its own BOProductHandler. A
BOProduct<product_type>Handler can itself extend or override another
BOProduct<product_type>Handler.
Create a class named tk.bo.BO<product_type>Handler or tk.bo.BO<product_family>Handler which
extends com.calypso.tk.bo.BOProductHandler.
A BOProductHandler may define the following methods: generateTransferRules, generateTransfers,
exercise, UpdateTransfer, addSecurityFlows, checkAutomaticTransfers.
This class will be invoked from com.calypso.tk.bo.BOProductHandler.
Sample Code in calypsox/tk/bo/
BODEMO_P1Handler.java
|
|
BOSimpleRepoHandler | 7.2.2 BOSimpleRepoHandler
BOSimpleRepoHandler is a custom handler that extends com.calypso.tk.bo.BOSimpleRepoHandler.
It provides, for example, the possibility to add an attribute to a Transfer by using the UpdateTransfer()
method.
|
|
Creating a Custom Interest Dispatch Process | 7.2.3 Creating a Custom Interest Dispatch Process
It is possible to customize the behavior of the interest dispatch process for repos.
Create a class named tk.bo.BORepo<dispatch_method>DispatchInterestHandler that implements
com.calypso.tk.bo.BORepoDispatchInterestHandler.
BORepoDispatchInterestHandler has two methods:
• dispatchInterest() called from addSecurityFlow(), allows creating as many interest flows as
necessary.
• updateInteretTransfer() called from preProcessDAPTransfers(), allows linking transfers created
because of the new interest flows to the security and principal transfers of each collateral.
Then register the dispatch method in the “Repo.DispatchInterestMethod” domain.
This class will be invoked from com.calypso.apps.tk.bo.BORepoHandler.
|
|
Creating a Custom Date Filter | 7.2.4 Creating a Custom Date Filter
The default behavior will generate the Product transfers up to the next event date if engine parameter
XFER_NEXT_EVENT = True.
Create a class named tk.product.<product_type>ProductNextEventDate that implements the
interface com.calypso.tk.product.ProductNextEventDate.
<product_type>ProductNextEventDate is invoked by
com.calypso.tk.product.ProductNextEventDateUtil, which is used by BOProductHandler.
|
|
Creating a Custom Date Selector | 7.2.5 Creating a Custom Date Selector
Create a class named tk.bo.CustomBOTransferDateSelector which implements the interface
com.calypso.tk.bo.BOTransferDateSelector.
CustomBOTransferDateSelector is invoked by com.calypso.tk.bo.BOProductHandler to set the dates
on the transfers.
|
|
Creating a Custom Transfer Matching Mechanism | 7.2.6 Creating a Custom Transfer Matching Mechanism
This interface determines whether a Transfer must be canceled, updated, or created. For instance, it
allows the user to disable some criteria during the matching of two transfers.
Create a class named engine.payment.<product_type>TransferMatching or
engine.payment.DefaultTransferMatching, which implements the interface
com.calypso.engine.payment.TransferMatching.
The *TransferMatching class is invoked by com.calypso.engine.payment.TransferMatchingUtil,
which is used by the Transfer engine to select the transfer matching mechanism.
The default transfer matching mechanism is based on the CHECK_PAST_SDI_VERSION property. If
CHECK_PAST_SDI_VERSION is set to False and the SDI version number has changed, transfers will not
be regenerated. If CHECK_PAST_SDI_VERSION is set to True and the SDI version number has
changed, transfers will be regenerated.
|
|
Creating a Custom Netting Handler | 7.2.7 Creating a Custom Netting Handler
You can create a custom netting handler to modify how netting is done. Create a class named
tk.bo.<netting_handler>NettingHandler that implements com.calypso.tk.bo.NettingHandler.
The default implementation is DefaultNettingHandler.
Register the <netting_handler> in the “nettingHandler” domain. You can associate a custom netting
handler with a netting type in the Netting Config window.
|
|
Creating a Custom Netting Method Selector | 7.2.8 Creating a Custom Netting Method Selector
A custom Netting Method Detector automatically sets the Netting Type on the Transfer Rules and lets
you override the Netting Method default value.
Create a class named tk.bo.<product_type>NettingSelector which implements the interface
com.calypso.tk.bo.NettingSelector.
*NettingSelector is invoked by com.calypso.tk.bo.NettingSelectorUtil to set the netting method.
|
|
Creating a Custom Persistence Routine for Transfer Attributes | 7.2.9 Creating a Custom Persistence Routine for Transfer Attributes
Create a class named tk.bo.sql.CustomTransferAttributeSQL that implements the interface
com.calypso.tk.bo.sql.TransferAttributeSQL.
CustomTransferAttributeSQL is invoked from com.calypso.tk.bo.sql.BOTransferSQL when saving
transfers. TransferAttributeSQL includes methods for archiving custom attributes that must be
implemented. To fully support archiving and restoring of custom attributes, you must define new
history tables for any custom attribute tables you have added to the database.
|
|
Customizing the Message Engine | 7.3 Customizing the Message Engine
The Message engine generates messages for various events as applicable (Trade, Transfer, etc), using
the following process:
• The Message engine identifies the roles to which sending the message using TradeRoleFinder.
Once, the roles are determined, receiver contact information can be retrieved. A message is
generated for each receiver using a BOMessageHandler provided MessageSelector confirms
the message must be generated. The behavior of TradeRoleFinder and MessageSelector can
be customized. You can create a custom BOMessageHandler for a given product.
• BOMessageHandler builds the messages based on the Message setup rules. It uses
FormatterUtil to select a type of Formatter (SWIFT, HTML, etc.) and a template. It uses
MessageFormatterUtil to select a MessageFormatter for populating the template. The
MessageFormatter is selected based on the type of Formatter and the product. You can create
a custom type of Formatter, a custom template selector, a custom MessageFormatter selector,
and a custom MessageFormatter.
|
|
Creating a Custom Update Transfer | 7.3.1 Creating a Custom Update Transfer
A custom Update Transfer can modify the Transfer depending on the Transfer, Trade, and Cashflow.
Create a class named tk.bo.CustomUpdateTransfer that implements the interface
com.calypso.tk.bo.UpdateTransfer.
|
|
Creating a Custom Role Finder | 7.3.2 Creating a Custom Role Finder
For example, you want to retrieve the possible receivers of a message based on the Legal Entity role.
Write this class to retrieve the Legal Entities for a given Role defined in a Trade, a Product, or a
Transfer.
Create a class named tk.bo.<product_type>RoleFinder or tk.bo.<product_family>RoleFinder
which extends the class com.calypso.tk.bo.TradeRoleFinder.
This class will be invoked from com.calypso.tk.bo.TradeRoleFinder.
|
|
Creating a Custom Message Selector | 7.3.3 Creating a Custom Message Selector
For instance, the SampleCustomMessageSelector returns False when there is no SWIFT address for the
Receiver Contact, causing a message to not be generated by the Message engine.
Create a class named engine.advice.CustomMessageSelector which implements the interface
com.calypso.engine.advice.MessageSelector.
This class is invoked by com.calypso.engine.advice.MessageEngine to establish if a message must
be generated.
|
|
Customizing Message Selection | 7.3.4 Customizing Message Selection
A custom interface allows customers to implement a specific behavior of AdviceConfigSelection in the
MessageEngine.
The customized implementation must be called engine.advice.CustomAdviceConfigSelector and
must implement com.calypso.engine.advice.AdviceConfigSelector.
The Default backward compatible implementation is
com.calypso.engine.advice.DefaultAdviceConfigSelector, which is instantiated by default.
A sample custom implementation is located in the calypsox directory. This custom implementation
generates a message for a given event type for a specific product type, as well as a message for the
product type ALL. Hence, it is no longer necessary to duplicate an advice config product type ALL for a
given eventType if an advice config for particular productType and eventType already exists.
|
|
Creating a Custom Message Handler | 7.3.5 Creating a Custom Message Handler
Create a class named tk.bo.BO<product_type>MessageHandler or
tk.bo.BO<product_family>MessageHandler which extends com.calypso.tk.bo.BOMessageHandler.
[NOTE: For message types without a product type, such as STATEMENT, you can create a
class named tk.bo.BOSTATEMENTMessageHandler. In this case, the product-specific
message handler is simply skipped and the application uses the more generic messagetype-
based handler]
You may be redefine the following BOMessageHandler methods:
• generateBOMessages() — Defines what messages should be produced.
For example, for an FX Swap confirmation by Swift, it would create two messages, one for each
leg.
• setSpecialMessageEnvironment() — The Message engine calls this function whenever an
existing message has been found. It allows you to set a link between each message and decide
what should be done on the previous existing message. Typically this function sets the
keyword AMEND, CANCEL or NEW.
• filterMessages() — Returns the existing message matching exactly the new one which should be
generated. For example, if you have already produced a Bond Confirmation, it will return the
existing Bond Confirmation already generated for the Trade.
• isMessageRequired() — Allows you to decide if the new message should be created. This
function provides access to the previous message generated. You can therefore perform any
type of comparison required.
• fillDefaultMessageInfo() — Called to initialize each message created by the Message engine.
• getTradeFieldsNotAmendmentDomain() — Selects the domain containing the trades fields that
can be amended without triggering the generation of a new BO Message.
• getFeeNotAmendmentDomain() — Selects the domain containing the fees names that can be
amended on a trade without triggering the generation of a new BO Message.
This class will be invoked from com.calypso.tk.bo.BOMessageHandler.
|
|
Creating a Custom Type of Formatter | 7.3.6 Creating a Custom Type of Formatter
Calypso provides formatter support for HTML, Text, SWIFT, and XML, standard. However, it might be
necessary to support the FIX format and hence, create a FIX generator class.
Create a class named tk.bo.<format_type>Formatter which implements the interface
com.calypso.tk.bo.Formatter. Implement the methods generate() to generates an advice
document, and display() to displays the advice document in the Task Station.
<format_type>Formatter is invoked from com.calypso.tk.bo.FormatterUtil.
|
|
Creating a Custom Template Selector | 7.3.7 Creating a Custom Template Selector
Create a class named tk.bo.<product_type>TemplateSelector which implements the interface
com.calypso.tk.bo.TemplateSelector.
Invoke TemplateSelector from com.calypso.tk.bo.FormatterUtil to choose a template selector.
|
|
Creating a Custom Message Formatter Selector | 7.3.8 Creating a Custom Message Formatter Selector
Create a class named tk.bo.<message_type>MFSelector which implements the interface
com.calypso.tk.bo.MFSelector.
Invoke MFSelector from com.calypso.tk.bo.MessageFormatterUtil to choose a MessageFormatter
selector.
|
|
Creating a Custom Message Formatter | 7.3.9 Creating a Custom Message Formatter
A Message Formatter is responsible for extracting the information from a trade and matching the
appropriate keywords in the template.
See “How to Create an HTML Template,” for information on how to create an HTML template.
Create a class named tk.bo.<message_type><product_type>MessageFormatter,
tk.bo.<product_type>MessageFormatter or tk.bo.CustomMessageFormatter which extends
tk.bo.MessageFormatter.
In your MessageFormatter, create a parse<keyword_name>() method for each keyword you wish to
add. For example parseRATE_INDEX().
Implement each parse method to take the following arguments and return the keyword value for a
given situation, as defined by the passed arguments.
• message — the message which will use the returned keyword value;
• trade — the trade with which the advice is associated;
• sender — the contact person sending the advice (LEContact);
• rec — the contact person receiving the advice (LEContact);
• transferRules — a Vector of TradeTransferRule objects which provide the general definition
of any payments associated with the advice;
• transfer — the payment, if any, associated with the advice;
• dsCon — a connection to the Data Server.
[NOTE: In your parse method, you can check if a custom keyword is being evaluated within
an IF statement using FormatterParser.isConditionalEvaluation(), which will return a Boolean]
The following methods are available in MessageFormatter:
• protected void setCustomFormatter(MessageFormatter formatter);
• protected MessageFormatter getCustomFormatter();
The method setCustomFormatter() is called by the core Calypso code once, when the
MessageFormatter is loaded to format a message, to store the CustomMessageFormatter instead of
reloading it for every template keyword. This method can be overridden as needed.
The method getCustomFormatter() can be used to get the current CustomMessageFormatter as
needed.
A MessageFormatter class will be invoked from com.calypso.tk.bo.MessageFormatterUtil.
CustomMessageFormatter is invoked from com.calypso.tk.bo.MessageFormatter.
Sample Code in calypsox/tk/bo/
StructuredProductMessageFormatter.java
|
|
Creating a Custom Persistence Routine for Message Attributes | 7.3.10Creating a Custom Persistence Routine for Message Attributes
Create a class named tk.bo.sql.CustomMessageAttributeSQL that implements the interface
com.calypso.tk.bo.sql.MessageAttributeSQL.
MessageAttributeSQL is invoked from com.calypso.tk.bo.sql.BOMessageSQL when saving
messages. MessageAttributeSQL includes methods for archiving custom attributes that must be
implemented. To fully support archiving and restoring of custom attributes, you must define new
history tables for any custom attribute tables you have added to the database.
|
|
Creating a Custom XML Generator | 7.3.11Creating a Custom XML Generator
Create a class named tk.bo.xml.<template_name>XMLGenerator or
tk.bo.xml.DefaultXMLGenerator that implements the interface
com.calypso.tk.bo.xml.XMLGenerator.
XMLGenerator is invoked from com.calypso.tk.bo.xml.XMLUtil.
|
|
Creating Multiple BOMessages per Message Type | 7.3.12Creating Multiple BOMessages per Message Type
Create a class named tk.product.<product_type> that implements the interface
com.calypso.tk.product.MultiMessageProduct.
For example, an FX Swap needs two trade confirmations when you verify the trade; one confirm for the
near leg and a second confirm for the far leg.
|
|
How to Customize a Statement Message | 7.3.13How to Customize a Statement Message
The AccountStatementInterface interface is used by the Message engine to set the Message Reference
on the Statement messages. It provides flexibility in the population of the fields:
fillMessageReference(MessageArray message, AccountStatement statement, DSConnection dsCon).
To customize the statements, create a class named tk.bo.swift.AccountStatementCustomizer that
implements tk.bo.AccountStatementInterface.
|
|
How to Customize the Statement Configuration | 7.3.14How to Customize the Statement Configuration
You can create a custom panel in the Statement Config window: Make sure that the statement type is
defined in the domain “StatementType”, and create a class named
apps.refdata.accounting.statement.<statement type>AccountStatementConfigPanel that
implements the interface AccountStatementConfigPanelInterface.
|
|
How to Customize MessageIdentifier | 7.3.15How to Customize MessageIdentifier
Create a class named tk.engine.advice.BOMessageMessageIdentifierHandler that implements
com.calypso.engine.advice.IMessageIdentifier to customize MessageIdentifier.
This class is invoked from com.calypso.engine.advice.MessageEngine.
|
|
How to Customize SWIFT Messages | 7.4 How to Customize SWIFT Messages
SWIFT messages can be generated from an XML template using SWIFTFormatter.
|
|
Using SWIFTFormatter | 7.4.1 Using SWIFTFormatter
Creating a Custom SWIFTFormatter
Create a class named tk.bo.swift.<name>SWIFTFormatter that extends
com.calypso.tk.bo.swift.SWIFTFormatter.
The name should be the name of the template (MT360 for example).
SWIFTFormatter is invoked from com.calypso.tk.bo.SWIFTFormatterUtil.
By default, the XML templates should be placed in templates/swift.
You can customize the location of the template using the method getFileStream().
Creating a Custom Iterator to Populate Repeated Information
Create a class named tk.bo.swift.<name>Iterator or tk.bo.swift.<name> that implements the
interface java.util.Iterator.
The SWIFTFormatter can access the iterator count and the iterator object, and behave as applicable.
Creating a Custom Header Block
Create a class named tk.bo.swift.SwiftTextCustomizer that implements the interface
com.calypso.tk.bo.swift.SwiftTextInterface.
Sample Code in calypsox/tk/bo/swift/
SwiftTextCustomizer.java
|
|
Applying Custom Validation to SWIFT Messages | 7.4.2 Applying Custom Validation to SWIFT Messages
Create a class named tk.bo.swift.CustomSwiftMessageValidator that implements the interface
com.calypso.tk.bo.swift.SwiftMessageValidator.
CustomSwiftMessageValidator is invoked by com.calypso.tk.bo.swift.SwiftMessage before the
message is saved.
|
|
Customizing IsFinancial in SWIFT Messages | 7.4.3 Customizing IsFinancial in SWIFT Messages
Create a class named tk.bo.swift.CustomSwiftUtilInterface that extends
com.calypso.tk.bo.swift.DefaultSwiftUtilInterface.
• Method – getIsFinancial: This method determines whether or not the provided Legal Entity is a
financial organization.
• Input:
− LegalEntity le — The Legal Entity
− BOMessage message — Future use
• Returns:
− True — The Legal Entity is a financial organization.
− False — The Legal Entity is not a financial organization.
• Usage - Boolean getIsFinancial(BOMessage message, LegalEntity le)
This method is typically used to get the value of the isFinancial variable.
|
|
Customizing EntityInfo for SWIFT Messages | 7.4.4 Customizing EntityInfo for SWIFT Messages
Create a class named tk.bo.swift.CustomEntityInfo that implements
com.calypso.tk.bo.swift.EntityInfo.
CustomEntityInfo is invoked by com.calypso.tk.bo.swift.SwiftUtil.
|
|
How to Customize the Sender Engine | 7.5 How to Customize the Sender Engine
The Sender engine uses DocumentSender objects to physically transmit message documents to a
given address method or gateway. Calypso provides EMAILDocumentSender to send documents via
e-mail. Address methods are stored in the “addressMethod” domain.
[NOTE: When sending Advice Messages, users must strip the message prior to calling the
send() method]
Creating a Custom Document Sender
Create a class named tk.bo.document.<address_method>DocumentSender,
tk.bo.document.Gateway<gateway>DocumentSender, or
tk.bo.document.<address_method>Gateway<gateway>DocumentSender, that implements the
com.calypso.tk.bo.document.DocumentSender interface.
The DocumentSender is invoked by com.calypso.tk.bo.document.DocumentSenderUtil.
In your DocumentSender, create the send() method to send the message.
[NOTE: When dealing with an Advice message, you must first call
SwiftMessage.stripExtraInfo(AdviceDocument.getDocument()) to strip the message prior to
calling send()]
Generally the send() method initiates the physical production of the document via some output
mechanism such as a printer or email utility. The send() method must return a Boolean True if
successful, or if not, False. You must also define the isOnline() method. The Sender engine will query
this isOnline to ensure that the sender gateway system is online.
DocumentSender has the ability to also process a PSEventMessage event, in addition to sending an
Advice document. The following parameters of the send() method should be used as described below:
• saved — saved[0] should be true to indicate if the document was saved and the event
processed
• engineName — should be null to indicate that the Sender engine need not process the event
|
|
How to Customize the Accounting Engine | 7.6 How to Customize the Accounting Engine
The Accounting engine uses the following process to generate postings for various events (Trade,
Valuation, Liquidation, etc.) as applicable:
• The Accounting engine selects which accounting rule to apply using a mapping mechanism
between the events it subscribes to and the accounting rules configured in the system. It builds
a list of requested accounting events based on the selected accounting rule. The mapping
mechanism can be customized.
• For each accounting event, the Accounting engine calls a generic AccountingHandler to
specify how to generate the corresponding posting. AccountingHandler can call a specific
AccountingHandler for a given product type, or a specific AccountingEventHandler for a given
type of accounting event. The Accounting engine also allows adding custom attributes to the
generated postings.
The AccountingHandler calls methods in either DefaultFeeAccountingHandler or
CustomFeeAccountingHandler, if defined.
• Once all the postings have been created, a matching process occurs to compare a set of
criteria on the new postings and the old postings, and to generate reverse postings as
applicable. The matching mechanism can be customized.
|
|
Generating Fee-Related Postings | 7.6.1 Generating Fee-Related Postings
You can define a CustomFeeAccountingHandler that extends DefaultFeeAccountingHandler which
implements FeeAccountingHandler to support new fee-related event types, or to redefine existing
event types.
For a fee-related accounting event type such as PREMIUM, call the getFee() method. For an accounting
event type such as PREMIUM_AM, the use the getFeeAM() method.
The FeeAccountingHandler interface contains methods for the Calypso defined, fee-related events.
Method invocation is by reflection, therefore, you can add your own methods to your
CustomFeeAccountingHandler without changing the interface.
|
|
Creating a Custom Mapping Mechanism to an Accounting Rule | 7.6.2 Creating a Custom Mapping Mechanism to an Accounting Rule
Create a class named engine.accounting.CustomAccountingRuleSelector that implements the
interface com.calypso.engine.accounting.AccountingRuleSelector.
CustomAccountingRuleSelector is invoked from
com.calypso.engine.accounting.AccountingEngine to select an accounting rule.
|
|
Creating a Custom Product Accounting Handler | 7.6.3 Creating a Custom Product Accounting Handler
Create a class named tk.bo.accounting.<product_type>AccountingHandler or
tk.bo.accounting.<product_family>AccountingHandler which extends
com.calypso.tk.bo.accounting.AccountingHandler.
The AccountingHandler should have a get<accounting event type>() method for each accounting
event type that it will calculate. Accounting event types are listed in the “accEventType” domain. The
set of accounting event types that your system will calculate is established in the
AccountingEventConfig objects for a given Accounting Rule. For example, getCOT() calculates a COT
accounting event.
A custom product AccountingHandler is invoked from
com.calypso.tk.bo.accounting.AccountingHandler to generate a posting for a given product type
or family type.
|
|
Creating a Custom Event Accounting Handler | 7.6.4 Creating a Custom Event Accounting Handler
Create a class named tk.bo.accounting.<event_type>AccountingHandler that implements the
interface com.calypso.tk.bo.accounting.EventAccountingHandler.
A custom event AccountingHandler is invoked from
com.calypso.tk.bo.accounting.AccountingHandler to generate a posting for a given type of
accounting event.
|
|
Creating a Custom Posting Description | 7.6.5 Creating a Custom Posting Description
Create a class named engine.accounting.CustomFillPostingDescription that implements the
interface com.calypso.engine.accounting.FillPostingDescription. You can implement
fillDescription() for adding attributes and fillPostingDates() for customizing the dates set on the
posting: booking date and effective date.
You can implement fillDescription to return a string value for the posting the description field;
fillPostingDates for setting custom booking and effective dates; setPostingStatus to set a custom
posting status, and sort to order the postings prior to saving them in the database (e.g., in case a
downstream process dependent on the order of cancel/new events).
CustomFillPostingDescription is invoked from com.calypso.engine.accounting.AccountingEngine
to customize the content of the postings.
|
|
Creating a Custom Accounting Matching Mechanism | 7.6.6 Creating a Custom Accounting Matching Mechanism
Create a class named engine.accounting.<product_type>AccountingMatching or
engine.accounting.DefaultAccountingMatching that implements the interface
com.calypso.engine.accounting.AccountingMatching.
AccountingMatching is invoked from com.calypso.engine.accounting.AccountingMatchingUtil
when matching old postings and new postings for generating reverse postings if applicable.
|
|
Creating a Custom Account Keyword for Automatic Accounts | 7.6.7 Creating a Custom Account Keyword for Automatic Accounts
Create a class named tk.bo.accounting.keyword.<keyword>AccountKeyword which implements the
interface com.calypso.tk.bo.accounting.keyword.AccountKeyword.
AccountKeyword is invoked from com.calypso.tk.bo.accounting.keyword.KeywordUtil.
Then register the <keyword> in the attributeType domain. For example, for
calypsox/tk/bo/accounting/keyword/IBANAccountKeyword.java, you must register IBAN in the
“attributeType” domain.
|
|
Applying Custom Validation to Accounting Rules | 7.6.8 Applying Custom Validation to Accounting Rules
Create a class named apps.refdata.CustomAccRuleValidator which implements the interface
com.calypso.apps.refdata.AccRuleValidator.
CustomAccRuleValidator is invoked from com.calypso.apps.refdata.AccountingRuleFrame prior to
saving an accounting rule.
|
|
Apply Custom Validation to Account Interest | 7.6.9 Apply Custom Validation to Account Interest
Create a class named apps.refdata.CustomAccountInterestConfigValidator that implements
com.calypso.apps.refdata.AccountInterestConfigValidator.
AccountInterestConfigValidator is invoked from
com.calypso.apps.refdata.AccountInterestConfigWindow.
|
|
Apply Custom Validation to Manual Postings | 7.6.10Apply Custom Validation to Manual Postings
Create a class named tk.bo.accounting.CustomManualPostingValidator that implements
com.calypso.tk.bo.accounting.ManualPostingValidator.
ManualPostingValidator is invoked from com.calypso.apps.reporting.EditPostingWindow and
com.calypso.apps.reporting.EditMultiplePostingsWindow.
|
|
Applying a Custom Filter to Account Postings | 7.6.11Applying a Custom Filter to Account Postings
Create a class named engine.accounting.CustomAccountingFilterEvent or multiple classes named
engine.accounting.<Name>AccountingFilterEvent, each implementing
com.calypso.tk.bo.accounting.AccountingFilterEventInterface. When using multiple classes,
define each <Name> in the “CustomAccountingFilterEvent” domain.
AccountingFilterEvent is invoked from com.calypso.engine.accounting.AccountingEngine.
|
End of preview. Expand
in Data Studio
No dataset card yet
- Downloads last month
- 2