zserio
zserio copied to clipboard
Consider to use interface and delegation in generated Java Service interface
Currently, the generated Java Service interface for server forces users to use inheritance to implement protected methods:
public final class SimpleService
{
public static abstract class SimpleServiceService implements zserio.runtime.service.ServiceInterface
{
public SimpleServiceService()
{
...
}
@Override
public byte[] callMethod(java.lang.String methodName, byte[] requestData, java.lang.Object context)
throws zserio.runtime.ZserioError
{
...
}
public static java.lang.String serviceFullName()
{
return SERVICE_FULL_NAME;
}
public static java.lang.String[] methodNames()
{
return new java.lang.String[]
{
"powerOfTwo"
};
}
protected abstract service_types.simple_service.Response powerOfTwoImpl(
service_types.simple_service.Request request, java.lang.Object context);
private byte[] powerOfTwoMethod(byte[] requestData, java.lang.Object context)
throws zserio.runtime.ZserioError
{
...
}
...
Consider to use interface and delegation instead of that. Then, user can provide an implementation of interface in SimpleServiceService
constructor instead of inheritance and implementation of protected methods.
Please note that if we decide to change Java Service interface in the suggested way, we should change similarly generated C++ and Python Service interface.