Class GenerateAndConsumeTask

  • All Implemented Interfaces:
    ResourceManager, com.rapiddweller.common.MessageHolder, com.rapiddweller.common.ThreadAware, PageListener, Task, java.io.Closeable, java.lang.AutoCloseable

    public class GenerateAndConsumeTask
    extends java.lang.Object
    implements Task, PageListener, ResourceManager, com.rapiddweller.common.MessageHolder
    Task that creates one data set instance per run() invocation and sends it to the specified consumer.

    Created: 01.02.2008 14:39:11
    Author:
    Volker Bergmann
    • Field Detail

      • statements

        protected final java.util.List<Statement> statements
        The Statements.
    • Constructor Detail

      • GenerateAndConsumeTask

        public GenerateAndConsumeTask​(java.lang.String taskName,
                                      java.lang.String productName)
        Instantiates a new Generate and consume task.
        Parameters:
        taskName - the task name
        productName - the product name
    • Method Detail

      • addStatement

        public void addStatement​(Statement statement)
        Add statement.
        Parameters:
        statement - the statement
      • setStatements

        public void setStatements​(java.util.List<Statement> statements)
        Sets statements.
        Parameters:
        statements - the statements
      • getResourceManager

        public ResourceManager getResourceManager()
        Gets resource manager.
        Returns:
        the resource manager
      • setConsumer

        public void setConsumer​(com.rapiddweller.script.Expression<Consumer> consumerExpr)
        Sets consumer.
        Parameters:
        consumerExpr - the consumer expr
      • getConsumer

        public Consumer getConsumer()
        Gets consumer.
        Returns:
        the consumer
      • init

        public void init​(BeneratorContext context)
        Init.
        Parameters:
        context - the context
      • getProductName

        public java.lang.String getProductName()
        Gets product name.
        Returns:
        the product name
      • getRecentProduct

        public ProductWrapper<?> getRecentProduct()
        Gets recent product.
        Returns:
        the recent product
      • getTaskName

        public java.lang.String getTaskName()
        Description copied from interface: Task
        Gets task name.
        Specified by:
        getTaskName in interface Task
        Returns:
        the name of the task.
      • isThreadSafe

        public boolean isThreadSafe()
        Specified by:
        isThreadSafe in interface com.rapiddweller.common.ThreadAware
      • isParallelizable

        public boolean isParallelizable()
        Specified by:
        isParallelizable in interface com.rapiddweller.common.ThreadAware
      • execute

        public TaskResult execute​(com.rapiddweller.common.Context ctx,
                                  com.rapiddweller.common.ErrorHandler errorHandler)
        Description copied from interface: Task
        Executes the task's work, possibly interacting with the context.
        Specified by:
        execute in interface Task
        Parameters:
        ctx - the context
        errorHandler - the error handler
        Returns:
        the task result
      • reset

        public void reset()
        Reset.
      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Specified by:
        close in interface ResourceManager
        Specified by:
        close in interface Task
      • addResource

        public boolean addResource​(java.io.Closeable resource)
        Description copied from interface: ResourceManager
        Add resource boolean.
        Specified by:
        addResource in interface ResourceManager
        Parameters:
        resource - the resource
        Returns:
        the boolean
      • getMessage

        public java.lang.String getMessage()
        Specified by:
        getMessage in interface com.rapiddweller.common.MessageHolder
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • initStatements

        public void initStatements​(BeneratorContext context)
        Init statements.
        Parameters:
        context - the context