Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Begin migrating returned values to map-likes that retain backwards co…
…mpatibility For example, to declare a server-named queue and get the generated name back, there is no longer a need to use interop (and know anything about the Java client API).
- Loading branch information
Michael Klishin
committed
Feb 26, 2013
1 parent
366fb54
commit 18aa647
Showing
8 changed files
with
328 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package com.novemberain.langohr; | ||
|
||
import clojure.lang.*; | ||
|
||
import java.util.Iterator; | ||
|
||
public abstract class PersistentMapLike implements IPersistentMap { | ||
protected IPersistentMap map; | ||
|
||
public Object valAt(Object o) { | ||
return this.map.valAt(o); | ||
} | ||
|
||
public Object valAt(Object o, Object o2) { | ||
return this.map.valAt(o, o2); | ||
} | ||
|
||
public IPersistentMap assoc(Object o, Object o2) { | ||
return map.assoc(o, o2); | ||
} | ||
|
||
public IPersistentMap assocEx(Object o, Object o2) { | ||
return map.assocEx(o, o2); | ||
} | ||
|
||
public IPersistentMap without(Object o) { | ||
return map.without(o); | ||
} | ||
|
||
public Iterator iterator() { | ||
return map.iterator(); | ||
} | ||
|
||
public boolean containsKey(Object o) { | ||
return map.containsKey(o); | ||
} | ||
|
||
public IMapEntry entryAt(Object o) { | ||
return map.entryAt(o); | ||
} | ||
|
||
public IPersistentCollection cons(Object o) { | ||
return map.cons(o); | ||
} | ||
|
||
public int count() { | ||
return map.count(); | ||
} | ||
|
||
public IPersistentCollection empty() { | ||
return map.empty(); | ||
} | ||
|
||
public boolean equiv(Object o) { | ||
return map.equiv(o); | ||
} | ||
|
||
public ISeq seq() { | ||
return map.seq(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.novemberain.langohr.exchange; | ||
|
||
import clojure.lang.IPersistentMap; | ||
import clojure.lang.PersistentHashMap; | ||
import com.novemberain.langohr.PersistentMapLike; | ||
import com.rabbitmq.client.AMQP; | ||
|
||
import java.util.HashMap; | ||
|
||
public class DeclareOk extends PersistentMapLike implements AMQP.Exchange.DeclareOk { | ||
private final AMQP.Exchange.DeclareOk method; | ||
|
||
public DeclareOk(AMQP.Exchange.DeclareOk method) { | ||
this.method = method; | ||
|
||
this.map = mapFrom(method); | ||
} | ||
|
||
public static IPersistentMap mapFrom(AMQP.Exchange.DeclareOk method) { | ||
return PersistentHashMap.create(new HashMap()); | ||
} | ||
|
||
public int protocolClassId() { | ||
return method.protocolClassId(); | ||
} | ||
|
||
public int protocolMethodId() { | ||
return method.protocolMethodId(); | ||
} | ||
|
||
public String protocolMethodName() { | ||
return method.protocolMethodName(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.novemberain.langohr.queue; | ||
|
||
import clojure.lang.IPersistentMap; | ||
import clojure.lang.PersistentHashMap; | ||
import com.novemberain.langohr.PersistentMapLike; | ||
import com.rabbitmq.client.AMQP; | ||
|
||
import java.util.HashMap; | ||
|
||
public class BindOk extends PersistentMapLike implements AMQP.Queue.BindOk { | ||
private final AMQP.Queue.BindOk method; | ||
|
||
public BindOk(AMQP.Queue.BindOk method) { | ||
this.method = method; | ||
this.map = mapFrom(method); | ||
} | ||
|
||
public static IPersistentMap mapFrom(AMQP.Queue.BindOk method) { | ||
return PersistentHashMap.create(new HashMap()); | ||
} | ||
|
||
public int protocolClassId() { | ||
return method.protocolClassId(); | ||
} | ||
|
||
public int protocolMethodId() { | ||
return method.protocolMethodId(); | ||
} | ||
|
||
public String protocolMethodName() { | ||
return method.protocolMethodName(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package com.novemberain.langohr.queue; | ||
|
||
import clojure.lang.IPersistentMap; | ||
import clojure.lang.PersistentHashMap; | ||
import clojure.lang.RT; | ||
import com.novemberain.langohr.PersistentMapLike; | ||
import com.rabbitmq.client.AMQP; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class DeclareOk extends PersistentMapLike implements AMQP.Queue.DeclareOk { | ||
private final AMQP.Queue.DeclareOk method; | ||
|
||
public DeclareOk(AMQP.Queue.DeclareOk method) { | ||
this.method = method; | ||
|
||
this.map = mapFrom(method); | ||
|
||
} | ||
|
||
public static IPersistentMap mapFrom(AMQP.Queue.DeclareOk method) { | ||
Map m = new HashMap(); | ||
m.put(RT.keyword(null, "queue"), method.getQueue()); | ||
m.put(RT.keyword(null, "message-count"), method.getMessageCount()); | ||
m.put(RT.keyword(null, "consumer-count"), method.getConsumerCount()); | ||
m.put(RT.keyword(null, "message_count"), method.getMessageCount()); | ||
m.put(RT.keyword(null, "consumer_count"), method.getConsumerCount()); | ||
|
||
return PersistentHashMap.create(m); | ||
} | ||
|
||
public int getConsumerCount() { | ||
return method.getConsumerCount(); | ||
} | ||
|
||
public int getMessageCount() { | ||
return method.getMessageCount(); | ||
} | ||
|
||
public String getQueue() { | ||
return method.getQueue(); | ||
} | ||
|
||
public int protocolClassId() { | ||
return method.protocolClassId(); | ||
} | ||
|
||
public int protocolMethodId() { | ||
return method.protocolMethodId(); | ||
} | ||
|
||
public String protocolMethodName() { | ||
return method.protocolMethodName(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.novemberain.langohr.queue; | ||
|
||
import clojure.lang.IPersistentMap; | ||
import clojure.lang.PersistentHashMap; | ||
import clojure.lang.RT; | ||
import com.novemberain.langohr.PersistentMapLike; | ||
import com.rabbitmq.client.AMQP; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class DeleteOk extends PersistentMapLike implements AMQP.Queue.DeleteOk { | ||
private final AMQP.Queue.DeleteOk method; | ||
|
||
public DeleteOk(AMQP.Queue.DeleteOk method) { | ||
this.method = method; | ||
|
||
this.map = mapFrom(method); | ||
|
||
} | ||
|
||
public static IPersistentMap mapFrom(AMQP.Queue.DeleteOk method) { | ||
Map m = new HashMap(); | ||
m.put(RT.keyword(null, "message-count"), method.getMessageCount()); | ||
m.put(RT.keyword(null, "message_count"), method.getMessageCount()); | ||
|
||
return PersistentHashMap.create(m); | ||
} | ||
|
||
public int getMessageCount() { | ||
return method.getMessageCount(); | ||
} | ||
|
||
public int protocolClassId() { | ||
return method.protocolClassId(); | ||
} | ||
|
||
public int protocolMethodId() { | ||
return method.protocolMethodId(); | ||
} | ||
|
||
public String protocolMethodName() { | ||
return method.protocolMethodName(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.novemberain.langohr.queue; | ||
|
||
import clojure.lang.IPersistentMap; | ||
import clojure.lang.PersistentHashMap; | ||
import clojure.lang.RT; | ||
import com.novemberain.langohr.PersistentMapLike; | ||
import com.rabbitmq.client.AMQP; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class PurgeOk extends PersistentMapLike implements AMQP.Queue.PurgeOk { | ||
private final AMQP.Queue.PurgeOk method; | ||
|
||
public PurgeOk(AMQP.Queue.PurgeOk method) { | ||
this.method = method; | ||
|
||
this.map = mapFrom(method); | ||
|
||
} | ||
|
||
public static IPersistentMap mapFrom(AMQP.Queue.PurgeOk method) { | ||
Map m = new HashMap(); | ||
m.put(RT.keyword(null, "message-count"), method.getMessageCount()); | ||
m.put(RT.keyword(null, "message_count"), method.getMessageCount()); | ||
|
||
return PersistentHashMap.create(m); | ||
} | ||
|
||
public int getMessageCount() { | ||
return method.getMessageCount(); | ||
} | ||
|
||
public int protocolClassId() { | ||
return method.protocolClassId(); | ||
} | ||
|
||
public int protocolMethodId() { | ||
return method.protocolMethodId(); | ||
} | ||
|
||
public String protocolMethodName() { | ||
return method.protocolMethodName(); | ||
} | ||
} |
Oops, something went wrong.