Rewrote the code that generates InvocationService marshalling and

dispatching classes in Java to eliminate annoying dependency on the output
format of JDK 1.4.1's javap.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3238 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2004-11-25 04:46:19 +00:00
parent 90621e78de
commit a0d343ff04
6 changed files with 715 additions and 7 deletions
@@ -0,0 +1,71 @@
package $package;
#foreach ($import in $imports)
import $import;
#end
/**
* Provides the implementation of the {@link ${name}Service} interface
* that marshalls the arguments and delivers the request to the provider
* on the server. Also provides an implementation of the response listener
* interfaces that marshall the response arguments and deliver them back
* to the requesting client.
*/
public class ${name}Marshaller extends InvocationMarshaller
implements ${name}Service
{
#foreach ($l in $listeners)
// documentation inherited
public static class ${l.name}Marshaller extends ListenerMarshaller
implements ${l.name}Listener
{
#foreach ($lm in $l.methods)
/** The method id used to dispatch {@link #$lm.method.name}
* responses. */
public static final int $lm.code = $velocityCount;
// documentation inherited from interface
public void $lm.method.name ($lm.argList)
{
omgr.postEvent(new InvocationResponseEvent(
callerOid, requestId, $lm.code,
new Object[] { $lm.getWrappedArgList(false) }));
}
#end
// documentation inherited
public void dispatchResponse (int methodId, Object[] args)
{
switch (methodId) {
#foreach ($lm in $l.methods)
case $lm.code:
((${l.name}Listener)listener).${lm.method.name}(
${lm.getUnwrappedArgList(true)});
return;
#end
default:
super.dispatchResponse(methodId, args);
}
}
}
#end
#foreach ($m in $methods)
/** The method id used to dispatch {@link #$m.method.name} requests. */
public static final int $m.code = $velocityCount;
// documentation inherited from interface
public void $m.method.name ($m.argList)
{
#foreach ($la in $m.listenerArgs)
$la.marshaller listener$la.index = new ${la.marshaller}();
listener${la.index}.listener = arg$la.index;
#end
sendRequest(arg1, $m.code, new Object[] {
$m.getWrappedArgList(true)
});
}
#end
}