Search in sources :

Example 36 with EventListener

use of won.bot.framework.eventbot.listener.EventListener in project webofneeds by researchstudio-sat.

the class MatcherProtocolTestBot method initializeEventListeners.

@Override
protected void initializeEventListeners() {
    EventListenerContext ctx = getEventListenerContext();
    EventBus bus = getEventBus();
    // subscribe this bot with the WoN nodes' 'new need' topic
    RegisterMatcherAction registerMatcherAction = new RegisterMatcherAction(ctx);
    this.matcherRegistrator = new ActionOnEventListener(ctx, registerMatcherAction, 1);
    bus.subscribe(ActEvent.class, this.matcherRegistrator);
    RandomDelayedAction delayedRegistration = new RandomDelayedAction(ctx, registrationMatcherRetryInterval, registrationMatcherRetryInterval, 0, registerMatcherAction);
    ActionOnEventListener matcherRetryRegistrator = new ActionOnEventListener(ctx, delayedRegistration);
    bus.subscribe(MatcherRegisterFailedEvent.class, matcherRetryRegistrator);
    // create needs every trigger execution until 2 needs are created
    this.needCreator = new ActionOnEventListener(ctx, new CreateNeedWithFacetsAction(ctx, getBotContextWrapper().getNeedCreateListName()), NO_OF_NEEDS);
    bus.subscribe(MatcherRegisteredEvent.class, new ActionOnEventListener(ctx, new BaseEventBotAction(ctx) {

        @Override
        protected void doRun(final Event event, EventListener executingListener) throws Exception {
            getEventListenerContext().getEventBus().subscribe(ActEvent.class, needCreator);
        }
    }, 1));
    this.matcherNotifier = new ActionOnceAfterNEventsListener(ctx, 4, new LogAction(ctx, "Received all events for newly created needs."));
    bus.subscribe(NeedCreatedEventForMatcher.class, matcherNotifier);
    bus.subscribe(NeedCreatedEvent.class, matcherNotifier);
    this.matcher = new ActionOnceAfterNEventsListener(ctx, NO_OF_NEEDS, new MatchNeedsAction(ctx));
    // count until 1 need is created, then create a comment facet
    bus.subscribe(NeedCreatedEvent.class, this.matcher);
    this.allNeedsDeactivator = new ActionOnEventListener(ctx, new DeactivateAllNeedsAction(ctx), 1);
    bus.subscribe(HintFromMatcherEvent.class, this.allNeedsDeactivator);
    this.workDoneSignaller = new ActionOnceAfterNEventsListener(ctx, 4, new SignalWorkDoneAction(ctx));
    bus.subscribe(NeedDeactivatedEvent.class, this.workDoneSignaller);
    bus.subscribe(NeedDeactivatedEventForMatcher.class, this.workDoneSignaller);
}
Also used : EventListenerContext(won.bot.framework.eventbot.EventListenerContext) ActionOnceAfterNEventsListener(won.bot.framework.eventbot.listener.impl.ActionOnceAfterNEventsListener) CreateNeedWithFacetsAction(won.bot.framework.eventbot.action.impl.needlifecycle.CreateNeedWithFacetsAction) EventBus(won.bot.framework.eventbot.bus.EventBus) SignalWorkDoneAction(won.bot.framework.eventbot.action.impl.lifecycle.SignalWorkDoneAction) RegisterMatcherAction(won.bot.framework.eventbot.action.impl.matcher.RegisterMatcherAction) DeactivateAllNeedsAction(won.bot.framework.eventbot.action.impl.needlifecycle.DeactivateAllNeedsAction) BaseEventBotAction(won.bot.framework.eventbot.action.BaseEventBotAction) NeedDeactivatedEvent(won.bot.framework.eventbot.event.impl.needlifecycle.NeedDeactivatedEvent) HintFromMatcherEvent(won.bot.framework.eventbot.event.impl.wonmessage.HintFromMatcherEvent) MatcherRegisteredEvent(won.bot.framework.eventbot.event.impl.matcher.MatcherRegisteredEvent) Event(won.bot.framework.eventbot.event.Event) ActEvent(won.bot.framework.eventbot.event.impl.lifecycle.ActEvent) NeedCreatedEvent(won.bot.framework.eventbot.event.impl.needlifecycle.NeedCreatedEvent) MatcherRegisterFailedEvent(won.bot.framework.eventbot.event.impl.matcher.MatcherRegisterFailedEvent) MatchNeedsAction(won.bot.framework.eventbot.action.impl.matcher.MatchNeedsAction) ActionOnEventListener(won.bot.framework.eventbot.listener.impl.ActionOnEventListener) ActionOnEventListener(won.bot.framework.eventbot.listener.impl.ActionOnEventListener) BaseEventListener(won.bot.framework.eventbot.listener.BaseEventListener) EventListener(won.bot.framework.eventbot.listener.EventListener)

