1 16 17 package org.apache.axis2.deployment.repository.util; 18 19 import org.apache.axis2.deployment.DeploymentConstants; 20 import org.apache.axis2.deployment.DeploymentEngine; 21 22 import java.io.File ; 23 import java.util.ArrayList ; 24 import java.util.Iterator ; 25 import java.util.List ; 26 27 public class WSInfoList implements DeploymentConstants { 28 31 private static List jarlist = new ArrayList (); 32 33 36 public List currentjars = new ArrayList (); 37 38 41 private DeploymentEngine deplorer; 42 43 public WSInfoList(DeploymentEngine deploy_engine) { 44 deplorer = deploy_engine; 45 } 46 47 50 public void init() { 51 jarlist.clear(); 52 } 53 54 69 public void addWSInfoItem(File file, int type) { 70 switch (type) { 71 case SERVICE: 72 { 73 if (!isFileExist(file.getName())) { WSInfo wsInfo = new WSInfo(file.getName(), file.lastModified(), SERVICE); 75 jarlist.add(wsInfo); 76 ArchiveFileData archiveFileData = new ArchiveFileData(file, SERVICE); 77 deplorer.addtowsToDeploy(archiveFileData); } else { 79 if (deplorer.isHotUpdate()) { 80 WSInfo tempWSInfo = getFileItem(file.getName()); 81 if (isModified(file, tempWSInfo)) { tempWSInfo.setLastmodifieddate(file.lastModified()); 83 WSInfo wsInfo = new WSInfo(tempWSInfo.getFilename(), tempWSInfo.getLastmodifieddate(), SERVICE); 84 deplorer.addtowstoUnDeploy(wsInfo); ArchiveFileData archiveFileData = new ArchiveFileData(file, SERVICE); 86 deplorer.addtowsToDeploy(archiveFileData); 88 } 89 } 90 } 91 break; 92 } 93 case MODULE: 94 { 95 if (!isFileExist(file.getName())) { WSInfo wsInfo = new WSInfo(file.getName(), file.lastModified(), MODULE); 97 jarlist.add(wsInfo); 98 ArchiveFileData archiveFileData = new ArchiveFileData(file, MODULE); 99 deplorer.addtowsToDeploy(archiveFileData); } else { 101 if (deplorer.isHotUpdate()) { 102 WSInfo tempWSInfo = getFileItem(file.getName()); 103 if (isModified(file, tempWSInfo)) { 104 tempWSInfo.setLastmodifieddate(file.lastModified()); 105 WSInfo wsInfo = new WSInfo(tempWSInfo.getFilename(), tempWSInfo.getLastmodifieddate(), MODULE); 106 deplorer.addtowstoUnDeploy(wsInfo); ArchiveFileData archiveFileData = new ArchiveFileData(file, MODULE); 108 deplorer.addtowsToDeploy(archiveFileData); 110 } 111 } 112 } 113 break; 114 } 115 } 116 String jarname = file.getName(); 117 currentjars.add(jarname); 118 } 119 120 127 public WSInfo getFileItem(String filename) { 128 int sise = jarlist.size(); 129 for (int i = 0; i < sise; i++) { 130 WSInfo wsInfo = (WSInfo) jarlist.get(i); 131 if (wsInfo.getFilename().equals(filename)) { 132 return wsInfo; 133 } 134 } 135 return null; 136 } 137 138 146 public boolean isModified(File file, WSInfo wsInfo) { 147 if (wsInfo.getLastmodifieddate() != file.lastModified()) { 148 return true; 149 } 150 return false; 151 } 152 153 159 public boolean isFileExist(String filename) { 160 return !(getFileItem(filename) == null); 161 } 162 163 170 public void checkForUndeploye() { 171 Iterator iter = jarlist.listIterator(); 172 int size = currentjars.size(); 173 List tempvector = new ArrayList (); 174 tempvector.clear(); 175 String filename = ""; 176 boolean exist = false; 177 while (iter.hasNext()) { 178 WSInfo fileitem = (WSInfo) iter.next(); 179 exist = false; 180 for (int i = 0; i < size; i++) { 181 filename = (String ) currentjars.get(i); 182 if (filename.equals(fileitem.getFilename())) { 183 exist = true; 184 break; 185 } 186 } 187 188 if (!exist) { 189 tempvector.add(fileitem); 190 WSInfo wsInfo = new WSInfo(fileitem.getFilename(), fileitem.getLastmodifieddate()); 191 deplorer.addtowstoUnDeploy(wsInfo); } 193 194 } 195 196 for (int i = 0; i < tempvector.size(); i++) { 197 WSInfo fileItem = (WSInfo) tempvector.get(i); 198 jarlist.remove(fileItem); 199 } 200 tempvector.clear(); 201 currentjars.clear(); 202 } 203 204 205 208 public void update() { 209 checkForUndeploye(); 210 if (deplorer.isHotUpdate()) { 211 deplorer.unDeploy(); 212 } 213 deplorer.doDeploy(); 214 215 } 216 217 } 218 | Popular Tags |