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}} }