[New] Added ExecutionHandler.getControllers(String)

This commit is contained in:
Robert von Burg 2020-06-22 17:24:53 +02:00
parent 17645c11a2
commit 3bdd87bd73
2 changed files with 31 additions and 12 deletions

View File

@ -45,6 +45,14 @@ public class EventBasedExecutionHandler extends ExecutionHandler {
super(container, componentName);
}
@Override
public Collection<Controller> getControllers(String realm) {
Map<Locator, Controller> controllersByRealm = this.controllers.getMap(realm);
if (controllersByRealm == null)
return Collections.emptyList();
return controllersByRealm.values();
}
@Override
public Controller getController(String realm, Activity activity) {
return this.controllers.getElement(realm, activity.getLocator());
@ -294,8 +302,8 @@ public class EventBasedExecutionHandler extends ExecutionHandler {
if (getContainer().hasComponent(OperationsLog.class)) {
getComponent(OperationsLog.class).addMessage(
new LogMessage(realm, SYSTEM_USER_AGENT, controller.getLocator(), LogSeverity.Exception,
LogMessageState.Information, ResourceBundle.getBundle("strolch-service"), "execution.handler.failed.execution")
.withException(e).value("reason", e));
LogMessageState.Information, ResourceBundle.getBundle("strolch-service"),
"execution.handler.failed.execution").withException(e).value("reason", e));
}
}
});
@ -316,8 +324,8 @@ public class EventBasedExecutionHandler extends ExecutionHandler {
if (getContainer().hasComponent(OperationsLog.class)) {
getComponent(OperationsLog.class).addMessage(
new LogMessage(realm, SYSTEM_USER_AGENT, locator, LogSeverity.Exception,
LogMessageState.Information, ResourceBundle.getBundle("strolch-service"), "execution.handler.failed.executed")
.withException(e).value("reason", e));
LogMessageState.Information, ResourceBundle.getBundle("strolch-service"),
"execution.handler.failed.executed").withException(e).value("reason", e));
}
}
});
@ -338,8 +346,8 @@ public class EventBasedExecutionHandler extends ExecutionHandler {
if (getContainer().hasComponent(OperationsLog.class)) {
getComponent(OperationsLog.class).addMessage(
new LogMessage(realm, SYSTEM_USER_AGENT, locator, LogSeverity.Exception,
LogMessageState.Information, ResourceBundle.getBundle("strolch-service"), "execution.handler.failed.stopped")
.withException(e).value("reason", e));
LogMessageState.Information, ResourceBundle.getBundle("strolch-service"),
"execution.handler.failed.stopped").withException(e).value("reason", e));
}
}
});
@ -360,8 +368,8 @@ public class EventBasedExecutionHandler extends ExecutionHandler {
if (getContainer().hasComponent(OperationsLog.class)) {
getComponent(OperationsLog.class).addMessage(
new LogMessage(realm, SYSTEM_USER_AGENT, locator, LogSeverity.Exception,
LogMessageState.Information, ResourceBundle.getBundle("strolch-service"), "execution.handler.failed.error")
.withException(e).value("reason", e));
LogMessageState.Information, ResourceBundle.getBundle("strolch-service"),
"execution.handler.failed.error").withException(e).value("reason", e));
}
}
});
@ -382,8 +390,8 @@ public class EventBasedExecutionHandler extends ExecutionHandler {
if (getContainer().hasComponent(OperationsLog.class)) {
getComponent(OperationsLog.class).addMessage(
new LogMessage(realm, SYSTEM_USER_AGENT, locator, LogSeverity.Exception,
LogMessageState.Information, ResourceBundle.getBundle("strolch-service"), "execution.handler.failed.warning")
.withException(e).value("reason", e));
LogMessageState.Information, ResourceBundle.getBundle("strolch-service"),
"execution.handler.failed.warning").withException(e).value("reason", e));
}
}
});
@ -408,8 +416,8 @@ public class EventBasedExecutionHandler extends ExecutionHandler {
if (getContainer().hasComponent(OperationsLog.class)) {
getComponent(OperationsLog.class).addMessage(
new LogMessage(realm, SYSTEM_USER_AGENT, activity.getLocator(), LogSeverity.Exception,
LogMessageState.Information, ResourceBundle.getBundle("strolch-service"), "execution.handler.failed.archive")
.withException(e).value("reason", e));
LogMessageState.Information, ResourceBundle.getBundle("strolch-service"),
"execution.handler.failed.archive").withException(e).value("reason", e));
}
}
});

View File

@ -1,5 +1,6 @@
package li.strolch.execution;
import java.util.Collection;
import java.util.Set;
import java.util.concurrent.ExecutorService;
@ -57,6 +58,16 @@ public abstract class ExecutionHandler extends StrolchComponent {
return getExecutorService("ExecutionHandler");
}
/**
* Returns the controllers for the given realm
*
* @param realm
* the realm for which to get the controller
*
* @return the controllers
*/
public abstract Collection<Controller> getControllers(String realm);
/**
* Returns the controller for the given realm and activity, null if it does not exist
*