net.sourceforge.basher
Class TaskConfiguration

java.lang.Object
  extended by net.sourceforge.basher.TaskConfiguration
Direct Known Subclasses:
TaskContribution

public class TaskConfiguration
extends Object

Container class for holding task configuration options and manipulating certain aspects of it.

Author:
Johan Lindquist

Constructor Summary
TaskConfiguration()
           
 
Method Summary
 void addApplicablePhase(Phase phase)
          Adds the specified phase to the set of applicable phases.
 void clearApplicablePhases()
          Clears the list of applicable phases.
 boolean equals(Object o)
           
 List<Phase> getApplicablePhases()
          Retrieves the Phases in which this Task is run.
 Double getInertia()
          Retrieves the inertia of this TaskConfiguration.
 Integer getMaxInvocations()
          Retrieves the maximum number of times the task should be invoked.
 Integer getMaxTime()
          Returns the default max time for Tasks.
 Long getRunFrom()
          Retrieves the default time from which this task should run.
 Long getStopAfter()
          Retrieves the default time from which this task should stop running.
 String getTaskName()
          Retrieves the name that the Task instance should be known as.
 Integer getWeight()
          Retrieves the weight of this AbstractTask.
 int hashCode()
           
 void initialize(TaskConfiguration taskConfiguration)
           
 void reCalculateWeight()
          Recalculates the weight of this Task.
 void reset()
          Resets the weight calculattions of this TaskConfiguration instance.
 void setInertia(Double inertia)
          Sets the inertia of this AbstractTask.
 void setMaxInvocations(Integer maxInvocations)
          Sets the maximum number of times the task should be invoked.
 void setMaxTime(Integer maxTime)
           
 void setRunFrom(Long runFrom)
          Sets the time from which this task should run.
 void setStopAfter(Long stopAfter)
          Sets the default time from which this task should stop running.
 void setTaskName(String taskName)
          Sets the name that the Task instance should be known as.
 void setWeight(Integer weight)
          Sets the weight for the task.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TaskConfiguration

public TaskConfiguration()
Method Detail

getWeight

public Integer getWeight()
Retrieves the weight of this AbstractTask. This could be used by certain schedulers to allow for more fine grained control of task scheduling

Returns:
A value between 1 and 100 (higher signals a wish to run more frequently)

getInertia

public Double getInertia()
Retrieves the inertia of this TaskConfiguration. See setInertia(Double).

Returns:
The rate of change for this instance.

setInertia

public void setInertia(Double inertia)
Sets the inertia of this AbstractTask. This is used to control the change of the weight assocaited with this task, calculated for each invocation of the task (if it is not 1.0).

Parameters:
inertia - The inertia to give this instance. This should be a value between 0.1 and 2.0.

reset

public void reset()
Resets the weight calculattions of this TaskConfiguration instance.


setWeight

public void setWeight(Integer weight)
Sets the weight for the task. This could be used by a scheduler to control the invocations of the Task.

Parameters:
weight - The weight of the task. Should be a value between 1 and 100.

setMaxInvocations

public void setMaxInvocations(Integer maxInvocations)
Sets the maximum number of times the task should be invoked. See getMaxInvocations() for more information.

Parameters:
maxInvocations - The number of invocations to do. A value of 0 (zero) or less indicates that the task should always be invoked.

getMaxInvocations

public Integer getMaxInvocations()
Retrieves the maximum number of times the task should be invoked. The number returned could be used by a scheduler to control the invocation of the Task.

Returns:
The maximum number of invocations

reCalculateWeight

public void reCalculateWeight()
Recalculates the weight of this Task. This will take the inertia and multiply it with the current weight and cast the result to an integer.


getRunFrom

public Long getRunFrom()
Retrieves the default time from which this task should run.

Returns:
The time from which this task should run. 0 indicates run from start, otherwise specifies the seconds from start of the run phase.

getStopAfter

public Long getStopAfter()
Retrieves the default time from which this task should stop running.

Returns:
The time from which this task should stop running. Always returns Long.MAX_VALUE (run forever) unless overridden by sub-class.

setRunFrom

public void setRunFrom(Long runFrom)
Sets the time from which this task should run.

Parameters:
runFrom - The time from which this task should run. 0 indicates run from start, otherwise specifies the seconds from start of the run phase.

setStopAfter

public void setStopAfter(Long stopAfter)
Sets the default time from which this task should stop running.

Parameters:
stopAfter - The time from which this task should stop running. Always returns Long.MAX_VALUE (run forever) unless overridden by sub-class.

clearApplicablePhases

public void clearApplicablePhases()
Clears the list of applicable phases.


addApplicablePhase

public void addApplicablePhase(Phase phase)
Adds the specified phase to the set of applicable phases. This method will ensure there are no duplicate entries.

Parameters:
phase - The phases to add

getApplicablePhases

public List<Phase> getApplicablePhases()
Retrieves the Phases in which this Task is run. This, by default, returns only Phase.RUN.

Returns:
List of phases this Task should run in - only RUN phase is included by default

getMaxTime

public Integer getMaxTime()
Returns the default max time for Tasks.

Returns:
Always returns -1, signifying no maximum time

setMaxTime

public void setMaxTime(Integer maxTime)

getTaskName

public String getTaskName()
Retrieves the name that the Task instance should be known as.

Returns:
The name of the task instance.

setTaskName

public void setTaskName(String taskName)
Sets the name that the Task instance should be known as.

Parameters:
taskName - The name of the instance.

initialize

public void initialize(TaskConfiguration taskConfiguration)
Parameters:
taskConfiguration -

equals

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

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object


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