Package com.caplin.motif
Class TradeAdapter
java.lang.Object
com.caplin.motif.TradeAdapter
- Direct Known Subclasses:
TradeAdapter
A Trade adapter allows for listeners to listen and receive events when a trade
has been initiated for a particular trade protocol.
-
Field Summary
-
Constructor Summary
ConstructorDescriptionTradeAdapter
(com.caplin.datasource.DataSource dataSource) Deprecated.TradeAdapter
(com.caplin.datasource.DataSource dataSource, ThreadMode threadMode) Constructs the TradeAdapter that will utilise the specified DataSource and its configuration for communication with the motif.TradeAdapter
(com.caplin.datasource.DataSource dataSource, ThreadMode threadMode, @NotNull Properties properties) Constructs the TradeAdapter that will utilise the specified DataSource and its configuration for communication with the motif. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Registers a listener that will be called when the trade channel opens or closesvoid
addUserSessionListener
(UserSessionListener listener) Adds a listener that will be notified whenever a user session is created and closed.com.caplin.datasource.DataSource
Returns the DataSource contained by this TradeAdapter.void
registerTradeListenerFactory
(String protocol, TradeListenerFactory listener) Registers a TradeListenerFactory that will be notified when a trade with the specified protocol has been initiated.void
removeUserSessionListener
(UserSessionListener listener) Removes a listener UserSessionListener to stop receiving session events.
-
Field Details
-
dataSource
protected final com.caplin.datasource.DataSource dataSource
-
-
Constructor Details
-
TradeAdapter
public TradeAdapter(com.caplin.datasource.DataSource dataSource, ThreadMode threadMode) throws IOException Constructs the TradeAdapter that will utilise the specified DataSource and its configuration for communication with the motif.- Parameters:
dataSource
- The DataSource that will be used to receive requests for ESP and RFS trades.threadMode
- The thread mode to use for trades being made through the Adapter.- Throws:
IOException
- If an error occurred reading configuration files for the adapter.
-
TradeAdapter
public TradeAdapter(com.caplin.datasource.DataSource dataSource, ThreadMode threadMode, @NotNull @NotNull Properties properties) throws IOException Constructs the TradeAdapter that will utilise the specified DataSource and its configuration for communication with the motif.- Parameters:
dataSource
- The DataSource that will be used to receive requests for ESP and RFS trades.threadMode
- The thread mode to use for trades being made through the Adapter.properties
- The properties file to use when creating theTradingProvider
- Throws:
IOException
- If an error occurred reading configuration files for the adapter.
-
TradeAdapter
Deprecated.Constructs the TradeAdapter that will utilise the specified DataSource and its configuration for communication with the motif.Uses a default
ThreadMode
ofThreadMode.SharedThreads
- Parameters:
dataSource
- The DataSource that will be used to receive requests for ESP and RFS trades.- Throws:
IOException
- If an error occurred reading configuration files for the adapter.
-
-
Method Details
-
registerTradeListenerFactory
Registers a TradeListenerFactory that will be notified when a trade with the specified protocol has been initiated.- Parameters:
protocol
- The protocol of the trade to add the listener for. This should match the protocol specified in the trade model xml, for example, ESP or RFS.listener
- The listener that will be notified when a trade with the specified protocol has initiated.
-
addUserSessionListener
Adds a listener that will be notified whenever a user session is created and closed. Note that you can add multiple UserSessionListeners- Parameters:
listener
- the listener to be notified of session lifecycle events.
-
removeUserSessionListener
Removes a listener UserSessionListener to stop receiving session events.- Parameters:
listener
- the listener to be removed from receiving session lifecycle events.
-
addTradeChannelSessionListener
Registers a listener that will be called when the trade channel opens or closes- Parameters:
listener
- the listener to be added
-
getDataSource
public com.caplin.datasource.DataSource getDataSource()Returns the DataSource contained by this TradeAdapter.- Returns:
- the DataSource.
-
TradeAdapter(DataSource, ThreadMode)