Class NotificationChannelImpl
- All Implemented Interfaces:
com.caplin.container.impl.cache.CacheMissListener
,NotificationChannel
-
Constructor Summary
ConstructorDescriptionNotificationChannelImpl
(com.caplin.container.impl.Runtime runtime, String username, com.caplin.container.impl.managedcontainer.NestableContainer notificationsContainer, NotificationConfiguration configuration) -
Method Summary
Modifier and TypeMethodDescriptionvoid
callbackChannelListener
(String uniqueId, String action) boolean
void
Closes the channel.boolean
boolean
getItemFields
(String itemSubject) getKey()
int
Returns the subject for the channel.Returns the username for the channelvoid
onCacheMiss
(String subject) void
onDecrement
(int change) void
onIncrement
(int change) void
removeNotification
(String uniqueId) Removes theNotification
from the internal cache and sends a container remove so that this notification is no longer requested when the channel is subscribed to.void
removeNotifications
(List<String> uniqueIds) RemovesNotification
s from the internal cache and sends a container remove so that these notifications are no longer requested when the channel is subscribed to.void
Sends an empty container on the channel.void
sendNotification
(Notification notification) Adds theNotification
to the internal cache and sends a container add so that this notification is requested when the channel is subscribed to.void
Sends a status ok on the channel.void
Sends a status stale on the channel.void
sendNotificationNotFound
(String uniqueId) Sends a not found for aNotification
.void
sendNotifications
(List<Notification> notifications) AddsNotification
s to the internal cache and sends a container add so that these items are requested when the channel is subscribed to.void
sendNotificationStatusOk
(String uniqueId) Send status ok for aNotification
.void
sendNotificationStatusStale
(String uniqueId) Send status stale for aNotification
.void
setContainerRequested
(boolean containerRequested) void
setControlChannelOpen
(boolean controlChannelOpen) void
Your application SHOULD set aNotificationChannelListener
on 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:NotificationChannel
Adds
Notification
s 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 interfaceNotificationChannel
- Parameters:
notifications
- to send
-
sendNotification
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 interfaceNotificationChannel
- Parameters:
notification
- to send
-
onCacheMiss
- Specified by:
onCacheMiss
in interfacecom.caplin.container.impl.cache.CacheMissListener
-
sendNotificationStatusOk
Description copied from interface:NotificationChannel
Send status ok for a
Notification
.Under normal circumstances this method is not used.
- Specified by:
sendNotificationStatusOk
in interfaceNotificationChannel
- Parameters:
uniqueId
- of the message whose status is OK
-
sendNotificationStatusStale
Description copied from interface:NotificationChannel
Send status stale for a
Notification
.Under normal circumstances this method is not used.
- Specified by:
sendNotificationStatusStale
in interfaceNotificationChannel
- Parameters:
uniqueId
- of the message whose status is STALE
-
sendNotificationNotFound
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 interfaceNotificationChannel
- 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 interfaceNotificationChannel
-
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 interfaceNotificationChannel
-
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 noNotification
s 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:
sendEmptyNotificationContainer
in interfaceNotificationChannel
-
removeNotifications
Description copied from interface:NotificationChannel
Removes
Notification
s 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 interfaceNotificationChannel
- Parameters:
uniqueIds
- of the items to remove
-
removeNotification
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 interfaceNotificationChannel
- Parameters:
uniqueId
- of the item to remove
-
callbackChannelListener
-
setNotificationChannelListener
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 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: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 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:NotificationChannel
Returns the username for the channel
- Specified by:
getUsername
in interfaceNotificationChannel
- 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 interfaceNotificationChannel
- Returns:
- subject for the channel
-
getKey
-
getNotificationCount
public int getNotificationCount()
-