01: package vicazh.hyperpool.stream;
02:
03: import java.util.*;
04:
05: /**
06: * The control list selector
07: *
08: * @author Victor Zhigunov
09: * @version 0.4.0
10: */
11: public class ControlListSelector extends ListSelector implements
12: ControlListSelectorMBean {
13:
14: public List<Object> getListObject() {
15: Priority p = new Priority();
16: p.setClient(Priority.NO_LIMIT_PRIORITY);
17: p.setServer(Priority.NO_LIMIT_PRIORITY);
18: return p;
19: }
20:
21: private Timer timer;
22:
23: public void start() throws Exception {
24: timer = new Timer();
25: timer.schedule(new TimerTask() {
26: public void run() {
27: for (Object o : getList())
28: ((Priority) o).action();
29: }
30: }, 1000, 1000);
31: super .start();
32: }
33:
34: public void stop() throws Exception {
35: timer.cancel();
36: super.stop();
37: }
38:
39: }
|