/** * Sets the context channel, setting up a listener for channel events. */ public void setChannel(DataChannel channel) { if (this.channel != channel) { if (this.mergeHandler != null) { this.mergeHandler.active = false; this.mergeHandler = null; } this.channel = channel; EventManager eventManager = (channel != null) ? channel.getEventManager() : null; if (eventManager != null) { this.mergeHandler = new CayenneContextMergeHandler(this); // listen to our channel events... // note that we must reset listener on channel switch, as there is no // guarantee that a new channel uses the same EventManager. EventUtil.listenForChannelEvents(channel, mergeHandler); } } }
/** * @since 3.1 */ @Override protected void attachToChannel(DataChannel channel) { super.attachToChannel(channel); if (mergeHandler != null) { mergeHandler.active = false; mergeHandler = null; } EventManager eventManager = channel.getEventManager(); if (eventManager != null) { mergeHandler = new CayenneContextMergeHandler(this); // listen to our channel events... // note that we must reset listener on channel switch, as there is // no // guarantee that a new channel uses the same EventManager. EventUtil.listenForChannelEvents(channel, mergeHandler); } }
void graphCommitted(GraphDiff parentSyncDiff) { if (parentSyncDiff != null) { new CayenneContextMergeHandler(context).merge(parentSyncDiff); } remapTargets(); stateLog.graphCommitted(); reset(); if (lifecycleEventsEnabled) { // include all diffs after the commit start marker. // We fire event as if it was posted by parent channel, so that // nested contexts could catch it context.fireDataChannelCommitted(context.getChannel(), parentSyncDiff); } }
void graphCommitted(GraphDiff parentSyncDiff) { if (parentSyncDiff != null) { new CayenneContextMergeHandler(context).merge(parentSyncDiff); } if (lifecycleEventsEnabled) { GraphDiff diff = changeLog.getDiffsAfterMarker(COMMIT_MARKER); stateLog.graphCommitted(); reset(); // include all diffs after the commit start marker. send(diff, DataChannel.GRAPH_FLUSHED_SUBJECT, context); } else { stateLog.graphCommitted(); reset(); } }