1 19 20 package org.netbeans.modules.tomcat5.progress; 21 22 import javax.enterprise.deploy.spi.TargetModuleID ; 23 import javax.enterprise.deploy.spi.status.DeploymentStatus ; 24 import javax.enterprise.deploy.spi.status.ProgressEvent ; 25 import javax.enterprise.deploy.spi.status.ProgressListener ; 26 import org.netbeans.modules.tomcat5.TomcatFactory; 27 import org.openide.ErrorManager; 28 29 36 public class ProgressEventSupport { 37 38 39 private Object obj; 40 41 private java.util.Vector listeners; 42 43 private DeploymentStatus status; 44 45 50 public ProgressEventSupport (Object o) { 51 if (o == null) { 52 throw new NullPointerException (); 53 } 54 obj = o; 55 } 56 57 58 public synchronized void addProgressListener (ProgressListener lsnr) { 59 if (listeners == null) { 60 listeners = new java.util.Vector (); 61 } 62 listeners.addElement(lsnr); 63 } 64 65 66 public synchronized void removeProgressListener (ProgressListener lsnr) { 67 if (listeners == null) { 68 return; 69 } 70 listeners.removeElement(lsnr); 71 } 72 73 74 public void fireHandleProgressEvent (TargetModuleID targetModuleID, DeploymentStatus sCode) { 75 if (TomcatFactory.getEM ().isLoggable (ErrorManager.INFORMATIONAL)) { 76 TomcatFactory.getEM ().log ("progress event from "+obj+" status "+sCode); } 78 synchronized (this) { 79 status = sCode; 80 } 81 ProgressEvent evt = new ProgressEvent (obj, targetModuleID, sCode); 82 java.util.Vector targets = null; 83 synchronized (this) { 84 if (listeners != null) { 85 targets = (java.util.Vector ) listeners.clone(); 86 } 87 } 88 89 if (targets != null) { 90 for (int i = 0; i < targets.size(); i++) { 91 ProgressListener target = (ProgressListener )targets.elementAt(i); 92 target.handleProgressEvent (evt); 93 } 94 } 95 } 96 97 99 public synchronized DeploymentStatus getDeploymentStatus () { 100 return status; 101 } 102 } 103 | Popular Tags |