Class NotificationChannelImpl

java.lang.Object
com.caplin.datasource.notification.impl.NotificationChannelImpl
All Implemented Interfaces:
com.caplin.container.impl.cache.CacheMissListener, NotificationChannel

@JMXBean public class NotificationChannelImpl extends Object implements NotificationChannel, com.caplin.container.impl.cache.CacheMissListener
  • Constructor Details

    • NotificationChannelImpl

      public NotificationChannelImpl(com.caplin.container.impl.Runtime runtime, String username, com.caplin.container.impl.managedcontainer.NestableContainer notificationsContainer, NotificationConfiguration configuration)
  • Method Details

    • sendNotifications

      public void sendNotifications(List<Notification> notifications)
      Description copied from interface: NotificationChannel

      Adds Notifications to the internal cache and sends a container add so that these items are requested when the channel is subscribed to.

      If any items with the same unique id already exists in the internal cache then these items fields will be updated with these one. This will then trigger an update for any users currently subscribed to these items.

      Specified by:
      sendNotifications in interface NotificationChannel
      Parameters:
      notifications - to send
    • sendNotification

      public void sendNotification(Notification notification)
      Description copied from interface: NotificationChannel

      Adds the Notification to the internal cache and sends a container add so that this notification is requested when the channel is subscribed to.

      If an notification with the same unique id already exists in the internal cache then that item's fields will be updated with this one's. This will then trigger an update for any users currently subscribed to this item.

      Specified by:
      sendNotification in interface NotificationChannel
      Parameters:
      notification - to send
    • onCacheMiss

      public void onCacheMiss(String subject)
      Specified by:
      onCacheMiss in interface com.caplin.container.impl.cache.CacheMissListener
    • sendNotificationStatusOk

      public void sendNotificationStatusOk(String uniqueId)
      Description copied from interface: NotificationChannel

      Send status ok for a Notification.

      Under normal circumstances this method is not used.

      Specified by:
      sendNotificationStatusOk in interface NotificationChannel
      Parameters:
      uniqueId - of the message whose status is OK
    • sendNotificationStatusStale

      public void sendNotificationStatusStale(String uniqueId)
      Description copied from interface: NotificationChannel

      Send status stale for a Notification.

      Under normal circumstances this method is not used.

      Specified by:
      sendNotificationStatusStale in interface NotificationChannel
      Parameters:
      uniqueId - of the message whose status is STALE
    • sendNotificationNotFound

      public void sendNotificationNotFound(String uniqueId)
      Description copied from interface: NotificationChannel

      Sends a not found for a Notification.

      Specifically for the case where there is more than one NotificationProvider.

      Sent in response to a NotificationChannelListener.onNotificationRequest(com.caplin.datasource.notification.NotificationChannel, java.lang.String) when the item requested is not serviceable by your application.

      Specified by:
      sendNotificationNotFound in interface NotificationChannel
      Parameters:
      uniqueId - of item that cannot be serviced by your application.
    • sendNotificationContainerStatusOk

      public void sendNotificationContainerStatusOk()
      Description copied from interface: NotificationChannel

      Sends a status ok on the channel.

      Under normal circumstances this method is not used.

      Specified by:
      sendNotificationContainerStatusOk in interface NotificationChannel
    • sendNotificationContainerStatusStale

      public void sendNotificationContainerStatusStale()
      Description copied from interface: NotificationChannel

      Sends a status stale on the channel.

      Under normal circumstances this method is not used.

      Specified by:
      sendNotificationContainerStatusStale in interface NotificationChannel
    • sendEmptyNotificationContainer

      public void sendEmptyNotificationContainer()
      Description copied from interface: NotificationChannel

      Sends an empty container on the channel.

      Invoke when a NotificationApplicationListener.notificationChannelOpened(com.caplin.datasource.notification.NotificationChannel) callback is received and there are currently no Notifications to be added for the channel. I.e. A NotificationApplicationListener.notificationChannelOpened(com.caplin.datasource.notification.NotificationChannel) for a historic trade data NotificationChannel for a user who has not yet traded would be serviced with this method.

      Specified by:
      sendEmptyNotificationContainer in interface NotificationChannel
    • removeNotifications

      public void removeNotifications(List<String> uniqueIds)
      Description copied from interface: NotificationChannel

      Removes Notifications from the internal cache and sends a container remove so that these notifications are no longer requested when the channel is subscribed to.

      Specified by:
      removeNotifications in interface NotificationChannel
      Parameters:
      uniqueIds - of the items to remove
    • removeNotification

      public void removeNotification(String uniqueId)
      Description copied from interface: NotificationChannel

      Removes the Notification from the internal cache and sends a container remove so that this notification is no longer requested when the channel is subscribed to.

      Specified by:
      removeNotification in interface NotificationChannel
      Parameters:
      uniqueId - of the item to remove
    • callbackChannelListener

      public void callbackChannelListener(String uniqueId, String action)
    • setNotificationChannelListener

      public void setNotificationChannelListener(NotificationChannelListener listener)
      Description copied from interface: NotificationChannel

      Your application SHOULD set a NotificationChannelListener on the channel. On this listener, your application will receive callbacks on requests for Notifications not in the cache and when a front-end client sends actions in response to the notification.

      See NotificationConfiguration for information about having a distributed notification provision, the scenario where a request could come in for an item not in cache.

      Specified by:
      setNotificationChannelListener in interface NotificationChannel
      Parameters:
      listener - to receive requests for items not already cached by the NotificationAPI
    • onIncrement

      public void onIncrement(int change)
    • onDecrement

      public void onDecrement(int change)
    • setControlChannelOpen

      public void setControlChannelOpen(boolean controlChannelOpen)
    • setContainerRequested

      public void setContainerRequested(boolean containerRequested)
    • controlChannelOpen

      public boolean controlChannelOpen()
    • containerRequested

      public boolean containerRequested()
    • closeable

      public boolean closeable()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • closeChannel

      @JMXBeanOperation(name="close-notification-channel", description="Close notification channel") public void closeChannel()
      Description copied from interface: NotificationChannel

      Closes the channel.

      Sends a Subject Not Found on the channel's subject to let subscribers know that it is no longer serviced.

      Specified by:
      closeChannel in interface NotificationChannel
    • getItemSubjects

      @JMXBeanAttribute(name="notification-subjects", description="Notification subjects") public List<String> getItemSubjects()
    • getItemCount

      @JMXBeanAttribute(name="notification-count", description="Number of items associated with this notification channel") public Long getItemCount()
    • getItemFields

      @JMXBeanOperation(name="get-notification-fields", description="Get notification fields by subject") public Map<String,String> getItemFields(@JMXBeanParameter(name="notification-subject",description="Subject of notification to get") String itemSubject)
    • getInstantiationTime

      @JMXBeanAttribute(name="instantiation-time", description="Time at which this notification channel was instantiated") public Date getInstantiationTime()
    • getUsername

      @JMXBeanAttribute(name="username", description="Username of the notification channel") public String getUsername()
      Description copied from interface: NotificationChannel

      Returns the username for the channel

      Specified by:
      getUsername in interface NotificationChannel
      Returns:
      username for the channel
    • getSubject

      @JMXBeanAttribute(name="subject", description="Subject of the notification channel") public String getSubject()
      Description copied from interface: NotificationChannel

      Returns the subject for the channel.

      Specified by:
      getSubject in interface NotificationChannel
      Returns:
      subject for the channel
    • getKey

      @JMXBeanKey public String getKey()
    • getNotificationCount

      public int getNotificationCount()