Class
caplin.trading.trademodel

SL4BTradeMessageService

Extends SL4B_AbstractSubscriber.

implements caplin.trading.trademodel.TradeMessageService

The SL4BTradeMessageService is an implementation of a caplin.trading.trademodel.TradeMessageService that connects one or more caplin.trading.trademodel.Trade instances with SL4B. When a Trade is created, a new requestID is associated with it, and sent with all future messages to the server, so that messages back from the server can be associated with the appropriate Trade instance. Trades may be created or restored via server messages. These server messages can be identified by having a prefix, identified by #SERVER_REQUEST_ID_PREFIX, on their requestID. If the SL4BTradeMessageService receives a message for a trade that does not exist and the requestID has the required prefix a new caplin.trading.trademodel.Trade object is created if a oTradeFactory has been supplied to the constructor.

Constructor Summary

Attributes Name and Description
caplin.trading.trademodel.SL4BTradeMessageService(caplin.trading.trademodel.TradeChannelMapper oTradeChannelMapper, caplin.trading.trademodel.TradeFactory oTradeFactory)

Constructs a caplin.trading.trademodel.SL4BTradeMessageService.

Field Summary

Attributes Name and Description
<static> caplin.trading.trademodel.SL4BTradeMessageService.SERVER_REQUEST_ID_PREFIX

Prefix on a requestID that identifies a trade as originating from the server.

Method Summary

Attributes Name and Description
void addTrade(caplin.trading.trademodel.Trade oTrade)

void ready()

This method is called by SL4B when it is ready to receive subscriptions.

void removeTrade(caplin.trading.trademodel.Trade oTrade)

void sendTradeEvent(String sEventName, caplin.trading.trademodel.Trade oTrade, caplin.trading.trademodel.DataHolder oData)

This method is called by the Trade when it wishes to send some data to the server.

void tradeCompleted(caplin.trading.trademodel.Trade oTrade)

TradeCompleted is called when an update is received from the server that takes the trade into a final state (e.g.

Constructor Detail

caplin.trading.trademodel.SL4BTradeMessageService(caplin.trading.trademodel.TradeChannelMapper oTradeChannelMapper, caplin.trading.trademodel.TradeFactory oTradeFactory)

Constructs a caplin.trading.trademodel.SL4BTradeMessageService.

Parameters
caplin.trading.trademodel.TradeChannelMapper oTradeChannelMapper Maps a trade object onto a trade channel and provides a way to get a list of all the RTTP objects associated with trade channels. Must not be null.
caplin.trading.trademodel.TradeFactory oTradeFactory (Optional) A factory object used to create {@see caplin.trading.trademodel.Trade trades}.
Throws
caplin.core.Error
if oTradeChannelMapper is not an instance of caplin.trading.trademodel.TradeChannelMapper.

Field Detail

<static> String caplin.trading.trademodel.SL4BTradeMessageService.SERVER_REQUEST_ID_PREFIX

Prefix on a requestID that identifies a trade as originating from the server.

Method Detail

void ready()

This method is called by SL4B when it is ready to receive subscriptions. This method should only be called by SL4B. (this happens after initialise() is called on the superclass).

void sendTradeEvent(String sEventName, caplin.trading.trademodel.Trade oTrade, caplin.trading.trademodel.DataHolder oData)

This method is called by the Trade when it wishes to send some data to the server.

Parameters
String sEventName the event name that should be sent to the server. May not be null.
caplin.trading.trademodel.Trade oTrade the trade object. May not be null.
caplin.trading.trademodel.DataHolder oData the data that needs to be sent with this event. May not be null.
Throws
caplin.core.Error
if sEventName is null or of an incorrect type.
caplin.core.Error
if oTrade is null or of an incorrect type.
caplin.core.Error
if oData is null or of an incorrect type.
See
caplin.trading.trademodel.TradeMessageService.sendTradeEvent

void tradeCompleted(caplin.trading.trademodel.Trade oTrade)

TradeCompleted is called when an update is received from the server that takes the trade into a final state (e.g. trade completed or trade expired).

This method must not be called externally.

Parameters
caplin.trading.trademodel.Trade oTrade The trade that has just completed. May not be null.
Throws
caplin.core.Error
if oTrade is null or of an incorrect type.