public class TriggerService
extends java.lang.Object
A TriggerService subscribes to the Triggers of a StreamLink user and allows the user to register a listener to be called back when triggers are added, removed or modified.
The TriggerService also allows the user to add and remove triggers.
When trigger conditions are met, notifications will be fired. Notifications can be handled by creating a NotificationService and registering for notification callbacks.
The service itself does not subscribe to anything unless listeners are added to it. For every listener added one subscription is being issued. These subscriptions induce the service state for the associated listeners. Therefore the service states can vary for different listeners. If the reference to the service is removed without removing all listeners beforehand, open subscriptions will stay around forever. To avoid that, remove all listeners before removing the service.
Constructor and Description |
---|
TriggerService(StreamLink streamLink)
Creates a new TriggerService for the given StreamLink instance.
|
Modifier and Type | Method and Description |
---|---|
void |
addListener(TriggerListener listener)
Adds a trigger listener that will be called back when triggers are added and removed.
|
Trigger |
addTrigger(java.lang.String subject,
java.lang.String condition,
java.util.Map<java.lang.String,java.lang.String> extraParams,
ResultListener listener)
Add a new trigger for the current user.
|
void |
removeListener(TriggerListener listener)
Removes a previously added trigger listener, callbacks to this listener will be stopped.
|
void |
removeTrigger(Trigger trigger,
ResultListener listener)
Removes a trigger from the system.
|
public TriggerService(StreamLink streamLink)
Creates a new TriggerService for the given StreamLink instance.
streamLink
- the StreamLink that will be used to send and retrieve triggers from the Liberator.public void addListener(TriggerListener listener)
Adds a trigger listener that will be called back when triggers are added and removed.
listener
- - The TriggerListener to be added.public void removeListener(TriggerListener listener)
Removes a previously added trigger listener, callbacks to this listener will be stopped.
listener
- - The TriggerListener to be removed.public Trigger addTrigger(java.lang.String subject, java.lang.String condition, java.util.Map<java.lang.String,java.lang.String> extraParams, ResultListener listener)
Add a new trigger for the current user.
subject
- the rttp subject of this trigger.condition
- the trigger condition, for more details on the format of the condition string, please see the StreamLink Overview document.extraParams
- a map of extra parameters to be added to the trigger.listener
- a ResultListener that will be called back to notify the user code of the result of this operation.public void removeTrigger(Trigger trigger, ResultListener listener)
Removes a trigger from the system.
trigger
- the Trigger that should be removed.listener
- a ResultListener that will be called back to notify the user code of the result of this operation.Please send bug reports and comments to Caplin support