Interface AutomationService

  • All Known Implementing Classes:
    OperationServiceImpl

    public interface AutomationService
    Service providing an operation registry and operation execution methods. The operation registry is thread-safe and optimized for lookups. Progress monitor for asynchronous executions is not yet implemented.
    Author:
    Bogdan Stefanescu, Guillaume
    • Method Detail

      • putOperation

        void putOperation​(Class<?> type)
                   throws OperationException
        Registers an operation given its class. The operation class MUST be annotated using Operation annotation. If an operation having the same ID exists an exception will be thrown.
        Throws:
        OperationException
      • putOperation

        void putOperation​(Class<?> type,
                          boolean replace)
                   throws OperationException
        Registers an operation given its class. The operation class MUST be annotated using Operation annotation. If the replace argument is true then any existing operation having the same ID will replaced with this one.
        Throws:
        OperationException
      • putOperation

        void putOperation​(Class<?> type,
                          boolean replace,
                          String contributingComponent)
                   throws OperationException
        Registers an operation given its class. The operation class MUST be annotated using Operation annotation. If the replace argument is true then any existing operation having the same ID will replaced with this one. Third argument represents the name of the component registring the operation
        Throws:
        OperationException
      • removeOperation

        void removeOperation​(Class<?> key)
        Removes an operation given its class. If the operation was not registered does nothing.
      • removeOperation

        void removeOperation​(OperationType type)
        Removes an operation given it's type. If the operation was not registered does nothing.
        Since:
        5.9.2
      • getOperations

        OperationType[] getOperations()
        Gets all operation types that was registered.
      • putOperationChain

        @Deprecated
        void putOperationChain​(OperationChain chain,
                               boolean replace)
                        throws OperationException
        Deprecated.
        since 5.9.2 no specific chain registry anymore: chains are now operations, use putOperation(OperationType, boolean) method instead.
        Registers a parametrized operation chain. This chain can be executed later by calling run and passing the chain ID. If the replace attribute is true then any chain already registered under the same id will be replaced otherwise an exception is thrown.
        Throws:
        OperationException
        Since:
        5.7.2
      • removeOperationChain

        @Deprecated
        void removeOperationChain​(String id)
        Deprecated.
        since 5.9.2 no specific chain registry anymore: chains are now operations, use removeOperation(OperationType) method instead.
        Removes a registered operation chain given its ID. Do nothing if the chain was not registered.
        Since:
        5.7.2
      • getOperationChains

        @Deprecated
        List<OperationChain> getOperationChains()
        Deprecated.
        since 5.9.2 no specific chain registry anymore: chains are now operations, use getOperations() method instead.
        Gets a list of all registered chains
        Returns:
        the list or an empty list if no registered chains exists
        Since:
        5.7.2
      • putTypeAdapter

        void putTypeAdapter​(Class<?> accept,
                            Class<?> produce,
                            TypeAdapter adapter)
        Registers a new type adapter that can adapt an instance of the accepted type into one of the produced type.
      • removeTypeAdapter

        void removeTypeAdapter​(Class<?> accept,
                               Class<?> produce)
        Removes a type adapter
      • getTypeAdapter

        TypeAdapter getTypeAdapter​(Class<?> accept,
                                   Class<?> produce)
        Gets a type adapter for the input type accept and the output type produce. Returns null if no adapter was registered for these types.
      • getAdaptedValue

        <T> T getAdaptedValue​(OperationContext ctx,
                              Object toAdapt,
                              Class<?> targetType)
                       throws OperationException
        Adapts an object to a target type if possible otherwise throws an exception. The method must be called in an operation execution with a valid operation context.
        Throws:
        OperationException
      • isTypeAdaptable

        boolean isTypeAdaptable​(Class<?> typeToAdapt,
                                Class<?> targetType)
        Checks whether or not the given type is adaptable into the target type. An instance of an adaptable type can be converted into an instance of the target type.

        This is a shortcut to getTypeAdapter(typeToAdapt, targetType) != null

      • getDocumentation

        List<OperationDocumentation> getDocumentation()
                                               throws OperationException
        Generates a documentation model for all registered operations. The documentation model is generated from operation annotations and can be used in UI tools to describe operations. The returned list is sorted using operation ID. Optional method.
        Throws:
        OperationException
      • hasOperation

        boolean hasOperation​(String id)
        Parameters:
        id - operation ID
        Returns:
        true if operation registry contains the given operation
        Since:
        5.7.2
      • putChainException

        void putChainException​(ChainException exceptionChain)
        Since:
        5.7.3
      • removeExceptionChain

        void removeExceptionChain​(ChainException exceptionChain)
        Since:
        5.7.3
      • getChainExceptions

        ChainException[] getChainExceptions()
        Since:
        5.7.3
      • putAutomationFilter

        void putAutomationFilter​(AutomationFilter automationFilter)
        Since:
        5.7.3
      • removeAutomationFilter

        void removeAutomationFilter​(AutomationFilter automationFilter)
        Since:
        5.7.3
      • hasChainException

        boolean hasChainException​(String onChainId)
        Since:
        5.7.3
      • runInNewTx

        Object runInNewTx​(OperationContext ctx,
                          String chainId,
                          Map<String,​?> chainParameters,
                          Integer timeout,
                          boolean rollbackGlobalOnError)
                   throws OperationException
        This running method execute operation process through a new transaction.
        Parameters:
        ctx - the operation context.
        chainId - the chain Id.
        chainParameters - chain parameters.
        timeout - Transaction timeout.
        rollbackGlobalOnError - Rollback or not transaction after failing.
        Throws:
        OperationException
        Since:
        6.0