Package com.caplin.motif
Class TradeAdapter
- java.lang.Object
-
- com.caplin.motif.TradeAdapter
-
- Direct Known Subclasses:
TradeAdapter
public class TradeAdapter extends java.lang.Object
A Trade adapter allows for listeners to listen and receive events when a trade has been initiated for a particular trade protocol.
-
-
Field Summary
Fields Modifier and Type Field Description protected com.caplin.datasource.DataSource
dataSource
-
Constructor Summary
Constructors Constructor Description TradeAdapter(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 java.util.Properties properties)
Constructs the TradeAdapter that will utilise the specified DataSource and its configuration for communication with the motif.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addTradeChannelSessionListener(TradeChannelSessionListener listener)
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
getDataSource()
Returns the DataSource contained by this TradeAdapter.void
registerTradeListenerFactory(java.lang.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.
-
-
-
Constructor Detail
-
TradeAdapter
public TradeAdapter(com.caplin.datasource.DataSource dataSource, ThreadMode threadMode) throws java.io.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:
java.io.IOException
- If an error occurred reading configuration files for the adapter.
-
TradeAdapter
public TradeAdapter(com.caplin.datasource.DataSource dataSource, ThreadMode threadMode, @NotNull @NotNull java.util.Properties properties) throws java.io.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:
java.io.IOException
- If an error occurred reading configuration files for the adapter.
-
TradeAdapter
@Deprecated public TradeAdapter(com.caplin.datasource.DataSource dataSource) throws java.io.IOException
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:
java.io.IOException
- If an error occurred reading configuration files for the adapter.
-
-
Method Detail
-
registerTradeListenerFactory
public void registerTradeListenerFactory(java.lang.String protocol, TradeListenerFactory listener)
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
public void addUserSessionListener(UserSessionListener listener)
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
public void removeUserSessionListener(UserSessionListener listener)
Removes a listener UserSessionListener to stop receiving session events.- Parameters:
listener
- the listener to be removed from receiving session lifecycle events.
-
addTradeChannelSessionListener
public void addTradeChannelSessionListener(TradeChannelSessionListener listener)
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.
-
-