org.curjent.agent
Class FixedTasks

java.lang.Object
  extended by org.curjent.agent.FixedTasks
All Implemented Interfaces:
AgentTasks
Direct Known Subclasses:
FTPTransferTasks

public class FixedTasks
extends Object
implements AgentTasks

Source for a fixed number of tasks.

This implementation is not thread-safe.


Field Summary
private  LinkedList<Object> queue
          List of available tasks.
 
Constructor Summary
FixedTasks(Collection<Object> tasks)
          Saves a copy of the given collection of tasks.
FixedTasks(Object[] tasks)
          Equivalent to FixedTasks(Arrays.asList(tasks)).
 
Method Summary
 Object acquire()
          Removes and returns a task from our list of tasks.
 void release(Object task)
          Adds the given task to our list of available tasks.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

queue

private final LinkedList<Object> queue
List of available tasks.

Constructor Detail

FixedTasks

public FixedTasks(Object[] tasks)
Equivalent to FixedTasks(Arrays.asList(tasks)).


FixedTasks

public FixedTasks(Collection<Object> tasks)
Saves a copy of the given collection of tasks.

Throws:
NullPointerException - tasks is null.
IllegalArgumentException - tasks is empty.
Method Detail

acquire

public Object acquire()
               throws Throwable
Removes and returns a task from our list of tasks. Returns null if our list is empty.

Specified by:
acquire in interface AgentTasks
Throws:
Throwable - An unexpected error.
See Also:
Agent.newInstance(AgentLoader, Class[], AgentTasks, Class)

release

public void release(Object task)
             throws Throwable
Adds the given task to our list of available tasks.

Specified by:
release in interface AgentTasks
Throws:
NullPointerException - tasks is null.
Throwable - An unexpected error.


Copyright 2009-2011 Tom Landon
Apache License 2.0