Example 37 with EventListener

use of won.bot.framework.eventbot.listener.EventListener in project webofneeds by researchstudio-sat.

the class NeedCreatorBot method initializeEventListeners.

@Override
protected void initializeEventListeners() {
    final EventListenerContext ctx = getEventListenerContext();
    final EventBus bus = getEventBus();
    final Counter needCreationSuccessfulCounter = new CounterImpl("needsCreated");
    final Counter needCreationFailedCounter = new CounterImpl("needCreationFailed");
    final Counter needCreationStartedCounter = new CounterImpl("creationStarted");
    // create a targeted counter that will publish an event when the target is reached
    // in this case, 0 unfinished need creations means that all needs were created
    final Counter creationUnfinishedCounter = new TargetCounterDecorator(ctx, new CounterImpl("creationUnfinished"), 0);
    // create needs every trigger execution until the need producer is exhausted
    this.groupMemberCreator = new ActionOnEventListener(ctx, "groupMemberCreator", new MultipleActions(ctx, new IncrementCounterAction(ctx, needCreationStartedCounter), new IncrementCounterAction(ctx, creationUnfinishedCounter), new CreateNeedWithFacetsAction(ctx, getBotContextWrapper().getNeedCreateListName())), -1);
    bus.subscribe(ActEvent.class, this.groupMemberCreator);
    bus.subscribe(NeedCreatedEvent.class, new ActionOnEventListener(ctx, "logger", new BaseEventBotAction(ctx) {

        int lastOutput = 0;

        @Override
        protected void doRun(final Event event, EventListener executingListener) throws Exception {
            int cnt = needCreationStartedCounter.getCount();
            int unfinishedCount = creationUnfinishedCounter.getCount();
            int successCnt = needCreationSuccessfulCounter.getCount();
            int failedCnt = needCreationFailedCounter.getCount();
            if (cnt - lastOutput >= 1) {
                logger.info("started creation of {} needs, creation not yet finished for {}. Successful: {}, failed: {}", new Object[] { cnt, unfinishedCount, successCnt, failedCnt });
                lastOutput = cnt;
            }
        }
    }));
    // When the needproducer is exhausted, stop the creator.
    getEventBus().subscribe(NeedProducerExhaustedEvent.class, new ActionOnEventListener(ctx, new UnsubscribeListenerAction(ctx, groupMemberCreator)));
    // also, keep track of what worked and what didn't
    bus.subscribe(NeedCreationFailedEvent.class, new ActionOnEventListener(ctx, new IncrementCounterAction(ctx, needCreationFailedCounter)));
    bus.subscribe(NeedCreatedEvent.class, new ActionOnEventListener(ctx, new IncrementCounterAction(ctx, needCreationSuccessfulCounter)));
    // when a need is created (or it failed), decrement the halfCreatedNeed counter
    EventListener downCounter = new ActionOnEventListener(ctx, "downCounter", new DecrementCounterAction(ctx, creationUnfinishedCounter));
    // count a successful need creation
    bus.subscribe(NeedCreatedEvent.class, downCounter);
    // if a creation failed, we don't want to keep us from keeping the correct count
    bus.subscribe(NeedCreationFailedEvent.class, downCounter);
    // we count the one execution when the creator realizes that the producer is exhausted, we have to count down
    // once for that, too.
    bus.subscribe(NeedProducerExhaustedEvent.class, downCounter);
    EventListener loadTestMonitor = new ActionOnEventListener(ctx, "loadTestMonitor", new MatchingLoadTestMonitorAction(ctx));
    bus.subscribe(NeedCreatedEvent.class, loadTestMonitor);
    bus.subscribe(HintFromMatcherEvent.class, loadTestMonitor);
// wait for the targetCountReached event of the finishedCounter. We don't use
// another target counter, so we don't need to do more filtering.
// this.workDoneSignaller = new ActionOnEventListener(
// ctx, "workDoneSignaller",
// new SignalWorkDoneAction(ctx));
// bus.subscribe(TargetCountReachedEvent.class, this.workDoneSignaller);
}
Also used : EventListenerContext(won.bot.framework.eventbot.EventListenerContext) CreateNeedWithFacetsAction(won.bot.framework.eventbot.action.impl.needlifecycle.CreateNeedWithFacetsAction) EventBus(won.bot.framework.eventbot.bus.EventBus) MatchingLoadTestMonitorAction(won.bot.framework.eventbot.action.impl.monitor.MatchingLoadTestMonitorAction) BaseEventBotAction(won.bot.framework.eventbot.action.BaseEventBotAction) NeedCreationFailedEvent(won.bot.framework.eventbot.event.NeedCreationFailedEvent) HintFromMatcherEvent(won.bot.framework.eventbot.event.impl.wonmessage.HintFromMatcherEvent) Event(won.bot.framework.eventbot.event.Event) ActEvent(won.bot.framework.eventbot.event.impl.lifecycle.ActEvent) NeedProducerExhaustedEvent(won.bot.framework.eventbot.event.impl.needlifecycle.NeedProducerExhaustedEvent) NeedCreatedEvent(won.bot.framework.eventbot.event.impl.needlifecycle.NeedCreatedEvent) UnsubscribeListenerAction(won.bot.framework.eventbot.action.impl.listener.UnsubscribeListenerAction) ActionOnEventListener(won.bot.framework.eventbot.listener.impl.ActionOnEventListener) ActionOnEventListener(won.bot.framework.eventbot.listener.impl.ActionOnEventListener) BaseEventListener(won.bot.framework.eventbot.listener.BaseEventListener) EventListener(won.bot.framework.eventbot.listener.EventListener)

