Files
narya/src/main/resources/com/threerings/presents/tools/marshaller.tmpl
T
Michael Bayne fc7706c79d Get the transport specification out of the construction path, since it's not a
streamed property of the event. It turns out to be cleaner to just set it in
the places where we know that we want a specific transport anyway.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@6581 542714f4-19e9-0310-aa3c-eee0fc999fb1
2011-04-02 00:01:46 +00:00

80 lines
2.2 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}})
{
sendResponse({{code}}, new Object[] { {{getWrappedArgList}} });
}
{{/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}}
}