Package com.symphony.bdk.core.activity
Class AbstractActivity<E,C extends ActivityContext<E>>
java.lang.Object
com.symphony.bdk.core.activity.AbstractActivity<E,C>
- Direct Known Subclasses:
CommandActivity
,FormReplyActivity
,UserJoinedRoomActivity
@API(status=INTERNAL)
public abstract class AbstractActivity<E,C extends ActivityContext<E>>
extends Object
Base abstract class for activities provided by the BDK. Provides a generic flow to process an incoming chat event.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
beforeMatcher
(C context) This callback can be used to prepareActivityContext
before actually processing theActivityMatcher.matches(ActivityContext)
method.protected abstract void
bindToRealTimeEventsSource
(Consumer<RealTimeEventListener> realTimeEventsSource) Bind an Activity to its real-time event.protected C
createContextInstance
(V4Initiator initiator, E event) getInfo()
Retrieve activity details.protected abstract ActivityInfo
info()
Build activity info.protected boolean
protected abstract ActivityMatcher<C>
matcher()
Any kind of activity must provide anActivityMatcher
in order to detect if it can be applied to a certain user input.protected abstract void
onActivity
(C context) Contain the activity business logic.protected void
processEvent
(V4Initiator initiator, E event)
-
Constructor Details
-
AbstractActivity
public AbstractActivity()
-
-
Method Details
-
matcher
Any kind of activity must provide anActivityMatcher
in order to detect if it can be applied to a certain user input.- Returns:
- an
ActivityMatcher
implementation. - Throws:
EventException
- Throw this exception if this method should fail the current events processing and re-queue the events in datafeed. Other exceptions will be caught silently.
-
onActivity
Contain the activity business logic. Executed only if theActivityMatcher.matches(ActivityContext)
returned a true value.- Parameters:
context
- The activity context object.- Throws:
EventException
- Throw this exception if this method should fail the current events processing and re-queue the events in datafeed. Other exceptions will be caught silently.
-
bindToRealTimeEventsSource
protected abstract void bindToRealTimeEventsSource(Consumer<RealTimeEventListener> realTimeEventsSource) Bind an Activity to its real-time event.- Parameters:
realTimeEventsSource
- The real-time events source, issued from theDatafeedLoop
.
-
info
Build activity info. -
getInfo
Retrieve activity details. Can be used for metrics, reporting or help generation.- Returns:
- activity info
-
isAsynchronous
protected boolean isAsynchronous() -
beforeMatcher
This callback can be used to prepareActivityContext
before actually processing theActivityMatcher.matches(ActivityContext)
method.- Throws:
EventException
- Throw this exception if this method should fail the current events processing and re-queue the events in datafeed. Other exceptions will be caught silently.
-
processEvent
- Throws:
EventException
-
createContextInstance
-