Annotation Type OperationMethod


  • @Retention(RUNTIME)
    @Target(METHOD)
    public @interface OperationMethod
    To be used to mark methods provided by an operation. A method must have at most one argument which is the operation input and a return type which is the operation output. Methods with zero parameters (void input) will match any input. An operation may have multiple methods if it supports multiple input and output types.

    For each INPUT/OUTPUT type association you must create a new method in an operation and annotate it using this annotation. The set of input types available in an operation are the operation accepted types and the set of output types are the operation produced types. A produced type will become the input type for the next operation in the chain, that will be dispatched to the right method that know how to consume the type.

    When an operation provides 2 methods accepting the same input type the chain will need to take a decision to determine the best way to continue. A common algorithm to find the right path until the end of the chain is backtracking: from a set of potential nodes one is selected to be visited (randomly or not). If the node is a dead end then another node from the set is taken until the path to the last node is created.

    A chain may have no paths until the last operation. In this case the chain is invalid and the chain processor will trigger an error. Also, a chain can provide multiple paths to the last operation. To help the engine to find the best path until the last operation you can use the priority() attribute to specify which method is preferred. The default priority is 0 (e.g. no priority). Higher priorities have more chance to be selected when a conflict occurs. If no user priority is specified (i.e. priority is 0) then the default priority is used. Here is how the default priority is computed (the top most case has the greater priority):

    • The input type is an exact match of the method declared argument
    • The method argument type is assignable from the input type (i.e. a super type but not an exact match)
    • The input can be adapted to the method argument using registered type adapters
    • the method has no arguments (void input)
    If no one of these rules applies then the method will not match the input.

    The class owning the annotated method must be annotated using Operation

    Author:
    Bogdan Stefanescu
    • Element Detail

      • collector

        Class<? extends OutputCollector> collector
        If defined the method is iterable.

        It means that when such a method is called with an input type of Iterable<INPUT> (where INPUT is the declared method input type) the method will be iteratively called to generate all the outputs and collect them using the given OutputCollector.

        Default:
        org.nuxeo.ecm.automation.OutputCollector.class
      • priority

        int priority
        Default:
        0
      • asyncService

        Class<? extends AsyncService> asyncService
        Default:
        org.nuxeo.ecm.core.api.AsyncService.class