Class SubscriptionService
- java.lang.Object
- 
- org.forgerock.openig.tools.notifications.ws.SubscriptionService
 
- 
- All Implemented Interfaces:
- NotificationService
 
 public class SubscriptionService extends Object implements NotificationService Web-socket client endpoint that bridges AM notifications protocol to our own API.This class manages subscriptions requests and acknowledgments asynchronously. This class is web-socket implementation-free (no dependency on any web-socket container specific API or behaviour). 
- 
- 
Nested Class Summary- 
Nested classes/interfaces inherited from interface org.forgerock.openig.tools.notifications.NotificationServiceNotificationService.Registration
 
- 
 - 
Constructor SummaryConstructors Constructor Description SubscriptionService(TopicManager manager)SubscriptionServiceconstructor taking aTopicManager.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description Promise<NotificationService.Registration,NeverThrowsException>addConnectionEventListener(Consumer<ConnectionEvent> listener)Registers asynchronously a listener that will be notified on connection/disconnection events.Promise<Void,NeverThrowsException>close()Close theSubscriptionServiceand unsubscribe from all topics.voidonClose()Means of notifying theSubscriptionServicethat a notification provider has closed.voidonMessage(JsonValue message)Means of supplying theSubscriptionServicewith subscription and notification messages.voidonOpen(WebSocketAdapter webSocket)Means of notifying theSubscriptionServicethat a notification provider available.Promise<Subscription,SubscriptionException>subscribe(String topicName, NotificationListener listener)Subscribes (asynchronously) to a given topic, providing a listener that will be invoked at notification reception time.
 
- 
- 
- 
Constructor Detail- 
SubscriptionServicepublic SubscriptionService(TopicManager manager) SubscriptionServiceconstructor taking aTopicManager.- Parameters:
- manager-- TopicManagerto handle topic subscription
 
 
- 
 - 
Method Detail- 
onOpenpublic void onOpen(WebSocketAdapter webSocket) Means of notifying theSubscriptionServicethat a notification provider available.- Parameters:
- webSocket- the WebSocket to use to handle notification registration
 
 - 
onClosepublic void onClose() Means of notifying theSubscriptionServicethat a notification provider has closed.
 - 
onMessagepublic void onMessage(JsonValue message) Means of supplying theSubscriptionServicewith subscription and notification messages.- Parameters:
- message- the subscription or notification message
 
 - 
subscribepublic Promise<Subscription,SubscriptionException> subscribe(String topicName, NotificationListener listener) Description copied from interface:NotificationServiceSubscribes (asynchronously) to a given topic, providing a listener that will be invoked at notification reception time.- Specified by:
- subscribein interface- NotificationService
- Parameters:
- topicName- topic name to subscribe to
- listener- notification listener
- Returns:
- a promise of a subscription that will be completed after AM sends back the acknowledgement.
 
 - 
addConnectionEventListenerpublic Promise<NotificationService.Registration,NeverThrowsException> addConnectionEventListener(Consumer<ConnectionEvent> listener) Description copied from interface:NotificationServiceRegisters asynchronously a listener that will be notified on connection/disconnection events. The returnedPromisewill be completed once theNotificationServiceis connected.- Specified by:
- addConnectionEventListenerin interface- NotificationService
- Parameters:
- listener- consumer of connection events
- Returns:
- a promise of a registration object that has to be used for un-registration
 
 - 
closepublic Promise<Void,NeverThrowsException> close() Close theSubscriptionServiceand unsubscribe from all topics.- Returns:
- a Promise
 
 
- 
 
-