Skip to content

Debugging BRJS using the FXTrader app within CaplinTrader

Ioana Balas edited this page Feb 13, 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/workspace
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 != "workspace" ]; then
	echo "You must be in the workspace directory when you run this command!";
	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 apps/*
cp -a $CT/ct-core/apps/fxtrader apps

# Replace the servlet jar in 'WEB-INF/lib':
rm apps/fxtrader/WEB-INF/lib/brjs-servlet-*
cp sdk/libs/java/application/brjs-servlet-* 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