Your browser does not support JavaScript and this site utilizes JavaScript to build content and provide links to additional information. You should either enable JavaScript in your browser settings or use a browser that supports JavaScript in order to take full advantage of this site.
1 package com.sslexplorer.tasks; 2 3 import java.util.ArrayList ; 4 import java.util.Collection ; 5 6 import com.sslexplorer.boot.Util; 7 import com.sslexplorer.security.SessionInfo; 8 9 public abstract class AbstractTask implements Task { 10 11 private String bundle; 12 private String name; 13 private String note; 14 private Collection <TaskProgressBar> progressBars; 15 private SessionInfo session; 16 private boolean completed; 17 private int id; 18 private boolean configured; 19 private Object configLock = new Object (); 20 21 public AbstractTask(String bundle, String name) { 22 this.bundle = bundle; 23 this.name = name; 24 progressBars = new ArrayList <TaskProgressBar>(); 25 } 26 27 public void configured() { 28 if(configured) { 29 throw new IllegalStateException ("Already configured."); 30 } 31 notifyConfigLock(); 32 } 33 34 void notifyConfigLock() { 35 synchronized(configLock) { 36 configured = true; 37 configLock.notifyAll(); 38 } 39 } 40 41 public void waitForConfiguration() { 42 synchronized(configLock) { 43 while(!completed && !configured) { 44 try { 45 configLock.wait(1000); 46 } catch (InterruptedException e) { 47 } 48 } 49 } 50 51 } 52 53 public SessionInfo getSession() { 54 return session; 55 } 56 57 public void init(SessionInfo session, int id) { 58 if(this.session != null) { 59 throw new IllegalStateException ("Task already attached to session."); 60 } 61 this.id = id; 62 this.session = session; 63 } 64 65 public void addProgressBar(TaskProgressBar progressBar) { 66 progressBars.add(progressBar); 67 } 68 69 public void clearProgressBars() { 70 progressBars.clear(); 71 } 72 73 public String getBundle() { 74 return bundle; 75 } 76 77 public String getName() { 78 return name; 79 } 80 81 public void setNote(String note) { 82 this.note = note; 83 } 84 85 public String getNote() { 86 return note; 87 } 88 89 public Collection <TaskProgressBar> getProgressBars() { 90 return progressBars; 91 } 92 93 public boolean isComplete() { 94 return completed; 95 } 96 97 public boolean isConfigured() { 98 return configured; 99 } 100 101 public int getId() { 102 return id; 103 } 104 105 public void complete() { 106 if(completed) { 107 throw new IllegalStateException ("Already completed."); 108 } 109 completed = true; 110 notifyConfigLock(); 111 } 112 113 } 114
| Popular Tags
|