1 23 24 30 31 package com.sun.enterprise.deployment.autodeploy; 32 33 import java.io.File ; 34 import java.util.Properties ; 35 import com.sun.enterprise.deployment.backend.DeploymentRequest; 36 import com.sun.enterprise.deployment.util.DeploymentProperties; 37 import com.sun.enterprise.util.io.FileSource; 38 import com.sun.enterprise.util.io.FileUtils; 39 import com.sun.enterprise.util.StringUtils; 40 import com.sun.enterprise.deployment.backend.IASDeploymentException; 41 import com.sun.enterprise.util.i18n.StringManager; 42 43 public class AutoDirReDeployer extends AutoDeployer 44 { 45 public AutoDirReDeployer(DeploymentRequest req) 46 { 47 if(req == null) 48 throw new IllegalArgumentException ("nullarg"); 49 50 this.req = req; 51 } 52 53 public boolean redeploy() throws AutoDeploymentException 54 { 55 boolean status = false; 56 int deployResult = DEPLOY_FAILURE; 57 try 58 { 59 init(); 60 verify(); 61 File source = req.getFileSource().getFile(); 62 String name = req.getName(); 63 64 deployResult = deploy(source, name); 65 } 66 catch(AutoDeploymentException ade) 67 { 68 throw ade; 69 } 70 catch(Exception e) 71 { 72 throw new AutoDeploymentException("Error in AutoDirReDeployer.redeploy", e); 73 } 74 status = (deployResult == DEPLOY_SUCCESS); 75 return status; 76 } 77 78 82 83 boolean invokeDeploymentService(File deployablefile, String action, Object [] params, String [] signature) 84 throws AutoDeploymentException 85 { 86 boolean status = false; 87 try 88 { 89 Object result = getMBeanServer().invoke(getMBeanName(), action, params, signature); 90 status = parseResult(result); 91 } 92 catch(AutoDeploymentException de) 93 { 94 throw de; 95 } 96 catch(Exception e) 97 { 98 String msg = "Error in AutoReDeployer.invokeDeploymentService"; 99 throw new AutoDeploymentException(msg, e); 100 } 101 return status; 102 } 103 104 protected Properties getUndeployActionProperties(String name){ 105 DeploymentProperties dProps = 106 (DeploymentProperties)super.getUndeployActionProperties(name); 107 dProps.setReload(true); 108 return (Properties )dProps; 109 } 110 111 113 private void verify() throws AutoDeploymentException 114 { 115 117 if(!req.isApplication() && !req.isEjbModule() && !req.isWebModule()) 119 throw new AutoDeploymentException(getString("wrongType")); 120 121 if(!FileUtils.safeIsDirectory(req.getFileSource().getFile())) 123 throw new AutoDeploymentException(getString("notDir") + req.getFileSource().getFile().getAbsolutePath()); 124 125 if(!StringUtils.ok(req.getName())) 127 throw new AutoDeploymentException(getString("noName")); 128 } 129 130 132 private String getString(String s) 133 { 134 return localStrings.getString("enterprise.deployment.AutoDirRedeploy." + s); 135 } 136 137 139 140 private DeploymentRequest req; 141 private static StringManager localStrings = StringManager.getManager(AutoDirReDeployer.class); 142 } 143 144 | Popular Tags |