[New] Added EventBasedExecutionHandler.controllerStream()
This is used when triggering execution to sort the activity execution
This commit is contained in:
parent
d7d8a7c4f0
commit
167f0a5777
|
@ -1,11 +1,13 @@
|
||||||
package li.strolch.execution;
|
package li.strolch.execution;
|
||||||
|
|
||||||
|
import static java.util.Collections.emptyMap;
|
||||||
import static java.util.Collections.emptySet;
|
import static java.util.Collections.emptySet;
|
||||||
import static li.strolch.model.StrolchModelConstants.*;
|
import static li.strolch.model.StrolchModelConstants.*;
|
||||||
import static li.strolch.runtime.StrolchConstants.SYSTEM_USER_AGENT;
|
import static li.strolch.runtime.StrolchConstants.SYSTEM_USER_AGENT;
|
||||||
import static li.strolch.utils.collections.SynchronizedCollections.synchronizedMapOfMaps;
|
import static li.strolch.utils.collections.SynchronizedCollections.synchronizedMapOfMaps;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import li.strolch.agent.api.ComponentContainer;
|
import li.strolch.agent.api.ComponentContainer;
|
||||||
import li.strolch.agent.api.ObserverEvent;
|
import li.strolch.agent.api.ObserverEvent;
|
||||||
|
@ -228,6 +230,10 @@ public class EventBasedExecutionHandler extends ExecutionHandler {
|
||||||
triggerExecution(realmName);
|
triggerExecution(realmName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected Stream<Controller> controllerStream(String realm) {
|
||||||
|
return this.controllers.getMapOrDefault(realm, emptyMap()).values().stream();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void triggerExecution(String realm) {
|
public void triggerExecution(String realm) {
|
||||||
ExecutionHandlerState state = this.statesByRealm.getOrDefault(realm, ExecutionHandlerState.Running);
|
ExecutionHandlerState state = this.statesByRealm.getOrDefault(realm, ExecutionHandlerState.Running);
|
||||||
|
@ -237,9 +243,7 @@ public class EventBasedExecutionHandler extends ExecutionHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized (this.controllers) {
|
synchronized (this.controllers) {
|
||||||
Map<Locator, Controller> controllers = this.controllers.getMap(realm);
|
controllerStream(realm).forEach(this::toExecution);
|
||||||
if (controllers != null)
|
|
||||||
controllers.values().forEach(this::toExecution);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue