com.ibm.streams.operator

Annotation Type OperatorContext.ContextCheck



  • @Documented
    @Retention(value=RUNTIME)
    @Target(value=METHOD)
    public static @interface OperatorContext.ContextCheck
    A method annotated @ContextCheck allows checking of an operator's invocation context. Annotated methods can be executed during SPL compilation and at runtime before Operator.initialize(OperatorContext) is called.

    Annotated methods are searched for in the operator's Java class (which must be an instance of Operator) and all of its super classes. Order of invocation of annotated methods is not defined.
    The annotated method must be public, static and have a single parameter of type OperatorContextChecker. Any other method annotated with @ContextCheck will be ignored.
    At runtime @ContextCheck methods are invoked before invocation of @Parameter annotated methods.

    Here's an example where if the optional parameter user is set then the optional parameter password must also be set.

    
           @ContextCheck
           public static void checkUserPassword(OperatorContextChecker checker) {
              checker.checkDependentParameters("user", "password");
           }
     

    Any exception thrown during the method's invocation causes compilation or runtime invocation to fail.

    Compile time checking using @ContextCheck is only supported by the SPL compiler for Java primitive operators. Invocation of an Operator using the SPL standard toolkit operator spl.utility.JavaOp will not invoke methods annotated with @ContextCheck.

    See Also:
    OperatorContextChecker
    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element and Description
      boolean compile
      Check at compile time.
      boolean runtime
      Check at runtime.
    • Element Detail

      • compile

        public abstract boolean compile
        Check at compile time.
        Returns:
        True to invoke method at SPL compile time, false to not execute at SPL compile time.
        Default:
        true
      • runtime

        public abstract boolean runtime
        Check at runtime.
        Returns:
        True to invoke method at runtime, false to not execute at runtime.
        Default:
        true