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

Distinguish between new and remove notifications.

parent dc224792
No related branches found
No related tags found
No related merge requests found
......@@ -190,15 +190,12 @@ public class AgentController {
ModelSkeletonDelta delta = curAdapter.commitFinished(success);
if (success) {
// Delegate the new objects.
// Send notifications for all changes
for (EObject curObject : delta.getNewObjects()) {
scope.sendNotifications((CDOObject) curObject);
scope.sendNotifications(ModelNotification.NEW_NOTIFICATION, (CDOObject) curObject);
}
// Undelegate the removed objects.
for (EObject curObject : delta.getRemovedObjects()) {
if (delegationProvider.needsDelegation(curObject)) {
// TODO:
}
scope.sendNotifications(ModelNotification.REMOVED_NOTIFICATION, (CDOObject) curObject);
}
}
}
......
......@@ -250,7 +250,7 @@ public abstract class AgentScope extends Scope {
return synchronizedAdapters;
}
public void sendNotifications(CDOObject object) {
public void sendNotifications(String notificationType, CDOObject object) {
}
protected void sendNotificationMessage(String exchange, String routingKey, ModelNotification notification) {
......
......@@ -13,13 +13,18 @@ public class ModelNotification extends HashMap<String, Object> {
public static final String NOTIFICATION_TYPE = "NOTIFICATION_TYPE";
public static final String NEW_NOTIFICATION = "NEW";
public static final String REMOVED_NOTIFICATION = "REMOVED";
public ModelNotification(Map<String, Object> headers) {
super(headers);
}
public ModelNotification(Class<?> type, CDOObject object) {
put(INSTANCE_TYPE, type);
put(INSTANCE_ID, object.cdoID());
public ModelNotification(String notificationType, Class<?> instanceType, CDOObject instance) {
put(NOTIFICATION_TYPE, notificationType);
put(INSTANCE_TYPE, instanceType);
put(INSTANCE_ID, instance.cdoID());
}
}
......@@ -105,20 +105,20 @@ public class PhysicalInfrastructureScope extends InfrastructureScope {
}
@Override
public void sendNotifications(CDOObject object) {
public void sendNotifications(String notificationType, CDOObject object) {
if (object instanceof ComputeNode) {
sendNotificationMessage(getComputeNodeExchange(), ((ComputeNode) object).getName(),
new ModelNotification(ComputeNode.class, object));
new ModelNotification(notificationType, ComputeNode.class, object));
}
if (object instanceof StorageNode) {
sendNotificationMessage(getStorageNodeExchange(), ((StorageNode) object).getName(),
new ModelNotification(StorageNode.class, object));
new ModelNotification(notificationType, StorageNode.class, object));
}
if (object instanceof RuntimeEnvironment) {
RuntimeEnvironment env = (RuntimeEnvironment) object;
if (env.getOfClass() == RuntimeEnvironmentClasses.HYPERVISOR) {
sendNotificationMessage(getHypervisorExchange(), ((RuntimeEnvironment) object).getName(),
new ModelNotification(RuntimeEnvironment.class, object));
new ModelNotification(notificationType, RuntimeEnvironment.class, object));
}
}
}
......
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