Interface TradeChannel
-
- All Superinterfaces:
java.io.Serializable
public interface TradeChannel extends java.io.Serializable
An open trade messaging communications channel with an end user.The TradeChannel encapsulates a subscription by a client to the TradingDataSource. It provides a bi-directional channel allowing messages to be sent by both client and the TradingDataSource.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Trade
createTrade(java.lang.String tradingProtocol)
java.util.List<Trade>
getAllTrades()
Gets all the trades that this channel is currently managing.java.lang.String
getName()
Gets the name of the channelint
getPeerIndex()
Get the index of the peer connection that is managing this TradeChannel.Trade
getTrade(java.lang.String requestId)
Gets a Trade associated with this TradeChannel.TradeChannelListener
getTradeChannelListener()
Gets the ChannelListener that is set on this TradeChannel.java.lang.String
getUser()
Gets the username of the user represented by this channelTrade
restoreTrade(java.lang.String assetClass, java.lang.String tradeProtocol, java.lang.String restorationId)
Creates a trade object to faciliate restoration of a trade with a client.void
sendSubjectStatus(java.lang.String statusMessage, com.caplin.datasource.SubjectStatus subjectStatus)
Send a status message via the underlying channel for the subjectvoid
setTradeChannelListener(TradeChannelListener listener)
Sets the ChannelListener for this TradeChannel.
-
-
-
Method Detail
-
getUser
java.lang.String getUser()
Gets the username of the user represented by this channel- Returns:
- The username.
-
sendSubjectStatus
void sendSubjectStatus(java.lang.String statusMessage, com.caplin.datasource.SubjectStatus subjectStatus)
Send a status message via the underlying channel for the subject- Parameters:
statusMessage
- the statusMessage to sendsubjectStatus
- the subjectStatus to send
-
getName
java.lang.String getName()
Gets the name of the channel- Returns:
- The channel name.
-
getPeerIndex
int getPeerIndex()
Get the index of the peer connection that is managing this TradeChannel.- Returns:
- the 0-based index of the peer that is managing this trade channel, based on configuration order.
-
setTradeChannelListener
void setTradeChannelListener(TradeChannelListener listener)
Sets the ChannelListener for this TradeChannel. The ChannelListener will be notified when new Trades are initiated by the client this TradeChannel represents. The ChannelListener will also be notified of closed Trades.- Parameters:
listener
- The ChannelListener.
-
getTradeChannelListener
TradeChannelListener getTradeChannelListener()
Gets the ChannelListener that is set on this TradeChannel.- Returns:
- the ChannelListener that is set on this channel, or null if no listener is set.
-
getTrade
Trade getTrade(java.lang.String requestId)
Gets a Trade associated with this TradeChannel. A TradeChannel might contain a number of Trades concurrently being handled. This method allows a single Trade to be obtained referenced by its requestId.- Parameters:
requestId
- The RequestId for the Trade.- Returns:
- The Trade object.
-
getAllTrades
java.util.List<Trade> getAllTrades()
Gets all the trades that this channel is currently managing.- Returns:
- a List containing all the currently active trades. This list is a copy of the trades at the time the call is made and there is no guarantee that the trades are still active when iterating over the list.
-
restoreTrade
Trade restoreTrade(java.lang.String assetClass, java.lang.String tradeProtocol, java.lang.String restorationId) throws TradeException
Creates a trade object to faciliate restoration of a trade with a client. Once the trade has been created, a restore event should be created via an invocation to
Trade.createRestoreEvent(String)
.To allow for trades to be restored on the client,
TradeEvent.setRestorationId(String)
should be invoked on the first message sent to the client when it opens a trade. If the connection between the client and the Trading DataSource is lost and then re-established, the client will be able to identify the trade restoration message via the restorationId passed as an argument to this method.- Parameters:
assetClass
- The asset class of the trade, e.g FX or FI.tradeProtocol
- The trade protocol. This must be the name of the state model.restorationId
- The system identifier for the trade.- Returns:
- The restored trade.
- Throws:
TradeException
- Thrown if the trade would be in an invalid state.- See Also:
TradeEvent.setRestorationId(String)
-
createTrade
Trade createTrade(java.lang.String tradingProtocol) throws TradeException
- Throws:
TradeException
-
-