public class TradingProvider extends java.lang.Object implements ConnectionListener
All Trading DataSource applications must create an instance of this class. The class provides the following services.
TradeChannel
s over which trade messages flow.BlotterChannel
s over which blotter messages flow.
You must pass in a pre-configured instance of DataSource
to the constructor. The DataSource
is used for all Liberator communication.
Constructor and Description |
---|
TradingProvider(TradingApplicationListener listener,
DataSource dataSource)
Creates a
TradingProvider that uses, for Liberator communication, a preconfigured DataSource passed to the constructor. |
TradingProvider(TradingApplicationListener listener,
DataSource dataSource,
java.util.Properties properties)
Creates a
TradingProvider that uses, for Liberator communication, a preconfigured DataSource passed to the constructor. |
Modifier and Type | Method and Description |
---|---|
void |
addBlotterTradeListener(BlotterChannel blotterChannel,
BlotterTradeListener listener)
Registers the provided listener to receive auto-generated trade lifecycle blotter events for matching trades.
|
Trade |
createTrade(TradeChannel tradeChannel,
java.lang.String tradingProtocol)
Creates a new Trade and restores it to the specified channel, setting the requestId to a generated value.
|
DataSource |
getDataSource()
The underlying DataSource object that is used for communication with the Liberator.
|
void |
logTradingSystemMessage(java.util.logging.Level level,
java.lang.String message)
Log a message to the TradingProvider message logger.
|
void |
onPeerStatus(PeerStatusEvent peerStatusEvent)
Invoked when a DataSource peer changes state.
|
void |
removeBlotterTradeListener(BlotterChannel blotterChannel,
BlotterTradeListener listener)
De-registers the provided listener from receiving auto-generated trade lifecycle blotter events.
|
void |
terminate()
Closes all channels and cleans up all trades.
|
public TradingProvider(TradingApplicationListener listener, DataSource dataSource) throws java.lang.NullPointerException, java.lang.IllegalArgumentException, java.io.IOException
TradingProvider
that uses, for Liberator communication, a preconfigured DataSource
passed to the constructor.listener
- An implementation of TradingApplicationListener
. The listener is notified of TradeChannel
and BlotterChannel
lifecycle events.dataSource
- A preconfigured DataSource
that this TradingProvider
uses to communicate with Liberator. For a description of the DataSource
class, see the DataSource for Java API Reference.java.lang.NullPointerException
- if no state models have been specified in the trading properties file supplied to the DataSource
.java.io.IOException
- if an error occurs while processing the trading properties file.java.lang.IllegalArgumentException
public TradingProvider(TradingApplicationListener listener, DataSource dataSource, java.util.Properties properties) throws java.lang.NullPointerException, java.lang.IllegalArgumentException, java.io.IOException
TradingProvider
that uses, for Liberator communication, a preconfigured DataSource
passed to the constructor.listener
- An implementation of TradingApplicationListener
. The listener is notified of TradeChannel
and BlotterChannel
lifecycle events.dataSource
- A preconfigured DataSource
that this TradingProvider
uses to communicate with Liberator. For a description of the DataSource
class, see the DataSource for Java API Reference.properties
- A property object that will be used to configure the provider. If the value is null then the datasource property
trading-property-file will be checked for a property file location to be used for the configuration.java.lang.NullPointerException
- if no state models have been specified in the trading properties file supplied to the DataSource
.java.io.IOException
- if an error occurs while processing the trading properties file.java.lang.IllegalArgumentException
public void logTradingSystemMessage(java.util.logging.Level level, java.lang.String message)
level
- The level to log.message
- The message to log to the standard log - will be prefixed in the log file with "Trading System Message:"public void terminate()
public Trade createTrade(TradeChannel tradeChannel, java.lang.String tradingProtocol) throws TradeException
tradeChannel
- the TradeChannel to create the new trade ontradingProtocol
- the protocol for this tradeTradeException
- if there was a problem creating the Trade or restoring it to the provided TradeChannelpublic DataSource getDataSource()
public void addBlotterTradeListener(BlotterChannel blotterChannel, BlotterTradeListener listener)
Any trades that occur on any TradeChannel that open to a user that matches the BlotterChannel.getUserName()
will have blotter events automatically sent to the provided listener as they occur.
Currently only a single listener can be registered per-channel.
This method is usually called as a result of a TradingApplicationListener.blotterChannelCreated(BlotterChannel)
callback.
blotterChannel
- The blotter channel that should be used to match trades that should have blotter events sent to the listener.listener
- the BlotterTradeListener that should receive auto-generated blotter events.public void removeBlotterTradeListener(BlotterChannel blotterChannel, BlotterTradeListener listener)
This method is usually called as a result of a TradingApplicationListener.blotterChannelClosed(BlotterChannel)
callback.
blotterChannel
- the blotter channel that was used to register the listenerlistener
- the listener that should no longer receive auto-generated blotter events.public void onPeerStatus(PeerStatusEvent peerStatusEvent)
ConnectionListener
onPeerStatus
in interface ConnectionListener
peerStatusEvent
- An event containing information about the change in the peer's state.Please send bug reports and comments to Caplin support