1 17 package org.apache.geronimo.system.plugin; 18 19 import java.io.Serializable ; 20 import java.util.List ; 21 import java.util.ArrayList ; 22 import org.apache.geronimo.kernel.repository.Artifact; 23 24 30 public class DownloadResults implements Serializable , DownloadPoller { 31 private List removedConfigIDs = new ArrayList (); 32 private List restartedConfigIDs = new ArrayList (); 33 private List installedConfigIDs = new ArrayList (); 34 private List dependenciesPresent = new ArrayList (); 35 private List dependenciesInstalled = new ArrayList (); 36 private String currentFile; 37 private String currentMessage; 38 private int currentFileProgress = -1; 39 private Exception failure; 40 private boolean finished; 41 private long totalDownloadBytes = 0; 42 43 public synchronized DownloadResults duplicate() { 44 DownloadResults other = new DownloadResults(); 45 other.removedConfigIDs.addAll(removedConfigIDs); 46 other.restartedConfigIDs.addAll(restartedConfigIDs); 47 other.installedConfigIDs.addAll(installedConfigIDs); 48 other.dependenciesPresent.addAll(dependenciesPresent); 49 other.dependenciesInstalled.addAll(dependenciesInstalled); 50 other.currentFile = currentFile; 51 other.currentMessage = currentMessage; 52 other.currentFileProgress = currentFileProgress; 53 other.failure = failure; 54 other.finished = finished; 55 other.totalDownloadBytes = totalDownloadBytes; 56 return other; 57 } 58 59 public synchronized void addInstalledConfigID(Artifact dep) { 60 installedConfigIDs.add(dep); 61 } 62 63 public synchronized void addRemovedConfigID(Artifact obsolete) { 64 removedConfigIDs.add(obsolete); 65 } 66 67 public synchronized void addRestartedConfigID(Artifact target) { 68 restartedConfigIDs.add(target); 69 } 70 71 public synchronized void addDependencyPresent(Artifact dep) { 72 dependenciesPresent.add(dep); 73 } 74 75 public synchronized void addDependencyInstalled(Artifact dep) { 76 dependenciesInstalled.add(dep); 77 } 78 79 public synchronized void setCurrentFile(String currentFile) { 80 this.currentFile = currentFile; 81 } 82 83 public synchronized void setCurrentMessage(String currentMessage) { 84 this.currentMessage = currentMessage; 85 } 86 87 public synchronized void setCurrentFilePercent(int currentFileProgress) { 88 this.currentFileProgress = currentFileProgress; 89 } 90 91 public synchronized void setFailure(Exception failure) { 92 this.failure = failure; 93 } 94 95 public synchronized void setFinished() { 96 finished = true; 97 } 98 99 public synchronized void addDownloadBytes(long bytes) { 100 totalDownloadBytes += bytes; 101 } 102 103 public boolean isFinished() { 104 return finished; 105 } 106 107 public boolean isFailed() { 108 return failure != null; 109 } 110 111 115 public long getTotalDownloadBytes() { 116 return totalDownloadBytes; 117 } 118 119 122 public Exception getFailure() { 123 return failure; 124 } 125 126 133 public Artifact[] getInstalledConfigIDs() { 134 return (Artifact[]) installedConfigIDs.toArray(new Artifact[installedConfigIDs.size()]); 135 } 136 137 public Artifact[] getRemovedConfigIDs() { 138 return (Artifact[]) removedConfigIDs.toArray(new Artifact[installedConfigIDs.size()]); 139 } 140 141 public Artifact[] getRestartedConfigIDs() { 142 return (Artifact[]) restartedConfigIDs.toArray(new Artifact[installedConfigIDs.size()]); 143 } 144 145 149 public Artifact[] getDependenciesPresent() { 150 return (Artifact[]) dependenciesPresent.toArray(new Artifact[dependenciesPresent.size()]); 151 } 152 153 157 public Artifact[] getDependenciesInstalled() { 158 return (Artifact[]) dependenciesInstalled.toArray(new Artifact[dependenciesInstalled.size()]); 159 } 160 161 164 public String getCurrentFile() { 165 return currentFile; 166 } 167 168 171 public String getCurrentMessage() { 172 return currentMessage; 173 } 174 175 180 public int getCurrentFilePercent() { 181 return currentFileProgress; 182 } 183 } 184 | Popular Tags |