summaryrefslogtreecommitdiff
path: root/java/common/generate
diff options
context:
space:
mode:
authorRafael H. Schloming <rhs@apache.org>2007-08-09 02:26:18 +0000
committerRafael H. Schloming <rhs@apache.org>2007-08-09 02:26:18 +0000
commitce1474162e775b693383ed55ebb6dacf562baaa5 (patch)
treed700eaeb06f26a096b926d27e67c8abf49dedc36 /java/common/generate
parentba57e373864d44cfae17ec8c2c9de7a55f0b4113 (diff)
downloadqpid-python-ce1474162e775b693383ed55ebb6dacf562baaa5.tar.gz
updated the amqp.0-10-preview.xml to reflect the latest votes, and added support for execution results
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@564077 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/common/generate')
-rwxr-xr-xjava/common/generate42
1 files changed, 36 insertions, 6 deletions
diff --git a/java/common/generate b/java/common/generate
index f0a91e9d50..35b42e1207 100755
--- a/java/common/generate
+++ b/java/common/generate
@@ -103,7 +103,8 @@ OPTIONS = {}
class Struct:
- def __init__(self, name, base, type, track, content):
+ def __init__(self, node, name, base, type, track, content):
+ self.node = node
self.name = name
self.base = base
self.type = type
@@ -111,6 +112,16 @@ class Struct:
self.content = content
self.fields = []
+ def result(self):
+ r = self.node["result"]
+ if not r: return
+ name = r["@domain"]
+ if not name:
+ name = self.name + "Result"
+ else:
+ name = camel(0, name)
+ return name
+
def field(self, type, name):
self.fields.append((type, name))
@@ -265,6 +276,7 @@ class Visitor(mllib.transforms.Visitor):
name = camel(0, m.parent["@name"], m["@name"])
type = int(m.parent["@index"])*256 + int(m["@index"])
self.structs.append((name, "Method", type, m))
+ self.descend(m)
def do_domain(self, d):
s = d["struct"]
@@ -276,6 +288,15 @@ class Visitor(mllib.transforms.Visitor):
else:
type = int(st)
self.structs.append((name, "Struct", type, s))
+ self.descend(d)
+
+ def do_result(self, r):
+ s = r["struct"]
+ if s:
+ name = camel(0, r.parent.parent["@name"], r.parent["@name"], "Result")
+ type = int(r.parent.parent["@index"]) * 256 + int(s["@type"])
+ self.structs.append((name, "Result", type, s))
+ self.descend(r)
v = Visitor()
spec.dispatch(v)
@@ -284,7 +305,7 @@ opts = Output(out_dir, out_pkg, "Option")
opts.line("public enum Option {")
structs = []
for name, base, typecode, m in v.structs:
- struct = Struct(name, base, typecode,
+ struct = Struct(m, name, base, typecode,
TRACKS.get(m.parent["@name"], "Frame.L4"),
m["@content"] == "1")
for f in m.query["field", lambda f: FIELDS.get(f["@name"], True)]:
@@ -297,7 +318,7 @@ for name, base, typecode, m in v.structs:
OPTIONS[name] = opt_name
opts.line(" %s," % opt_name)
structs.append(struct)
-opts.line(" %s," % "NO_OPTION")
+opts.line(" %s," % "NO_OPTION")
opts.line("}")
opts.write()
@@ -333,13 +354,22 @@ inv = Output(out_dir, out_pkg, "Invoker")
inv.line("public abstract class Invoker {")
inv.line()
inv.line(" protected abstract void invoke(Method method);")
-inv.line(" protected abstract void invoke(Method method, Handler<Struct> handler);")
+inv.line(" protected abstract <T> Future<T> invoke(Method method, Class<T> resultClass);")
inv.line()
for s in structs:
if s.base != "Method": continue
dname = dromedary(s.name)
- inv.line(" public void %s(%s) {" % (dname, s.parameters()))
- inv.line(" invoke(new %s(%s));" % (s.name, s.arguments()))
+ result = s.result()
+ if result:
+ result_type = "Future<%s>" % result
+ else:
+ result_type = "void"
+ inv.line(" public %s %s(%s) {" % (result_type, dname, s.parameters()))
+ if result:
+ inv.line(" return invoke(new %s(%s), %s.class);" %
+ (s.name, s.arguments(), result))
+ else:
+ inv.line(" invoke(new %s(%s));" % (s.name, s.arguments()))
inv.line(" }")
inv.line("}")
inv.write()