1 22 package org.jboss.deployers.plugins.deployer; 23 24 import org.jboss.deployers.spi.DeploymentException; 25 import org.jboss.deployers.spi.deployer.Deployer; 26 import org.jboss.deployers.spi.deployer.DeploymentUnit; 27 import org.jboss.logging.Logger; 28 29 38 public class DeployerWrapper implements Deployer 39 { 40 41 private Logger log; 42 43 44 private Deployer deployer; 45 46 51 public DeployerWrapper(Deployer deployer) 52 { 53 if (deployer == null) 54 throw new IllegalArgumentException ("Null deployer"); 55 this.deployer = deployer; 56 this.log = Logger.getLogger(deployer.getClass()); 57 } 58 59 public boolean isRelevant(DeploymentUnit unit) 60 { 61 if (unit == null) 62 throw new IllegalArgumentException ("Null unit"); 63 64 try 65 { 66 boolean result = deployer.isRelevant(unit); 67 if (log.isTraceEnabled()) 68 log.trace("isRelevant " + unit.getName() + " result=" + result); 69 return result; 70 } 71 catch (Throwable t) 72 { 73 log.warn("Error during isRelevant: " + unit.getName(), t); 74 return false; 75 } 76 } 77 78 public void prepareDeploy(DeploymentUnit unit) throws DeploymentException 79 { 80 if (unit == null) 81 throw new IllegalArgumentException ("Null unit"); 82 83 try 84 { 85 log.trace("Preparing deployment: " + unit.getName()); 86 deployer.prepareDeploy(unit); 87 log.trace("Prepared deployment: " + unit.getName()); 88 } 89 catch (Throwable t) 90 { 91 log.error("Error during prepare deployment: " + unit.getName(), t); 92 throw DeploymentException.rethrowAsDeploymentException("Error during prepare deployment: " + unit.getName(), t); 93 } 94 } 95 96 public void prepareUndeploy(DeploymentUnit unit) 97 { 98 if (unit == null) 99 throw new IllegalArgumentException ("Null unit"); 100 101 try 102 { 103 log.trace("Undeploying: " + unit.getName()); 105 deployer.prepareUndeploy(unit); 106 log.trace("Undeployed: " + unit.getName()); 108 } 109 catch (Throwable t) 110 { 111 log.warn("Error during undeployment: " + unit.getName(), t); 113 } 114 } 115 116 public void handoff(DeploymentUnit from, DeploymentUnit to) throws DeploymentException 117 { 118 if (from == null) 119 throw new IllegalArgumentException ("Null from deployment"); 120 if (to == null) 121 throw new IllegalArgumentException ("Null to deployment"); 122 123 try 124 { 125 log.trace("Handing off from=" + from.getName() + " to=" + to.getName()); 126 deployer.handoff(from, to); 127 log.trace("Handed off from=" + from.getName() + " to=" + to.getName()); 128 } 129 catch (Throwable t) 130 { 131 log.warn("Error during handoff from=" + from.getName() + " to=" + to.getName(), t); 132 throw DeploymentException.rethrowAsDeploymentException("Error during handoff from=" + from.getName() + " to=" + to.getName(), t); 133 } 134 } 135 136 public void commitDeploy(DeploymentUnit unit) throws DeploymentException 137 { 138 if (unit == null) 139 throw new IllegalArgumentException ("Null unit"); 140 141 try 142 { 143 log.trace("Deploying: " + unit.getName()); 145 deployer.commitDeploy(unit); 146 log.trace("Deployed: " + unit.getName()); 148 } 149 catch (Throwable t) 150 { 151 log.error("Error during deployment: " + unit.getName(), t); 153 throw DeploymentException.rethrowAsDeploymentException("Error during deployment: " + unit.getName(), t); 155 } 156 } 157 158 public void commitUndeploy(DeploymentUnit unit) 159 { 160 if (unit == null) 161 throw new IllegalArgumentException ("Null unit"); 162 163 try 164 { 165 log.trace("Commiting undeployment: " + unit.getName()); 166 deployer.commitUndeploy(unit); 167 log.trace("Commited undeployment: " + unit.getName()); 168 } 169 catch (Throwable t) 170 { 171 log.warn("Error during commit undeployment: " + unit.getName(), t); 172 } 173 } 174 175 public int getRelativeOrder() 176 { 177 return deployer.getRelativeOrder(); 178 } 179 public void setRelativeOrder(int order) 180 { 181 deployer.setRelativeOrder(order); 182 } 183 184 @Override 185 public boolean equals(Object obj) 186 { 187 if (obj == this) 188 return true; 189 if (obj == null || obj instanceof Deployer == false) 190 return false; 191 if (obj instanceof DeployerWrapper) 192 obj = ((DeployerWrapper) obj).deployer; 193 return deployer.equals(obj); 194 } 195 196 @Override 197 public int hashCode() 198 { 199 return deployer.hashCode(); 200 } 201 202 @Override 203 public String toString() 204 { 205 return deployer.toString(); 206 } 207 } 208 | Popular Tags |