ode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From va...@apache.org
Subject [1/2] git commit: Messages now have an ID.
Date Thu, 15 Aug 2013 14:57:41 GMT
Updated Branches:
  refs/heads/master 212b3ce36 -> 4556e9bc9


Messages now have an ID.


Project: http://git-wip-us.apache.org/repos/asf/ode-jacob/repo
Commit: http://git-wip-us.apache.org/repos/asf/ode-jacob/commit/0a14bc63
Tree: http://git-wip-us.apache.org/repos/asf/ode-jacob/tree/0a14bc63
Diff: http://git-wip-us.apache.org/repos/asf/ode-jacob/diff/0a14bc63

Branch: refs/heads/master
Commit: 0a14bc63845877dee86a2867a70c9ad5df8f657e
Parents: 212b3ce
Author: Tammo van Lessen <vanto@apache.org>
Authored: Thu Aug 15 16:57:03 2013 +0200
Committer: Tammo van Lessen <vanto@apache.org>
Committed: Thu Aug 15 16:57:03 2013 +0200

----------------------------------------------------------------------
 src/main/java/org/apache/ode/jacob/Message.java | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ode-jacob/blob/0a14bc63/src/main/java/org/apache/ode/jacob/Message.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/ode/jacob/Message.java b/src/main/java/org/apache/ode/jacob/Message.java
index ccf2611..5d62135 100644
--- a/src/main/java/org/apache/ode/jacob/Message.java
+++ b/src/main/java/org/apache/ode/jacob/Message.java
@@ -21,6 +21,7 @@ package org.apache.ode.jacob;
 import java.io.Serializable;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicLong;
 
 
 /**
@@ -31,6 +32,8 @@ import java.util.concurrent.ConcurrentHashMap;
 public class Message implements Serializable {
     private static final long serialVersionUID = -2118625760125445959L;
     
+    private static final AtomicLong idGen = new AtomicLong();
+    
     private long id;
     private ChannelRef to;	
     private ChannelRef replyTo;
@@ -39,7 +42,7 @@ public class Message implements Serializable {
 	private Object body;
 
 	public Message() {
-		id = 0;	// TODO: generate id
+		id = idGen.incrementAndGet();
 		// TODO: always allocating headers may not be a good idea
 		//  checking for non-null headers in the getters below is 
 		//  not great either; should look into a better option later
@@ -111,8 +114,7 @@ public class Message implements Serializable {
     public static Message copyFrom(Message message) {
 	    Message result = new Message();
 	    
-	    //XXX: generate id
-	    result.setId(0);
+	    result.setId(idGen.incrementAndGet());
 	    
 	    result.setAction(message.getAction());
 	    result.setBody(message.getBody());


Mime
View raw message