Skip to content

Commit 2535869

Browse files
committed
cleanup
1 parent 6b01d66 commit 2535869

3 files changed

Lines changed: 8 additions & 18 deletions

File tree

cayenne/src/main/java/org/apache/cayenne/access/DataContext.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ protected void attachToChannel(DataChannel channel) {
243243
setEntityResolver(channel.getEntityResolver());
244244

245245
if (mergeHandler != null) {
246-
mergeHandler.setActive(false);
246+
mergeHandler.stop();
247247
mergeHandler = null;
248248
}
249249

cayenne/src/main/java/org/apache/cayenne/access/DataContextMergeHandler.java

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,33 +38,28 @@
3838

3939
/**
4040
* A listener of GraphEvents sent by the DataChannel that merges changes to the DataContext.
41-
*
41+
*
4242
* @since 1.2
4343
*/
44-
// TODO: andrus, 11/25/2006 - this logic is the same as the logic in DataRowUtils used to
45-
// merge snapshot changes. Any way to reconclie the two? (in fact DataRowUtils is more
46-
// comprehensive)
4744
class DataContextMergeHandler implements GraphChangeHandler, DataChannelListener {
4845

49-
private boolean active;
5046
private final DataContext context;
47+
private volatile boolean stopped;
5148

5249
DataContextMergeHandler(DataContext context) {
53-
this.active = true;
5450
this.context = context;
5551
}
5652

57-
void setActive(boolean active) {
58-
this.active = active;
53+
void stop() {
54+
this.stopped = true;
5955
}
6056

6157
/**
62-
* Returns true if this object is active and an event came from our channel, but did
63-
* not originate in it.
58+
* Returns true if this object is active and an event came from our channel, but did not originate in it.
6459
*/
6560
private boolean shouldProcessEvent(GraphEvent e) {
6661

67-
if (!active) {
62+
if (stopped) {
6863
return false;
6964
}
7065

@@ -149,7 +144,7 @@ public void nodeIdChanged(Object nodeId, Object newId) {
149144
public void nodeRemoved(Object nodeId) {
150145
ObjectStore os = context.getObjectStore();
151146
synchronized (os) {
152-
os.processDeletedID((ObjectId)nodeId);
147+
os.processDeletedID((ObjectId) nodeId);
153148
}
154149
}
155150

cayenne/src/main/java/org/apache/cayenne/access/DataContextSnapshotBuilder.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,6 @@
3838

3939
import java.util.Map;
4040

41-
/**
42-
* {@link DataContext} delegates object snapshot creation to this class
43-
*
44-
* @see DataContext#currentSnapshot(Persistent)
45-
*/
4641
class DataContextSnapshotBuilder implements PropertyVisitor {
4742

4843
private final EntityResolver resolver;

0 commit comments

Comments
 (0)