net.sourceforge.basher
Class TaskExecutionContext

java.lang.Object
  extended by net.sourceforge.basher.TaskExecutionContext

public class TaskExecutionContext
extends Object

Holder class for a Task and TaskConfiguration combination. Class also manages basic statistics for the invocation of a class, such as invocation counts etc.

Author:
Johan Lindquist

Constructor Summary
TaskExecutionContext(Task task)
          Deprecated.  
TaskExecutionContext(UUID identifier, Task task, TaskConfiguration taskConfiguration)
          Creates a new TaskExecutionContext, wrapping the specified task and task configuration.
 
Method Summary
 void addFollower(TaskExecutionContext taskExecutionContext)
           
 void clearFollowers()
           
 boolean equals(Object o)
           
 void executeTask()
          Main method that should be called by the component that executes tasks.
 int getFailures()
          Retrieves the number of failed invocation of the embedded task.
 Set<TaskExecutionContext> getFollowers()
           
 UUID getIdentifier()
           
 int getInvocations()
          Retrieves the number of times this task was invoked (successes+failures).
 int getNotRun()
          Retrieves the number times the task chose to not run.
 int getSuccesses()
          Retrieves the number of successful invocations of the embedded task.
 Task getTask()
          Retrieves the task embedded in this TaskExecutionContext.
 TaskConfiguration getTaskConfiguration()
           
 int hashCode()
           
 void releaseInvocation()
           
 void reserveInvocation()
           
 void setIdentifier(UUID identifier)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TaskExecutionContext

public TaskExecutionContext(Task task)
Deprecated. 

Parameters:
task -

TaskExecutionContext

public TaskExecutionContext(UUID identifier,
                            Task task,
                            TaskConfiguration taskConfiguration)
Creates a new TaskExecutionContext, wrapping the specified task and task configuration.

Parameters:
identifier - Identifier of the context, used for referencing this context
task - The task to wrap
taskConfiguration - The configuration of the task
Method Detail

getTask

public Task getTask()
Retrieves the task embedded in this TaskExecutionContext.

Returns:
The embedded task

getTaskConfiguration

public TaskConfiguration getTaskConfiguration()

getFailures

public int getFailures()
Retrieves the number of failed invocation of the embedded task.

Returns:
The number of failed invocations.

getSuccesses

public int getSuccesses()
Retrieves the number of successful invocations of the embedded task.

Returns:
The number of successful invocations.

getNotRun

public int getNotRun()
Retrieves the number times the task chose to not run. The task must throw a NotRunException for this counter to be incremented.

Returns:
The number of times the embedded task chose to not run.

reserveInvocation

public void reserveInvocation()

releaseInvocation

public void releaseInvocation()

getInvocations

public int getInvocations()
Retrieves the number of times this task was invoked (successes+failures).

Returns:
The number of invocations.

executeTask

public void executeTask()
                 throws Throwable
Main method that should be called by the component that executes tasks. This method ensures that counters of failures/successes are kept up to date for the task in question.

Throws:
Throwable - Any exception thrown by the embedded task when invoking the executeTask method are re-thrown by this method.

getIdentifier

public UUID getIdentifier()

setIdentifier

public void setIdentifier(UUID identifier)

addFollower

public void addFollower(TaskExecutionContext taskExecutionContext)

clearFollowers

public void clearFollowers()

getFollowers

public Set<TaskExecutionContext> getFollowers()

toString

public String toString()
Overrides:
toString in class Object

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object


Copyright © 2006-2010 Basher Team. All Rights Reserved.