1 23 24 29 42 43 48 49 package com.sun.enterprise.util.threadpool; 50 51 import com.sun.enterprise.util.collection.BlockingQueue; 52 import com.sun.enterprise.util.collection.TooManyTasksException; 53 import com.sun.enterprise.util.collection.QueueClosedException; 54 import java.util.ArrayList ; 55 56 63 public class TaskQueue extends BlockingQueue 64 { 65 66 private TaskFactory taskFactory; 67 68 74 public TaskQueue(TaskFactory factory) { 75 super(); 76 taskFactory = factory; 77 } 78 79 86 public TaskQueue(int queueLimit, TaskFactory factory) { 87 super(queueLimit); 88 taskFactory = factory; 89 } 90 91 94 public void addFirst(Object o) 95 throws TooManyTasksException, QueueClosedException 96 { 97 super.addFirst(taskFactory.createTask(o)); 98 } 99 100 103 public void addFirst(Servicable ser) 104 throws TooManyTasksException, QueueClosedException 105 { 106 super.addFirst(ser); 107 } 108 109 112 public void addLast(Object o) 113 throws TooManyTasksException, QueueClosedException 114 { 115 super.addLast(taskFactory.createTask(o)); 116 } 117 118 121 public void addLast(Servicable ser) 122 throws TooManyTasksException, QueueClosedException 123 { 124 super.addLast(ser); 125 } 126 127 130 public void add(int index, Object object) 131 throws TooManyTasksException, QueueClosedException 132 { 133 super.add(index, taskFactory.createTask(object)); 134 } 135 136 public void addAll(ArrayList arrayList) 137 throws TooManyTasksException, QueueClosedException 138 { 139 for (int i=0; i < arrayList.size(); i++) { 140 Object o = taskFactory.createTask(arrayList.get(i)); 141 arrayList.set(i, o); 142 } 143 super.addAll(arrayList); 144 } 145 146 150 public void destroyTask(Object o) 151 { 152 taskFactory.deleteTask(o); 153 } 154 } 155 | Popular Tags |