Files
narya/src/main/resources/com/threerings/presents/tools/marshaller.tmpl
T
Michael Bayne 217927de2b A variety of javadoc fixes.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@6533 542714f4-19e9-0310-aa3c-eee0fc999fb1
2011-03-15 18:17:09 +00:00

83 lines
2.3 KiB
Cheetah

package {{package}};
import javax.annotation.Generated;
{{#imports}}
import {{this}};
{{/imports}}
/**
* 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.
*/
{{generated}}
public class {{name}}Marshaller extends InvocationMarshaller
implements {{name}}Service
{
{{#listeners}}
/**
* Marshalls results to implementations of {@code {{name}}Service.{{listenerName}}Listener}.
*/
public static class {{listenerName}}Marshaller extends ListenerMarshaller
implements {{listenerName}}Listener
{
{{#methods}}
/** The method id used to dispatch {@link #{{method.name}}}
* responses. */
public static final int {{code}} = {{-index}};
// from interface {{listenerName}}Marshaller
public void {{method.name}} ({{getArgList}})
{
_invId = null;
omgr.postEvent(new InvocationResponseEvent(
callerOid, requestId, {{code}},
new Object[] { {{getWrappedArgList}} }, transport));
}
{{/methods}}
@Override // from InvocationMarshaller
public void dispatchResponse (int methodId, Object[] args)
{
switch (methodId) {
{{#methods}}
case {{code}}:
(({{listenerName}}Listener)listener).{{method.name}}(
{{getUnwrappedArgListAsListeners}});
return;
{{/methods}}
default:
super.dispatchResponse(methodId, args);
return;
}
}
}
{{/listeners}}
{{#methods}}
{{^-first}}
{{/-first}}
/** The method id used to dispatch {@link #{{method.name}}} requests. */
public static final int {{code}} = {{-index}};
// from interface {{name}}Service
public void {{method.name}} ({{getArgList}})
{
{{#listenerArgs}}
{{marshaller}} listener{{index}} = new {{marshaller}}();
listener{{index}}.listener = arg{{index}};
{{/listenerArgs}}
sendRequest({{code}}, new Object[] {
{{#hasArgs}}
{{getWrappedArgList}}
{{/hasArgs}}
}{{transport}});
}
{{/methods}}
}