diff --git a/src/main/java/io/iworkflow/core/ImplementationException.java b/src/main/java/io/iworkflow/core/ImplementationException.java new file mode 100644 index 0000000..5376482 --- /dev/null +++ b/src/main/java/io/iworkflow/core/ImplementationException.java @@ -0,0 +1,12 @@ +package io.iworkflow.core; + +// This indicates issues in the implementation of the workflow +public class ImplementationException extends RuntimeException { + public ImplementationException(Throwable cause) { + super(cause); + } + + public ImplementationException(String message) { + super(message); + } +} diff --git a/src/main/java/io/iworkflow/core/RpcDefinitions.java b/src/main/java/io/iworkflow/core/RpcDefinitions.java index 43ff987..1a00599 100644 --- a/src/main/java/io/iworkflow/core/RpcDefinitions.java +++ b/src/main/java/io/iworkflow/core/RpcDefinitions.java @@ -1,12 +1,11 @@ package io.iworkflow.core; -import com.google.common.collect.ImmutableMap; import io.iworkflow.core.communication.Communication; import io.iworkflow.core.persistence.Persistence; import java.io.Serializable; import java.lang.reflect.Method; -import java.util.Map; +import java.lang.reflect.Modifier; public final class RpcDefinitions { private RpcDefinitions() { @@ -100,12 +99,20 @@ public interface RpcProc0NoPersistence extends Serializable { void execute(Context context, Communication communication); } - public static final String ERROR_MESSAGE = "An RPC method must be in the form of one of {@link RpcDefinitions}"; + public static final String DEFINITION_ERROR_MESSAGE = "An RPC method must be in the form of one of {@link RpcDefinitions}"; + + public static final String FINAL_MODIFIER_ERROR_MESSAGE = "An RPC method must not be final"; public static void validateRpcMethod(final Method method) { RpcMethodMetadata methodMetadata = RpcMethodMatcher.match(method); + final boolean isFinal = Modifier.isFinal(method.getModifiers()); + + if (isFinal) { + throw new ImplementationException(FINAL_MODIFIER_ERROR_MESSAGE); + } + if (methodMetadata == null) { - throw new WorkflowDefinitionException(ERROR_MESSAGE); + throw new WorkflowDefinitionException(DEFINITION_ERROR_MESSAGE); } } }