Class NotificationServiceImpl
- java.lang.Object
-
- org.forgerock.openig.tools.notifications.ws.NotificationServiceImpl
-
- All Implemented Interfaces:
LifeCycle,NotificationService
public class NotificationServiceImpl extends Object implements NotificationService, LifeCycle
NotificationServiceimplementation.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.forgerock.openig.tools.notifications.NotificationService
NotificationService.Registration
-
-
Constructor Summary
Constructors Constructor Description NotificationServiceImpl(HttpWebSocketClient client, URI uri, IdGenerator idGenerator, String ssoTokenHeader, AsyncRefreshableSupplier<SsoToken,AuthenticationException> tokenProvider, Duration reconnectDelay, int initialConnectionAttempts, Duration heartbeatInterval, ScheduledExecutorService heartbeatExecutorService)Constructs aNotificationServiceimplementation.
-
Method Summary
All 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,Exception>start()Starts this object.Promise<Void,NeverThrowsException>stop()Stops this object.Promise<Subscription,SubscriptionException>subscribe(String topic, NotificationListener listener)Subscribes (asynchronously) to a given topic, providing a listener that will be invoked at notification reception time.
-
-
-
Constructor Detail
-
NotificationServiceImpl
public NotificationServiceImpl(HttpWebSocketClient client, URI uri, IdGenerator idGenerator, String ssoTokenHeader, AsyncRefreshableSupplier<SsoToken,AuthenticationException> tokenProvider, Duration reconnectDelay, int initialConnectionAttempts, Duration heartbeatInterval, ScheduledExecutorService heartbeatExecutorService)
Constructs aNotificationServiceimplementation.- Parameters:
client- websocket clienturi- URI to connect toidGenerator- ID GeneratorssoTokenHeader- SSO token headertokenProvider- SSO token value providerreconnectDelay- reconnection delay between attemptsinitialConnectionAttempts- number of retries allowed for the first connectionheartbeatInterval- delay between heartbeats. Set toDuration.UNLIMITEDorDuration.ZEROto disable.heartbeatExecutorService-ScheduledExecutorServiceused to schedule heartbeat tasks
-
-
Method Detail
-
start
public Promise<Void,Exception> start()
Description copied from interface:LifeCycleStarts this object.
-
stop
public Promise<Void,NeverThrowsException> stop()
Description copied from interface:LifeCycleStops this object.
-
subscribe
public Promise<Subscription,SubscriptionException> subscribe(String topic, 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 interfaceNotificationService- Parameters:
topic- topic name to subscribe tolistener- notification listener- Returns:
- a promise of a subscription that will be completed after AM sends back the acknowledgement.
-
addConnectionEventListener
public 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 interfaceNotificationService- Parameters:
listener- consumer of connection events- Returns:
- a promise of a registration object that has to be used for un-registration
-
-