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
NotificationService
implementation.
-
-
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 aNotificationService
implementation.
-
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 aNotificationService
implementation.- 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.UNLIMITED
orDuration.ZERO
to disable.heartbeatExecutorService
-ScheduledExecutorService
used to schedule heartbeat tasks
-
-
Method Detail
-
start
public Promise<Void,Exception> start()
Description copied from interface:LifeCycle
Starts this object.
-
stop
public Promise<Void,NeverThrowsException> stop()
Description copied from interface:LifeCycle
Stops this object.
-
subscribe
public Promise<Subscription,SubscriptionException> subscribe(String topic, NotificationListener listener)
Description copied from interface:NotificationService
Subscribes (asynchronously) to a given topic, providing a listener that will be invoked at notification reception time.- Specified by:
subscribe
in 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:NotificationService
Registers asynchronously a listener that will be notified on connection/disconnection events. The returnedPromise
will be completed once theNotificationService
is connected.- Specified by:
addConnectionEventListener
in interfaceNotificationService
- Parameters:
listener
- consumer of connection events- Returns:
- a promise of a registration object that has to be used for un-registration
-
-