Interface VariableInterceptor

All Known Implementing Classes:
ByteArrayVariableValidator, DateVariableTransformer, FileVariableValidator, NullVariableTransformer, ObjectJavaVariableValidator, ObjectJsonVariableTransformer, ObjectXmlVariableTransformer, PrimitiveVariableTransformer, SpinJsonVariableTransformer, SpinXmlVariableTransformer

public interface VariableInterceptor
Interceptor interface for handling variable invocations with type-specific filtering.

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 Type
    Method
    Description
    void
    Executes the interceptor logic for a variable invocation.
    default Set<Class<?>>
    Returns the set of variable value types that this interceptor can handle.
  • Method Details

    • execute

      void execute(VariableInvocation invocation)
      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

      default Set<Class<?>> getTypes()
      Returns the set of variable value types that this interceptor can handle.

      Use Camunda's existing type interfaces like: - PrimitiveValue.class for primitive variables - DateValue.class for date variables - ObjectValue.class for object variables (JSON, XML, Java serialized) - FileValue.class for file variables - SpinValue.class for Spin variables

      If 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