1 19 20 package org.netbeans.tests.j2eeserver.plugin.jsr88; 21 22 import javax.enterprise.deploy.spi.*; 23 import javax.enterprise.deploy.shared.*; 24 import javax.enterprise.deploy.model.*; 25 import javax.enterprise.deploy.spi.exceptions.OperationUnsupportedException ; 26 import javax.enterprise.deploy.spi.status.*; 27 import org.netbeans.modules.j2ee.deployment.plugins.api.ServerProgress; 28 import javax.enterprise.deploy.shared.*; 29 30 import java.io.*; 31 import java.util.*; 32 33 38 public class ProgObject extends ServerProgress { 39 40 private TargetModuleID[] tmIDs; 41 42 public ProgObject(DeploymentManager dm, Target[] targets, File archive, Object plan) { 43 this(dm, createTargetModuleIDs(targets, archive)); 44 } 45 46 public ProgObject(DeploymentManager dm, Target[] targets, Object archive, Object plan) { 47 this(dm, new TargetModuleID[0]); 48 } 49 50 public ProgObject(DeploymentManager dm, TargetModuleID[] modules) { 51 super(dm); 52 tmIDs = modules; 53 } 54 55 public static TargetModuleID[] createTargetModuleIDs(Target[] targets, File archive) { 56 TargetModuleID [] ret = new TargetModuleID[targets.length]; 57 for (int i=0; i<ret.length; i++) { 58 ret[i] = new TestTargetMoid(targets[i], archive.getName(), getType(archive.getName())); 59 ((Targ)targets[i]).add(ret[i]); 60 } 61 return ret; 62 } 63 static ModuleType getType(String name) { 64 if (name.endsWith(".ear")) return ModuleType.EAR; 65 else if (name.endsWith(".jar")) return ModuleType.EJB; else if (name.endsWith(".war")) return ModuleType.WAR; 67 else if (name.endsWith(".rar")) return ModuleType.RAR; 68 else throw new IllegalArgumentException ("Invalid archive name: " + name); 69 } 70 public void setStatusDistributeRunning(String message) { 71 notify(createRunningProgressEvent(CommandType.DISTRIBUTE, message)); 72 } 73 public void setStatusDistributeFailed(String message) { 74 notify(createFailedProgressEvent(CommandType.DISTRIBUTE, message)); 75 } 76 public void setStatusDistributeCompleted(String message) { 77 notify(createCompletedProgressEvent(CommandType.DISTRIBUTE, message)); 78 } 79 80 public void setStatusRedeployRunning(String message) { 81 notify(createRunningProgressEvent(CommandType.REDEPLOY, message)); 82 } 83 public void setStatusRedeployFailed(String message) { 84 notify(createFailedProgressEvent(CommandType.REDEPLOY, message)); 85 } 86 public void setStatusRedeployCompleted(String message) { 87 notify(createCompletedProgressEvent(CommandType.REDEPLOY, message)); 88 } 89 90 public void cancel() throws OperationUnsupportedException { 91 throw new OperationUnsupportedException ("Test plugin does not support cancel!"); 92 } 93 94 public void stop() throws OperationUnsupportedException { 95 throw new OperationUnsupportedException ("Test plugin does not support stop!"); 96 } 97 98 public boolean isCancelSupported() { 99 return false; } 101 102 public boolean isStopSupported() { 103 return false; } 105 106 public ClientConfiguration getClientConfiguration(TargetModuleID targetModuleID) { 107 return null; } 109 110 public DeploymentStatus getDeploymentStatus() { 111 return super.getDeploymentStatus(); 112 } 113 114 public TargetModuleID[] getResultTargetModuleIDs() { 115 List ret = new Vector(); 116 for (int i=0; i<tmIDs.length; i++) { 117 if (tmIDs[i].getChildTargetModuleID() != null) 118 ret.addAll(Arrays.asList(tmIDs[i].getChildTargetModuleID())); 119 ret.add(tmIDs[i]); 120 } 121 return (TargetModuleID[]) ret.toArray(new TargetModuleID[ret.size()]); 122 } 123 } 124 | Popular Tags |