1 26 package org.objectweb.openccm.descriptor.componentassembly.ccm.deployer.managers; 27 28 29 import java.util.Hashtable ; 30 import java.util.Iterator ; 31 import org.objectweb.openccm.descriptor.componentassembly.ccm.deployer.base.DeployerContext; 32 import org.objectweb.openccm.descriptor.componentassembly.ccm.deployer.base.DeployerFailureException; 33 import org.objectweb.openccm.descriptor.componentassembly.ccm.deployer.base.DeploymentLogger; 34 import org.objectweb.openccm.descriptor.componentassembly.ccm.deployer.base.ErrorManager; 35 import org.objectweb.openccm.descriptor.componentassembly.ccm.deployer.base.FatalDeploymentException; 36 import org.objectweb.openccm.descriptor.componentassembly.ccm.deployer.base.InitializationError; 37 import org.objectweb.openccm.descriptor.deployerconfig.Deployerconfig; 38 import org.objectweb.openccm.descriptor.deployerconfig.Deployerstatus; 39 import org.objectweb.openccm.descriptor.deployerconfig.Package; 40 import org.objectweb.openccm.descriptor.softpkg.ccm.CorbaComponentFileLoadingFailureException; 41 42 50 public class DefaultErrorManager 51 implements ErrorManager 52 { 53 private DeployerContext deployer; 59 private Hashtable tolerableError; 60 private DeploymentLogger deploymentLogger; 61 private Deployerconfig deployerConfig; 62 public DefaultErrorManager(Deployerconfig deployerConfig) 68 { 69 this.deployerConfig=deployerConfig; 70 setupError(); 71 } 72 80 private void 81 setupError() 82 { 83 tolerableError=new Hashtable (); 84 85 for(Iterator it=deployerConfig.getTolerablefailure().getXmlpackageList().iterator();it.hasNext();){ 86 Package pbi= (Package )it.next(); 87 for(Iterator it1=pbi.getDeployerstatusList().iterator();it1.hasNext();){ 88 Deployerstatus dsb=(Deployerstatus)it1.next(); 89 for(Iterator it2=dsb.getDeployerList().iterator();it2.hasNext();){ 90 org.objectweb.openccm.descriptor.deployerconfig.Deployer dbi= 91 (org.objectweb.openccm.descriptor.deployerconfig.Deployer)it2.next(); 92 tolerableError.put(pbi.getName()+"."+dbi.getName()+"."+dsb.getName(),"empty"); 93 } 94 } 95 } 96 97 } 98 99 105 private boolean 106 isTolerableException(DeployerFailureException e) 107 { 108 String deployerName=e.getDeployer().getClass().getName(); 109 String deployerStatus=e.getDeployer().getStatus().getStateName(); 110 if(tolerableError.containsKey(deployerName+"."+deployerStatus)) 111 return true; 112 return false; 113 } 114 118 protected DeploymentLogger 119 getDeploymentLogger() 120 { 121 return deploymentLogger; 122 } 123 136 public void 137 submitException(InitializationError e) 138 throws InitializationError 139 { 140 141 if(!isTolerableException(e)){ 142 getDeploymentLogger() 143 .log(e.getMessage()); 144 getDeploymentLogger() 145 .log(">> According to the error configuration it is " 146 +" a fatal deployment error. Deployment will be stop here."); 147 e.getDeployer().getLifeCycleManager().stepAborded(); 148 149 throw e; 150 } 151 152 getDeploymentLogger() 153 .log(">> Error occured during initialization of " 154 +e.getDeployer().getIdentifier()+":\n" 155 +e.getMessage()); 156 157 if(e instanceof CorbaComponentFileLoadingFailureException){ 158 getDeploymentLogger() 159 .log(">>Check you CSD file in must specify a link to a "+ 160 "non exisiting file"); 161 e.getDeployer().getLifeCycleManager().stepAborded(); 162 } 163 else{ 164 e.getDeployer().getLifeCycleManager().stepAborded(); 165 getDeploymentLogger() 166 .log(">> "+e.getDeployer().getStringifiedDeployerDescription()+ 167 "\n"+e.getMessage()); 168 throw e; 169 } 170 171 } 172 173 181 public void 182 submitException(DeployerFailureException e) 183 throws FatalDeploymentException 184 { 185 186 try{ 188 getDeploymentLogger() 189 .log(">> An error occured durig the deployment of:"); 190 191 getDeploymentLogger() 192 .log(">> "+e.getDeployer().getStringifiedDeployerDescription()+ 193 "\n"+e.getMessage()); 194 195 } 196 catch(Exception ex){ 197 System.err.println(ex.getMessage()); 198 } 199 if(!isTolerableException(e)){ 200 getDeploymentLogger() 201 .log(">> According to the error configuration it is " 202 +" a fatal deployment error. Deployment will be stop here."); 203 e.getDeployer().getLifeCycleManager().stepAborded(); 204 205 throw new FatalDeploymentException(e); 206 } 207 getDeploymentLogger().log(">> According to the error configuration it is " 208 +"a unfatal deployment error. Deployment will continue."); 209 210 e.getDeployer().getLifeCycleManager().stepAborded(); 211 212 } 213 214 public void connectDeploymentLogger(DeploymentLogger deploymentLogger) { 215 this.deploymentLogger=deploymentLogger; 216 } 217 218 219 220 } 221 | Popular Tags |