1 23 package org.hammurapi.results; 24 25 import java.util.Stack ; 26 27 import org.hammurapi.HammurapiException; 28 29 import com.pavelvlasov.jsel.CompilationUnit; 30 import com.pavelvlasov.persistence.Storage; 31 32 36 public abstract class ResultsFactory { 37 40 public interface Task { 41 void execute() throws HammurapiException; 42 } 43 44 private static ResultsFactory instance; 45 46 49 public void install() { 50 instance=this; 51 } 52 53 public static ResultsFactory getInstance() { 54 return instance; 55 } 56 57 public abstract AggregatedResults newAggregatedResults(); 58 59 public abstract NamedResults newNamedResults(String name); 60 61 public abstract DetailedResults newDetailedResults(String name); 62 63 public abstract CompositeResults newCompositeResults(String name); 64 65 public abstract ReviewResults newReviewResults(CompilationUnit compilationUnit); 66 67 private static ThreadLocal threadInstance = new ThreadLocal () { 68 protected Object initialValue() { 69 return new Stack (); 70 } 71 }; 72 73 76 public static DetailedResults getThreadResults() { 77 Stack stack = (Stack ) threadInstance.get(); 78 return stack.isEmpty() ? null : (DetailedResults) stack.peek(); 79 } 80 81 public static DetailedResults popThreadResults() { 82 Stack stack = (Stack ) threadInstance.get(); 83 return stack.isEmpty() ? null : (DetailedResults) stack.pop(); 84 } 85 86 public static void pushThreadResults(DetailedResults result) { 87 Stack stack = (Stack ) threadInstance.get(); 88 stack.push(result); 89 } 90 91 public abstract void setSummary(AggregatedResults summary); 92 94 public abstract Storage getStorage(); 95 96 100 public abstract ReviewResults findReviewResults(CompilationUnit cu); 101 102 public abstract void commit(long l); 103 104 public abstract void execute(Task task) throws HammurapiException; 105 106 109 public abstract void join() throws HammurapiException; 110 } 111 | Popular Tags |