1 17 18 package org.apache.geronimo.deployment.mavenplugin; 19 20 import java.io.File ; 21 import java.io.IOException ; 22 import java.net.MalformedURLException ; 23 24 import javax.enterprise.deploy.spi.DeploymentManager ; 25 import javax.enterprise.deploy.spi.Target ; 26 import javax.enterprise.deploy.spi.status.ProgressObject ; 27 28 34 public class DistributeModule extends AbstractModuleCommand { 35 36 private String module; 37 private String plan; 38 39 public String getModule() { 40 return module; 41 } 42 43 public void setModule(String module) { 44 this.module = module; 45 } 46 47 public String getPlan() { 48 return plan; 49 } 50 51 public void setPlan(String plan) { 52 this.plan = plan; 53 } 54 55 public void execute() throws Exception { 56 DeploymentManager manager = getDeploymentManager(); 57 58 Target [] targets = manager.getTargets(); 59 File moduleFile = (getModule() == null)? null: getFile(getModule()); 60 File planFile = (getPlan() == null)? null: getFile((getPlan())); 61 ProgressObject progress = manager.distribute(targets, moduleFile, planFile); 62 DeploymentClient.waitFor(progress); 63 } 64 65 private File getFile(String location) throws MalformedURLException { 66 try { 67 File f = new File (location).getCanonicalFile(); 68 if (!f.exists() || !f.canRead()) { 69 throw new MalformedURLException ("Invalid location: " + location); 70 } 71 return f; 72 } catch (IOException e) { 73 throw (MalformedURLException ) new MalformedURLException ("Invalid location: " + location).initCause(e); 74 } 75 76 } 77 78 } 79 | Popular Tags |