Interface VariableInterceptor
- All Known Implementing Classes:
ByteArrayVariableValidator,DateVariableTransformer,FileVariableValidator,NullVariableTransformer,ObjectJavaVariableValidator,ObjectJsonVariableTransformer,ObjectXmlVariableTransformer,PrimitiveVariableTransformer,SpinJsonVariableTransformer,SpinXmlVariableTransformer
Implement this interface to define custom logic that should be executed when a variable is accessed or modified during migration. Interceptors can specify which variable types they handle using Camunda's existing type system, allowing the system to only call relevant interceptors.
Usage Examples:
Type-specific interceptor using Camunda types:
@Component
public class JsonVariableInterceptor implements VariableInterceptor {
@Override
public Set<Class<?>> getTypes() {
return Set.of(ObjectValue.class); // Handle ObjectValue types
}
@Override
public void execute(VariableInvocation invocation) {
// This will only be called for ObjectValue variables
ObjectValue objectValue = (ObjectValue) invocation.getC7Variable().getTypedValue();
// Process based on serialization format
}
}
Universal interceptor (handles all types):
@Component
public class UniversalInterceptor implements VariableInterceptor {
@Override
public Set<Class<?>> getTypes() {
return Set.of(); // Empty set = handle all types
}
@Override
public void execute(VariableInvocation invocation) {
// This will be called for all variable types
logVariableAccess(invocation.getC7Variable());
}
}
Disabling interceptors via YAML configuration:
migrator:
interceptors:
- className: "io.camunda.migrator.impl.interceptor.SpinJsonVariableTransformer"
enabled: false
-
Method Summary
Modifier and TypeMethodDescriptionvoidexecute(VariableInvocation invocation) Executes the interceptor logic for a variable invocation.getTypes()Returns the set of variable value types that this interceptor can handle.
-
Method Details
-
execute
Executes the interceptor logic for a variable invocation. This method will only be called if the variable type matches one of the supported types.- Parameters:
invocation- the variable invocation containing C7 variable data and methods to modify it
-
getTypes
Returns the set of variable value types that this interceptor can handle.Use Camunda's existing type interfaces like: -
PrimitiveValue.classfor primitive variables -DateValue.classfor date variables -ObjectValue.classfor object variables (JSON, XML, Java serialized) -FileValue.classfor file variables -SpinValue.classfor Spin variablesIf the returned set is empty, this interceptor will be called for all variable types.
Default implementation returns an empty set (handle all types) for backward compatibility.
- Returns:
- set of supported variable value types, or empty set to handle all types
-