package $package;

import javax.annotation.Generated;

#foreach ($import in $imports)
import $import;
#end

/**
 * Dispatches requests to the {@link ${name}Provider}.
 */
${generated}
public class ${name}Dispatcher extends InvocationDispatcher<${name}Marshaller>
{
    /**
     * Creates a dispatcher that may be registered to dispatch invocation
     * service requests for the specified provider.
     */
    public ${name}Dispatcher (${name}Provider provider)
    {
        this.provider = provider;
    }

    @Override
    public ${name}Marshaller createMarshaller ()
    {
        return new ${name}Marshaller();
    }

    @Override
    public void dispatchRequest (
        ClientObject source, int methodId, Object[] args)
        throws InvocationException
    {
        switch (methodId) {
#foreach ($m in $methods)
        case ${name}Marshaller.$m.code:
            ((${name}Provider)provider).${m.method.name}(
                source#if ($m.hasArgs(true)), #end$m.getUnwrappedArgList(false)
            );
            return;

#end
        default:
            super.dispatchRequest(source, methodId, args);
            return;
        }
    }
}
