Class NotificationChannelImpl
- All Implemented Interfaces:
com.caplin.container.impl.cache.CacheMissListener,NotificationChannel
-
Constructor Summary
ConstructorsConstructorDescriptionNotificationChannelImpl(com.caplin.container.impl.Runtime runtime, String username, com.caplin.container.impl.managedcontainer.NestableContainer notificationsContainer, NotificationConfiguration configuration) -
Method Summary
Modifier and TypeMethodDescriptionvoidcallbackChannelListener(String uniqueId, String action) booleanvoidCloses the channel.booleanbooleangetItemFields(String itemSubject) getKey()intReturns the subject for the channel.Returns the username for the channelvoidonCacheMiss(String subject) voidonDecrement(int change) voidonIncrement(int change) voidremoveNotification(String uniqueId) Removes theNotificationfrom the internal cache and sends a container remove so that this notification is no longer requested when the channel is subscribed to.voidremoveNotifications(List<String> uniqueIds) RemovesNotifications from the internal cache and sends a container remove so that these notifications are no longer requested when the channel is subscribed to.voidSends an empty container on the channel.voidsendNotification(Notification notification) Adds theNotificationto the internal cache and sends a container add so that this notification is requested when the channel is subscribed to.voidSends a status ok on the channel.voidSends a status stale on the channel.voidsendNotificationNotFound(String uniqueId) Sends a not found for aNotification.voidsendNotifications(List<Notification> notifications) AddsNotifications to the internal cache and sends a container add so that these items are requested when the channel is subscribed to.voidsendNotificationStatusOk(String uniqueId) Send status ok for aNotification.voidsendNotificationStatusStale(String uniqueId) Send status stale for aNotification.voidsetContainerRequested(boolean containerRequested) voidsetControlChannelOpen(boolean controlChannelOpen) voidYour application SHOULD set aNotificationChannelListeneron the channel.toString()
-
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
Description copied from interface:NotificationChannelAdds
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:
sendNotificationsin interfaceNotificationChannel- Parameters:
notifications- to send
-
sendNotification
Description copied from interface:NotificationChannelAdds the
Notificationto 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:
sendNotificationin interfaceNotificationChannel- Parameters:
notification- to send
-
onCacheMiss
- Specified by:
onCacheMissin interfacecom.caplin.container.impl.cache.CacheMissListener
-
sendNotificationStatusOk
Description copied from interface:NotificationChannelSend status ok for a
Notification.Under normal circumstances this method is not used.
- Specified by:
sendNotificationStatusOkin interfaceNotificationChannel- Parameters:
uniqueId- of the message whose status is OK
-
sendNotificationStatusStale
Description copied from interface:NotificationChannelSend status stale for a
Notification.Under normal circumstances this method is not used.
- Specified by:
sendNotificationStatusStalein interfaceNotificationChannel- Parameters:
uniqueId- of the message whose status is STALE
-
sendNotificationNotFound
Description copied from interface:NotificationChannelSends 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:
sendNotificationNotFoundin interfaceNotificationChannel- Parameters:
uniqueId- of item that cannot be serviced by your application.
-
sendNotificationContainerStatusOk
public void sendNotificationContainerStatusOk()Description copied from interface:NotificationChannelSends a status ok on the channel.
Under normal circumstances this method is not used.
- Specified by:
sendNotificationContainerStatusOkin interfaceNotificationChannel
-
sendNotificationContainerStatusStale
public void sendNotificationContainerStatusStale()Description copied from interface:NotificationChannelSends a status stale on the channel.
Under normal circumstances this method is not used.
- Specified by:
sendNotificationContainerStatusStalein interfaceNotificationChannel
-
sendEmptyNotificationContainer
public void sendEmptyNotificationContainer()Description copied from interface:NotificationChannelSends an empty container on the channel.
Invoke when a
NotificationApplicationListener.notificationChannelOpened(com.caplin.datasource.notification.NotificationChannel)callback is received and there are currently noNotifications to be added for the channel. I.e. ANotificationApplicationListener.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:
sendEmptyNotificationContainerin interfaceNotificationChannel
-
removeNotifications
Description copied from interface:NotificationChannelRemoves
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:
removeNotificationsin interfaceNotificationChannel- Parameters:
uniqueIds- of the items to remove
-
removeNotification
Description copied from interface:NotificationChannelRemoves the
Notificationfrom the internal cache and sends a container remove so that this notification is no longer requested when the channel is subscribed to.- Specified by:
removeNotificationin interfaceNotificationChannel- Parameters:
uniqueId- of the item to remove
-
callbackChannelListener
-
setNotificationChannelListener
Description copied from interface:NotificationChannelYour application SHOULD set a
NotificationChannelListeneron 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
NotificationConfigurationfor information about having a distributed notification provision, the scenario where a request could come in for an item not in cache.- Specified by:
setNotificationChannelListenerin interfaceNotificationChannel- 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
-
closeChannel
@JMXBeanOperation(name="close-notification-channel", description="Close notification channel") public void closeChannel()Description copied from interface:NotificationChannelCloses the channel.
Sends a Subject Not Found on the channel's subject to let subscribers know that it is no longer serviced.
- Specified by:
closeChannelin interfaceNotificationChannel
-
getItemSubjects
-
getItemCount
@JMXBeanAttribute(name="notification-count", description="Number of items associated with this notification channel") public Long getItemCount() -
getItemFields
-
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:NotificationChannelReturns the username for the channel
- Specified by:
getUsernamein interfaceNotificationChannel- Returns:
- username for the channel
-
getSubject
@JMXBeanAttribute(name="subject", description="Subject of the notification channel") public String getSubject()Description copied from interface:NotificationChannelReturns the subject for the channel.
- Specified by:
getSubjectin interfaceNotificationChannel- Returns:
- subject for the channel
-
getKey
-
getNotificationCount
public int getNotificationCount()
-