for (Method method : interfaze.getMethods()) {
if (method.getDeclaringClass().getAnnotation(Workflow.class) == null) {
continue;
}
Execute executeAnnotation = method.getAnnotation(Execute.class);
Signal signalAnnotation = method.getAnnotation(Signal.class);
GetState getStateAnnotation = method.getAnnotation(GetState.class);
checkAnnotationUniqueness(method, executeAnnotation, signalAnnotation, getStateAnnotation);
if (executeAnnotation != null) {
if (workflowImplementationMethod != null) {
throw new IllegalArgumentException(
"Interface annotated with @Workflow is allowed to have only one method annotated with @Execute. Found "
+ getMethodFullName(workflowImplementationMethod.getMethod()) + " and "
+ getMethodFullName(method));
}
if (!method.getReturnType().equals(void.class) && !(Promise.class.isAssignableFrom(method.getReturnType()))) {
throw new IllegalArgumentException(
"Workflow implementation method annotated with @Execute can return only Promise or void: "
+ getMethodFullName(method));
}
if (!method.getDeclaringClass().equals(interfaze)) {
throw new IllegalArgumentException("Interface " + interfaze.getName()
+ " cannot inherit workflow implementation method annotated with @Execute: "
+ getMethodFullName(method));
}
DataConverter converter = createConverter(workflowAnnotation.dataConverter(), converterOverride);
workflowImplementationMethod = new MethodConverterPair(method, converter);
workflowType = getWorkflowType(interfaceName, method, executeAnnotation);
WorkflowRegistrationOptions registrationOptionsAnnotation = interfaze.getAnnotation(WorkflowRegistrationOptions.class);
SkipTypeRegistration skipRegistrationAnnotation = interfaze.getAnnotation(SkipTypeRegistration.class);
if (skipRegistrationAnnotation == null) {
if (registrationOptionsAnnotation == null) {
throw new IllegalArgumentException(
"@WorkflowRegistrationOptions is required for the interface that contains method annotated with @Execute");
}
registrationOptions = createRegistrationOptions(registrationOptionsAnnotation);
}
else {
if (registrationOptionsAnnotation != null) {
throw new IllegalArgumentException(
"@WorkflowRegistrationOptions is not allowed for the interface annotated with @SkipTypeRegistration.");
}
}
}
if (signalAnnotation != null) {
String signalName = signalAnnotation.name();
if (signalName == null || signalName.isEmpty()) {
signalName = method.getName();
}
DataConverter signalConverter = createConverter(workflowAnnotation.dataConverter(), converterOverride);
signals.put(signalName, new MethodConverterPair(method, signalConverter));