templates.ServiceDefinitionFactory.hbs Maven / Gradle / Ivy
The newest version!
{{#if originalClassPkg}}package {{originalClassPkg}};{{/if}}
public class {{generatedClassSimpleName}} implements dev.restate.sdk.common.syscalls.ServiceDefinitionFactory<{{originalClassFqcn}}, dev.restate.sdk.HandlerRunner.Options> {
@java.lang.Override
public dev.restate.sdk.common.syscalls.ServiceDefinition create({{originalClassFqcn}} bindableService) {
return dev.restate.sdk.common.syscalls.ServiceDefinition.of(
{{generatedClassSimpleNamePrefix}}Definitions.SERVICE_NAME,
{{#if isObject}}dev.restate.sdk.common.ServiceType.VIRTUAL_OBJECT{{else if isWorkflow}}dev.restate.sdk.common.ServiceType.WORKFLOW{{else}}dev.restate.sdk.common.ServiceType.SERVICE{{/if}},
java.util.List.of(
{{#handlers}}
dev.restate.sdk.common.syscalls.HandlerDefinition.of(
dev.restate.sdk.common.syscalls.HandlerSpecification.of(
"{{name}}",
{{#if isExclusive}}dev.restate.sdk.common.HandlerType.EXCLUSIVE{{else if isWorkflow}}dev.restate.sdk.common.HandlerType.WORKFLOW{{else}}dev.restate.sdk.common.HandlerType.SHARED{{/if}},
{{inputSerdeRef}},
{{outputSerdeRef}}
){{#if inputAcceptContentType}}.withAcceptContentType("{{inputAcceptContentType}}"){{/if}},
dev.restate.sdk.HandlerRunner.of(bindableService::{{name}})
){{#unless @last}},{{/unless}}
{{/handlers}}
)
);
}
@java.lang.Override
public boolean supports(Object serviceObject) {
return serviceObject instanceof {{originalClassFqcn}};
}
}