1 23 package com.sun.enterprise.diagnostics; 24 25 import java.util.List ; 26 import java.util.zip.ZipFile ; 27 import com.sun.enterprise.diagnostics.DiagnosticException; 28 import com.sun.enterprise.diagnostics.ReportConfig; 29 import com.sun.enterprise.diagnostics.Data; 30 import com.sun.enterprise.diagnostics.collect.Collector; 31 import com.sun.enterprise.diagnostics.report.html.HTMLReportWriter; 32 33 37 public class ReportGenerator { 38 39 protected ReportConfig config; 40 protected Collector harvester; 41 protected HTMLReportWriter reportWriter; 42 43 44 public ReportGenerator(ReportConfig config, Collector harvester, 45 HTMLReportWriter reportWriter) { 46 this.config = config; 47 this.harvester = harvester; 48 this.reportWriter = reportWriter; 49 } 50 51 54 public java.util.zip.ZipFile generate() 55 throws DiagnosticException { 56 Data data = collectData(); 57 writeReportSummary(data); 58 return archive(config.getTarget(), config.getCLIOptions().getReportFile()); 59 } 60 61 private Data collectData() throws DiagnosticException { 62 if(harvester != null) { 63 ((com.sun.enterprise.diagnostics.collect.Harvester)harvester).initialize(); 64 return harvester.capture(); 65 } 66 throw new DiagnosticException("Harvester null"); 67 } 68 69 protected void writeReportSummary(Data data) 70 throws DiagnosticException { 71 if(reportWriter != null) 72 reportWriter.writeReportSummary(data); 73 else 74 throw new DiagnosticException("HTML Report writer == null"); 75 } 76 77 protected ZipFile archive(ReportTarget target, String archiveName) 78 throws DiagnosticException { 79 return new Archiver().archive(config.getTarget(), archiveName); 80 } 81 } 82 | Popular Tags |