Example 38 with EventListener

use of won.bot.framework.eventbot.listener.EventListener in project webofneeds by researchstudio-sat.

the class BAAtomicBaseBot method initializeEventListeners.

@Override
protected void initializeEventListeners() {
    final EventListenerContext ctx = getEventListenerContext();
    final EventBus bus = getEventBus();
    ParticipantCoordinatorBotContextWrapper botContextWrapper = (ParticipantCoordinatorBotContextWrapper) getBotContextWrapper();
    // create needs every trigger execution until noOfNeeds are created
    this.participantNeedCreator = new ActionOnEventListener(ctx, "participantCreator", new CreateNeedWithFacetsAction(ctx, botContextWrapper.getParticipantListName(), getParticipantFacetType().getURI()), noOfNeeds - 1);
    bus.subscribe(ActEvent.class, this.participantNeedCreator);
    // when done, create one coordinator need
    this.coordinatorNeedCreator = new ActionOnEventListener(ctx, "coordinatorCreator", new FinishedEventFilter(participantNeedCreator), new CreateNeedWithFacetsAction(ctx, botContextWrapper.getCoordinatorListName(), getCoordinatorFacetType().getURI()), 1);
    bus.subscribe(FinishedEvent.class, this.coordinatorNeedCreator);
    FinishedEventFilter coordinatorCreatorFilter = new FinishedEventFilter(coordinatorNeedCreator);
    final Iterator<TwoPhaseScript> scriptIterator = scripts.iterator();
    // make a composite filter, with one filter for each testScriptListener that wait
    // for the FinishedEvents the they emit. That filter will be used to shut
    // down all needs after all the scriptListeners have finished.
    final OrFilter firstPhaseScriptListenerFilter = new OrFilter();
    final OrFilter secondPhaseScriptListenerFilter = new OrFilter();
    // create a callback that gets called immediately before the connection is established
    ConnectFromListToListAction.ConnectHook scriptConnectHook = new ConnectFromListToListAction.ConnectHook() {

        @Override
        public void onConnect(final URI fromNeedURI, final URI toNeedURI) {
            TwoPhaseScript script = scriptIterator.next();
            // create the listener that will execute the script actions
            BATestScriptListener testScriptListener = new BATestScriptListener(ctx, script.getFirstPhaseScript(), fromNeedURI, toNeedURI, MILLIS_BETWEEN_MESSAGES);
            // subscribe it to the relevant events.
            bus.subscribe(ConnectFromOtherNeedEvent.class, testScriptListener);
            bus.subscribe(OpenFromOtherNeedEvent.class, testScriptListener);
            bus.subscribe(MessageFromOtherNeedEvent.class, testScriptListener);
            // add a filter that will wait for the FinishedEvent emitted by that listener
            // wrap it in an acceptance filter to make extra sure we count each listener only once.
            firstPhaseScriptListenerFilter.addFilter(new AcceptOnceFilter(new FinishedEventFilter(testScriptListener)));
            // now we create the listener that is only active in the second phase
            // remember it so we can check its state later
            BATestScriptListener secondPhaseTestScriptListener = new BATestScriptListener(ctx, script.getSecondPhaseScript(), fromNeedURI, toNeedURI, MILLIS_BETWEEN_MESSAGES);
            // remember both listeners as a pair as we'll need them together later
            TwoPhaseScriptListener twoPhaseScriptListener = new TwoPhaseScriptListener(testScriptListener, secondPhaseTestScriptListener);
            scriptListeners.add(twoPhaseScriptListener);
            secondPhaseScriptListenerFilter.addFilter(new AcceptOnceFilter(new FinishedEventFilter(secondPhaseTestScriptListener)));
        }
    };
    // when done, connect the participants to the coordinator
    this.needConnector = new ActionOnceAfterNEventsListener(ctx, "needConnector", noOfNeeds, new ConnectFromListToListAction(ctx, botContextWrapper.getCoordinatorListName(), botContextWrapper.getParticipantListName(), getCoordinatorFacetType().getURI(), getParticipantFacetType().getURI(), MILLIS_BETWEEN_MESSAGES, scriptConnectHook, "Hi!"));
    bus.subscribe(NeedCreatedEvent.class, this.needConnector);
    // for each group member, there are 2 listeners waiting for messages. when they are all finished, we're done.
    this.firstPhaseDoneListener = new ActionOnceAfterNEventsListener(ctx, "firstPhaseDoneListener", firstPhaseScriptListenerFilter, noOfNeeds - 1, new BaseEventBotAction(ctx) {

        @Override
        protected void doRun(final Event event, EventListener executingListener) throws Exception {
            logger.debug("starting second phase");
            for (TwoPhaseScriptListener listener : scriptListeners) {
                logger.debug("subscribing second phase listener {}", listener);
                // subscribe it to the relevant events.
                bus.subscribe(MessageFromOtherNeedEvent.class, listener.getSecondPhaseListener());
                bus.subscribe(SecondPhaseStartedEvent.class, listener.getSecondPhaseListener());
                listener.getSecondPhaseListener().setCoordinatorSideConnectionURI(listener.getFirstPhaseListener().getCoordinatorSideConnectionURI());
                listener.getSecondPhaseListener().setParticipantSideConnectionURI(listener.getFirstPhaseListener().getParticipantSideConnectionURI());
                listener.getSecondPhaseListener().updateFilterForBothConnectionURIs();
                bus.publish(new SecondPhaseStartedEvent(listener.getFirstPhaseListener().getCoordinatorURI(), listener.getFirstPhaseListener().getCoordinatorSideConnectionURI(), listener.getFirstPhaseListener().getParticipantURI()));
            }
        }
    });
    bus.subscribe(FinishedEvent.class, this.firstPhaseDoneListener);
    // for each group member, there are 2 listeners waiting for messages. when they are all finished, we're done.
    this.scriptsDoneListener = new ActionOnceAfterNEventsListener(ctx, "scriptsDoneListener", secondPhaseScriptListenerFilter, noOfNeeds - 1, new DeactivateAllNeedsOfListAction(ctx, botContextWrapper.getParticipantListName()));
    bus.subscribe(FinishedEvent.class, this.scriptsDoneListener);
    // When the needs are deactivated, all connections are closed. wait for the close events and signal work done.
    this.workDoneSignaller = new ActionOnceAfterNEventsListener(ctx, "workDoneSignaller", noOfNeeds - 1, new SignalWorkDoneAction(ctx));
    bus.subscribe(CloseFromOtherNeedEvent.class, this.workDoneSignaller);
}
Also used : EventListenerContext(won.bot.framework.eventbot.EventListenerContext) ActionOnceAfterNEventsListener(won.bot.framework.eventbot.listener.impl.ActionOnceAfterNEventsListener) CreateNeedWithFacetsAction(won.bot.framework.eventbot.action.impl.needlifecycle.CreateNeedWithFacetsAction) EventBus(won.bot.framework.eventbot.bus.EventBus) OrFilter(won.bot.framework.eventbot.filter.impl.OrFilter) SignalWorkDoneAction(won.bot.framework.eventbot.action.impl.lifecycle.SignalWorkDoneAction) URI(java.net.URI) DeactivateAllNeedsOfListAction(won.bot.framework.eventbot.action.impl.needlifecycle.DeactivateAllNeedsOfListAction) SecondPhaseStartedEvent(won.bot.framework.eventbot.listener.baStateBots.baCCMessagingBots.atomicBots.SecondPhaseStartedEvent) ConnectFromListToListAction(won.bot.framework.eventbot.action.impl.wonmessage.ConnectFromListToListAction) BATestScriptListener(won.bot.framework.eventbot.listener.baStateBots.BATestScriptListener) BaseEventBotAction(won.bot.framework.eventbot.action.BaseEventBotAction) MessageFromOtherNeedEvent(won.bot.framework.eventbot.event.impl.wonmessage.MessageFromOtherNeedEvent) SecondPhaseStartedEvent(won.bot.framework.eventbot.listener.baStateBots.baCCMessagingBots.atomicBots.SecondPhaseStartedEvent) NeedCreatedEvent(won.bot.framework.eventbot.event.impl.needlifecycle.NeedCreatedEvent) FinishedEvent(won.bot.framework.eventbot.event.impl.listener.FinishedEvent) ConnectFromOtherNeedEvent(won.bot.framework.eventbot.event.impl.wonmessage.ConnectFromOtherNeedEvent) OpenFromOtherNeedEvent(won.bot.framework.eventbot.event.impl.wonmessage.OpenFromOtherNeedEvent) Event(won.bot.framework.eventbot.event.Event) ActEvent(won.bot.framework.eventbot.event.impl.lifecycle.ActEvent) CloseFromOtherNeedEvent(won.bot.framework.eventbot.event.impl.wonmessage.CloseFromOtherNeedEvent) ActionOnEventListener(won.bot.framework.eventbot.listener.impl.ActionOnEventListener) ActionOnEventListener(won.bot.framework.eventbot.listener.impl.ActionOnEventListener) EventListener(won.bot.framework.eventbot.listener.EventListener) AcceptOnceFilter(won.bot.framework.eventbot.filter.impl.AcceptOnceFilter) FinishedEventFilter(won.bot.framework.eventbot.filter.impl.FinishedEventFilter) ParticipantCoordinatorBotContextWrapper(won.bot.framework.bot.context.ParticipantCoordinatorBotContextWrapper)

