1 26 package org.objectweb.jonas_lib.deployment.work; 27 28 import java.io.File ; 29 import java.net.MalformedURLException ; 30 import java.util.Vector ; 31 32 import org.objectweb.jonas.container.EJBService; 33 import org.objectweb.jonas.service.ServiceManager; 34 35 import org.objectweb.util.monolog.api.BasicLevel; 36 37 43 public class JarCleanTask extends AbsCleanTask { 44 45 48 private static DeployerLog jarDeployerLog = null; 49 50 54 public JarCleanTask(DeployerLog jarDeployerLog) { 55 super(); 56 JarCleanTask.jarDeployerLog = jarDeployerLog; 57 } 58 59 65 protected boolean isValidLogEntry(LogEntry logEntry) throws CleanerException { 66 String fTimeStamp = null; 67 File jarOriginalFile = logEntry.getOriginal(); 68 File jarCopyFile = logEntry.getCopy(); 69 70 if (getLogger().isLoggable(BasicLevel.DEBUG)) { 71 getLogger().log(BasicLevel.DEBUG, "LogEntry exist :" + jarOriginalFile.exists()); 72 } 73 74 if (!jarOriginalFile.exists()) { 76 return false; 77 } 78 79 try { 81 fTimeStamp = FileManager.fileToTimeStampDir(jarOriginalFile.toURL(), ".jar"); 82 } catch (FileManagerException efme) { 83 throw new CleanerException("Can't get the timestamp of the file " + jarOriginalFile + " : " 84 + efme.getMessage()); 85 } catch (MalformedURLException mue) { 86 throw new CleanerException("Can't get the timestamp of the file " + jarOriginalFile + " : " 87 + mue.getMessage()); 88 } 89 90 if (getLogger().isLoggable(BasicLevel.DEBUG)) { 91 getLogger().log(BasicLevel.DEBUG, "LogEntry fTimeStamp :" + fTimeStamp); 92 getLogger().log(BasicLevel.DEBUG, "LogEntry isValid :" + fTimeStamp.equalsIgnoreCase(jarCopyFile.getName())); 93 } 94 95 return (fTimeStamp.equalsIgnoreCase(jarCopyFile.getName())); 97 98 } 99 100 105 protected void removeLogEntry(LogEntry logEntry) throws CleanerException { 106 removeRecursiveDirectory(logEntry.getCopy()); 108 109 try { 110 jarDeployerLog.removeEntry(logEntry); 111 } catch (DeployerLogException edle) { 112 throw new CleanerException("Can't remove an entry" + edle.getMessage()); 113 } 114 115 } 116 117 121 protected Vector getLogEntries() { 122 return jarDeployerLog.getEntries(); 123 } 124 125 131 protected boolean isDeployLogEntry(LogEntry logEntry) throws CleanerException { 132 133 ServiceManager sm = null; 135 136 try { 137 sm = ServiceManager.getInstance(); 138 } catch (Exception e) { 139 throw new CleanerException("Cannot get ServiceManager instance"); 140 } 141 EJBService ejbService = (EJBService) sm.getEjbService(); 142 143 return ejbService.isJarDeployedByWorkName(logEntry.getCopy().getName()); 145 146 } 147 } | Popular Tags |