1 19 20 package org.apache.cayenne.remote; 21 22 import org.apache.cayenne.DataChannel; 23 import org.apache.cayenne.ObjectContext; 24 import org.apache.cayenne.graph.GraphDiff; 25 26 35 public class SyncMessage implements ClientMessage { 36 37 protected transient ObjectContext source; 38 protected int type; 39 protected GraphDiff senderChanges; 40 41 private SyncMessage() { 43 44 } 45 46 public SyncMessage(ObjectContext source, int syncType, GraphDiff senderChanges) { 47 if (syncType != DataChannel.FLUSH_NOCASCADE_SYNC 49 && syncType != DataChannel.FLUSH_CASCADE_SYNC 50 && syncType != DataChannel.ROLLBACK_CASCADE_SYNC) { 51 throw new IllegalArgumentException ("'type' is invalid: " + syncType); 52 } 53 54 this.source = source; 55 this.type = syncType; 56 this.senderChanges = senderChanges; 57 } 58 59 62 public ObjectContext getSource() { 63 return source; 64 } 65 66 public int getType() { 67 return type; 68 } 69 70 public GraphDiff getSenderChanges() { 71 return senderChanges; 72 } 73 74 public String toString() { 75 switch (type) { 76 case DataChannel.FLUSH_NOCASCADE_SYNC: 77 return "flush-sync"; 78 case DataChannel.FLUSH_CASCADE_SYNC: 79 return "flush-cascade-sync"; 80 case DataChannel.ROLLBACK_CASCADE_SYNC: 81 return "rollback-cascade-sync"; 82 default: 83 return "unknown-sync"; 84 } 85 } 86 } 87 | Popular Tags |