Skip to content
Snippets Groups Projects
Commit 497c31e2 authored by Simon Spinner's avatar Simon Spinner
Browse files

Exchanges definitions in PlatformScope.

parent 54522263
No related branches found
No related tags found
No related merge requests found
package tools.descartes.prisma.core.scopes;
import edu.kit.ipd.descartes.mm.resourceconfiguration.ConfigurationSpecification;
import edu.kit.ipd.descartes.mm.resourcelandscape.RuntimeEnvironment;
import edu.kit.ipd.descartes.mm.runtimeenvironmentclasses.RuntimeEnvironmentClasses;
import tools.descartes.prisma.core.MessageBus;
import tools.descartes.prisma.core.MessageBus.ExchangeType;
import tools.descartes.prisma.core.ModelRepository;
import tools.descartes.prisma.model.sensor.Sensor;
public class PlatformScope extends ContainerScope {
......@@ -13,20 +17,45 @@ public class PlatformScope extends ContainerScope {
super(name, PLATFORM_SCOPE_TYPE, systemScope, repository, messageBus);
}
public String getVirtualMachineExchange() {
return getName() + ".VirtualMachine";
public String getOperatingSystemExchange() {
return getName() + ".OperatingSystem";
}
public String getRuntimeEnvironmentExchange() {
return getName() + ".RuntimeEnvironment";
}
public String getConfigurationSpecificationExchange() {
return getName() + ".ConfigurationSpecification";
}
public String getPlatformSensorExchange() {
return getName() + ".PlatformSensor";
}
@Override
protected void createMessageExchanges() {
super.createMessageExchanges();
getMessageBus().createExchange(getVirtualMachineExchange(), ExchangeType.TOPIC);
getMessageBus().createExchange(getRuntimeEnvironmentExchange(), ExchangeType.TOPIC);
declareNotification(
new NotificationDefinition(RuntimeEnvironment.class, getOperatingSystemExchange(),
ExchangeType.DIRECT) {
@Override
public boolean isActive(Object o) {
if (super.isActive(o)) {
return ((RuntimeEnvironment) o).getOfClass() == RuntimeEnvironmentClasses.OPERATING_SYSTEM;
}
return false;
}
});
declareNotification(new NotificationDefinition(RuntimeEnvironment.class, getRuntimeEnvironmentExchange(),
ExchangeType.TOPIC));
declareNotification(new NotificationDefinition(ConfigurationSpecification.class,
getConfigurationSpecificationExchange(), ExchangeType.TOPIC));
declareNotification(new NotificationDefinition(Sensor.class, getPlatformSensorExchange(), ExchangeType.TOPIC));
declareDelegation(getRuntimeEnvironmentExchange());
declareDelegation(getPlatformSensorExchange());
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment