Skip to content

Debugging BRJS using the FXTrader app within CaplinTrader

Dominic Chambers edited this page Apr 24, 2015 · 5 revisions

If you'd like to debug BRJS using the FXTrader app within CaplinTrader, you can do so by cloning the CaplinTrader repository. Run a gradlew assemble from your CT folder and then run these commands from within the BRJS repository:

cd brjs-sdk
ct-clone <path-to-your-ct-repository>

where ct-clone is a script you can add to your path, having the following contents:

#!/bin/bash

CT=$1
currentDir=${PWD##*/}

if [ $currentDir != "brjs-sdk" ]; then
    echo "You must be in the brjs-sdk directory when you run this command!";
    echo "";
    exit;
fi

if [ -z "$CT" ]; then
    echo "Usage: ct-clone <path-to-your-ct-repository>";
    echo "";
    exit;
fi

if [ ! -d "sdk/libs/java" ]; then
    echo "You need to have run 'gradlew assemble' within BRJS before running this script.";
    echo "";
    exit;
fi

if [ ! -f $CT/ct-core/conf/users.properties ]; then
    echo "You have to have started the server inside '$CT' before running this script.";
    echo "";
    exit;
fi


# Copy the app:
rm -rf brjs-apps/*
cp -a $CT/ct-core/apps/fxtrader brjs-apps

if [ ! -d "brjs-apps/fxtrader/WEB-INF/lib" ]; then
    echo "Could not locate the 'libs' directory for the imported fxtrader app at 'brjs-apps/fxtrader/WEB-INF/lib'";
    echo "";
    exit;
fi

# Replace the servlet jar in 'WEB-INF/lib':
rm brjs-apps/fxtrader/WEB-INF/lib/brjs-servlet-*
cp sdk/libs/java/application/brjs-servlet-* brjs-apps/fxtrader/WEB-INF/lib

# Copy the JavaScript libraries:
cp -a $CT/ct-core/sdk/libs/javascript/{ct-*,caplin-*,sljs*,highstock} sdk/libs/javascript/

# Copy the Java system libraries:
cp -a $CT/ct-core/sdk/libs/java/system/ct-* sdk/libs/java/system

# Copy the conf:
cp -a $CT/ct-core/conf/{users.properties,keymaster} conf

# Make 'br-bootstrap' depend on 'caplin-bootstrap':
if [ `grep -c "caplin-bootstrap" sdk/libs/javascript/br-bootstrap/thirdparty-lib.manifest` -eq 0 ]; then
    echo "Now manually update 'sdk/libs/javascript/br-bootstrap/thirdparty-lib.manifest' so that 'br-bootstrap' depends on 'caplin-bootstrap'"
    echo "";
fi

From your sdk folder, run a brjs help command to generate the CT-specific conf files. If the files bundleConfig.xml and users.properties have not been created in brjs-sdk/conf, copy them manually from ct-core/sdk/templates/brjs-template/conf.

Make sure that the content of the users.properties matches the following:

# usernames and passwords for the built in Jetty server
# format is: <username>
user: password,user
user1@caplin.com: password,user

Afterwards add the following to the web.xml of your newly created fxtrader app:

<security-constraint>
    <web-resource-collection>
        <web-resource-name>Application</web-resource-name>
        <url-pattern>/*</url-pattern>
    </web-resource-collection>
    <auth-constraint>
        <role-name>user</role-name>
    </auth-constraint>
</security-constraint>

<security-constraint>
    <web-resource-collection>
        <web-resource-name>Login Section</web-resource-name>
        <url-pattern>/login/*</url-pattern>
    </web-resource-collection>
</security-constraint>
Clone this wiki locally