Example 39 with EventListener

use of won.bot.framework.eventbot.listener.EventListener in project webofneeds by researchstudio-sat.

the class ExecuteReplaceCommandAction method doRun.

@Override
protected void doRun(Event event, EventListener executingListener) throws Exception {
    if (!(event instanceof ReplaceCommandEvent)) {
        return;
    }
    ReplaceCommandEvent replaceCommandEvent = (ReplaceCommandEvent) event;
    Dataset atomDataset = replaceCommandEvent.getAtomDataset();
    if (atomDataset == null) {
        logger.warn("ReplaceCommandEvent did not contain an atom model, aborting atom creation");
        getEventListenerContext().getEventBus().publish(new ReplaceAbortedEvent(null, replaceCommandEvent, "CreateAtomCommandEvent did not contain an atom model, aborting atom creation"));
        return;
    }
    Resource atomResource = WonRdfUtils.AtomUtils.getAtomResource(atomDataset);
    if (!atomResource.isURIResource()) {
        throw new IllegalArgumentException("atom resource in dataset is not an URI");
    }
    URI atomURI = URI.create(atomResource.getURI());
    RdfUtils.replaceBaseURI(atomDataset, atomResource.getURI(), true);
    RdfUtils.replaceBaseResource(atomDataset, atomResource, true);
    // AtomModelWrapper atomModelWrapper = new AtomModelWrapper(atomDataset);
    // URI wonNodeURI =
    // getEventListenerContext().getWonNodeInformationService().getWonNodeUri(atomURI);
    final URI wonNodeUri = getEventListenerContext().getWonNodeInformationService().getWonNodeUri(atomURI);
    logger.debug("replacing atom content on won node {} with content {} ", wonNodeUri, StringUtils.abbreviate(RdfUtils.toString(atomDataset), 150));
    RdfUtils.renameResourceWithPrefix(atomDataset, atomResource.getURI(), atomURI.toString());
    WonMessage replaceMessage = createWonMessage(atomURI, wonNodeUri, atomDataset);
    replaceMessage = getEventListenerContext().getWonMessageSender().prepareMessage(replaceMessage);
    EventListener successCallback = event12 -> {
        logger.debug("atom content replacement successful for atom URI {}", atomURI);
        getEventListenerContext().getEventBus().publish(new ReplaceCommandSuccessEvent(atomURI, replaceCommandEvent));
    };
    EventListener failureCallback = event1 -> {
        String textMessage = WonRdfUtils.MessageUtils.getTextMessage(((FailureResponseEvent) event1).getFailureMessage());
        logger.debug("atom content replacement failed for atom URI {}, original message URI {}: {}", new Object[] { atomURI, ((FailureResponseEvent) event1).getOriginalMessageURI(), textMessage });
        getEventListenerContext().getEventBus().publish(new ReplaceCommandFailureEvent(atomURI, replaceCommandEvent, textMessage));
    };
    EventBotActionUtils.makeAndSubscribeResponseListener(replaceMessage, successCallback, failureCallback, getEventListenerContext());
    logger.debug("registered listeners for response to message URI {}", replaceMessage.getMessageURI());
    getEventListenerContext().getWonMessageSender().sendMessage(replaceMessage);
    logger.debug("atom content replacement message sent with message URI {}", replaceMessage.getMessageURI());
}
Also used : Logger(org.slf4j.Logger) WonMessageBuilderException(won.protocol.exception.WonMessageBuilderException) ReplaceAbortedEvent(won.bot.framework.eventbot.event.impl.command.replace.ReplaceAbortedEvent) MethodHandles(java.lang.invoke.MethodHandles) LoggerFactory(org.slf4j.LoggerFactory) ReplaceCommandEvent(won.bot.framework.eventbot.event.impl.command.replace.ReplaceCommandEvent) ReplaceCommandFailureEvent(won.bot.framework.eventbot.event.impl.command.replace.ReplaceCommandFailureEvent) BaseEventBotAction(won.bot.framework.eventbot.action.BaseEventBotAction) EventBotActionUtils(won.bot.framework.eventbot.action.EventBotActionUtils) ReplaceCommandSuccessEvent(won.bot.framework.eventbot.event.impl.command.replace.ReplaceCommandSuccessEvent) StringUtils(org.apache.commons.lang3.StringUtils) FailureResponseEvent(won.bot.framework.eventbot.event.impl.wonmessage.FailureResponseEvent) WonMessage(won.protocol.message.WonMessage) WonRdfUtils(won.protocol.util.WonRdfUtils) WonMessageBuilder(won.protocol.message.builder.WonMessageBuilder) AtomModelWrapper(won.protocol.util.AtomModelWrapper) Event(won.bot.framework.eventbot.event.Event) RdfUtils(won.protocol.util.RdfUtils) Resource(org.apache.jena.rdf.model.Resource) EventListener(won.bot.framework.eventbot.listener.EventListener) URI(java.net.URI) Dataset(org.apache.jena.query.Dataset) EventListenerContext(won.bot.framework.eventbot.EventListenerContext) Dataset(org.apache.jena.query.Dataset) Resource(org.apache.jena.rdf.model.Resource) ReplaceAbortedEvent(won.bot.framework.eventbot.event.impl.command.replace.ReplaceAbortedEvent) URI(java.net.URI) ReplaceCommandEvent(won.bot.framework.eventbot.event.impl.command.replace.ReplaceCommandEvent) ReplaceCommandSuccessEvent(won.bot.framework.eventbot.event.impl.command.replace.ReplaceCommandSuccessEvent) WonMessage(won.protocol.message.WonMessage) ReplaceCommandFailureEvent(won.bot.framework.eventbot.event.impl.command.replace.ReplaceCommandFailureEvent) EventListener(won.bot.framework.eventbot.listener.EventListener) FailureResponseEvent(won.bot.framework.eventbot.event.impl.wonmessage.FailureResponseEvent)

