FileDocCategorySizeDatePackage
TaskQueue.javaAPI DocGlassfish v2 API5648Fri May 04 22:32:20 BST 2007com.sun.enterprise.util.threadpool

TaskQueue

public class TaskQueue extends com.sun.enterprise.util.collection.BlockingQueue
TaskQueue provides the user the ability to queue his objects without worring about the usage of the TaskQueue by the ThreadPool. The responsibility of the Task creation is now delegated to the TaskFactory. TaskFactory will create or pool the task objects that wrap the users object. The tasks need to implement the Serviceable interface

Fields Summary
private TaskFactory
taskFactory
Constructors Summary
public TaskQueue(TaskFactory factory)
Create a TaskQueue that has an infinite queuelength with the specified timeout.

param
The maximum time remove() will block.
see
remove()

		super();
		taskFactory = factory;
	
public TaskQueue(int queueLimit, TaskFactory factory)
Create a TaskQueue that has the specified queue limit with the specified timeout.

param
The maximum time remove() will block.
param
The queue length after which TooManyTasksException is thrown.
see
remove()

		super(queueLimit);
		taskFactory = factory;
	
Methods Summary
public voidadd(int index, java.lang.Object object)
Add the job at the specified position. Probably based on priority?

		super.add(index, taskFactory.createTask(object));
	
public voidaddAll(java.util.ArrayList arrayList)

		for (int i=0; i < arrayList.size(); i++) {
			Object o = taskFactory.createTask(arrayList.get(i));
			arrayList.set(i, o);
		}
		super.addAll(arrayList);
	
public voidaddFirst(java.lang.Object o)
Add to the head of the queue. Probably a high priority job?

		super.addFirst(taskFactory.createTask(o));
	
public voidaddFirst(Servicable ser)
Add to the head of the queue. Probably a high priority job?

		super.addFirst(ser);
	
public voidaddLast(java.lang.Object o)
Add to the tail of the queue.

		super.addLast(taskFactory.createTask(o));
	
public voidaddLast(Servicable ser)
Add to the tail of the queue.

		super.addLast(ser);
	
public voiddestroyTask(java.lang.Object o)
Hook to enable factory to deleteTask. The deleteTask can potentially return the object to some pool

		taskFactory.deleteTask(o);