if (event instanceof ISharedObjectCreateResponseEvent) {
// Ignore
} else if (event instanceof ISharedObjectMessageEvent) {
// track graph additions/removals and peer departures
// (deactivations)
ISharedObjectMessageEvent e = (ISharedObjectMessageEvent) event;
Object[] data = (Object[]) e.getData();
Integer type = (Integer) data[0];
switch (type.intValue()) {
case ADD:
handleAdd(e.getRemoteContainerID(), (ID) data[1]);
break;
case REMOVE:
handleRemove(e.getRemoteContainerID(), (ID) data[1]);
break;
case LEAVE:
handleLeave(e.getRemoteContainerID());
break;
}
} else if (event instanceof IContainerConnectedEvent) {
IContainerConnectedEvent e = (IContainerConnectedEvent) event;
if (e.getTargetID().equals(
getContext().getLocalContainerID()))
// this container joined
handleJoined();
else if (getContext().isGroupManager())
// some other container joined and we're the server
handleJoined(e.getTargetID());
} else if (event instanceof IContainerDisconnectedEvent) {
IContainerDisconnectedEvent e = (IContainerDisconnectedEvent) event;
// some other container departed -- same as peer deactivation
if (!e.getTargetID().equals(
getContext().getLocalContainerID()))
handleLeave(e.getTargetID());
} else if (event instanceof ISharedObjectActivatedEvent) {
ISharedObjectActivatedEvent e = (ISharedObjectActivatedEvent) event;
if (e.getActivatedID().equals(config.getSharedObjectID()))
// we're being activated
handleActivated();
} else if (event instanceof ISharedObjectDeactivatedEvent) {
ISharedObjectDeactivatedEvent e = (ISharedObjectDeactivatedEvent) event;
if (e.getDeactivatedID().equals(config.getSharedObjectID()))
// we're being deactivated
handleDeactivated();
else if (table.contains(e.getDeactivatedID()))
// a local graph we track is being deactivated
handleRemoved(e.getDeactivatedID());
}
}