Example 40 with EventListener

use of won.bot.framework.eventbot.listener.EventListener in project webofneeds by researchstudio-sat.

the class BotBehaviour method cleanup.

private synchronized void cleanup() {
    onCleanup();
    for (EventListener eventListener : activeListeners) {
        context.getEventBus().unsubscribe(eventListener);
    }
    activeListeners.clear();
    active.set(false);
}
Also used : EventListener(won.bot.framework.eventbot.listener.EventListener)

Aggregations

EventListener (won.bot.framework.eventbot.listener.EventListener)57 Event (won.bot.framework.eventbot.event.Event)54 BaseEventBotAction (won.bot.framework.eventbot.action.BaseEventBotAction)41 URI (java.net.URI)37 EventBus (won.bot.framework.eventbot.bus.EventBus)36 Dataset (org.apache.jena.query.Dataset)31 EventListenerContext (won.bot.framework.eventbot.EventListenerContext)31 WonMessage (won.protocol.message.WonMessage)30 ActionOnceAfterNEventsListener (won.bot.framework.eventbot.listener.impl.ActionOnceAfterNEventsListener)24 MethodHandles (java.lang.invoke.MethodHandles)23 Logger (org.slf4j.Logger)23 LoggerFactory (org.slf4j.LoggerFactory)23 EventBotActionUtils (won.bot.framework.eventbot.action.EventBotActionUtils)22 WonMessageBuilder (won.protocol.message.builder.WonMessageBuilder)20 ActionOnEventListener (won.bot.framework.eventbot.listener.impl.ActionOnEventListener)19 BotBehaviour (won.bot.framework.eventbot.behaviour.BotBehaviour)18 SuccessResponseEvent (won.bot.framework.eventbot.event.impl.wonmessage.SuccessResponseEvent)18 Optional (java.util.Optional)17 Test (org.junit.Test)17 EventBotAction (won.bot.framework.eventbot.action.EventBotAction)17