Class TradeAdapter

  • Direct Known Subclasses:
    TradeAdapter

    public class TradeAdapter
    extends Object
    A Trade adapter allows for listeners to listen and receive events when a trade has been initiated for a particular trade protocol.
    • Field Detail

      • dataSource

        protected final com.caplin.datasource.DataSource dataSource
    • Constructor Detail

      • 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 the TradingProvider
        Throws:
        IOException - If an error occurred reading configuration files for the adapter.
      • TradeAdapter

        @Deprecated
        public TradeAdapter​(com.caplin.datasource.DataSource dataSource)
                     throws IOException
        Constructs the TradeAdapter that will utilise the specified DataSource and its configuration for communication with the motif.

        Uses a default ThreadMode of ThreadMode.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 Detail

      • registerTradeListenerFactory

        public void registerTradeListenerFactory​(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.