1 16 17 package org.apache.axis2.deployment.listener; 18 19 import org.apache.axis2.deployment.DeploymentConstants; 20 import org.apache.axis2.deployment.DeploymentEngine; 21 import org.apache.axis2.deployment.repository.util.WSInfoList; 22 23 import java.io.File ; 24 import java.util.ArrayList ; 25 import java.util.List ; 26 27 public class RepositoryListenerImpl implements RepositoryListener, DeploymentConstants { 28 29 32 private List currentJars; 33 36 private WSInfoList wsinfoList; 37 38 42 private String folderName; 43 44 52 public RepositoryListenerImpl(String folderName, DeploymentEngine deploy_engine) { 53 this.folderName = folderName; 54 wsinfoList = new WSInfoList(deploy_engine); 55 init(); 56 } 57 58 62 public void checkModules() { 63 String modulepath = folderName + MODULE_PATH; 64 String files[]; 65 currentJars = new ArrayList (); 66 File root = new File (modulepath); 67 currentJars.add(root); 69 70 while (currentJars.size() > 0) { File dir = (File ) currentJars.get(0); currentJars.remove(0); files = dir.list(); if (files == null) { 75 continue; 76 } 77 for (int i = 0; i < files.length; i++) { File f = new File (dir, files[i]); 79 if (f.isDirectory()) { currentJars.add(0, f); 81 } else if (isModuleArchiveFile(f.getName())) { 83 wsinfoList.addWSInfoItem(f, MODULE); 84 } 85 } 86 } 87 } 88 89 93 public void checkServices() { 94 String modulepath = folderName + SERVICE_PATH; 95 searchWS(modulepath, SERVICE); 96 } 97 98 101 public void update() { 102 wsinfoList.update(); 105 } 106 107 113 public void init() { 114 wsinfoList.init(); 115 checkModules(); 116 checkServices(); 117 update(); 118 } 119 120 123 public void startListent() { 124 checkServices(); 126 update(); 127 } 128 129 133 private void searchWS(String folderName, int type) { 134 String files[]; 135 currentJars = new ArrayList (); 136 File root = new File (folderName); 137 currentJars.add(root); 139 140 while (currentJars.size() > 0) { File dir = (File ) currentJars.get(0); currentJars.remove(0); files = dir.list(); if (files == null) { 145 continue; 146 } 147 for (int i = 0; i < files.length; i++) { File f = new File (dir, files[i]); 149 if (f.isDirectory()) { currentJars.add(0, f); 151 } else if (isServiceArchiveFile(f.getName())) { 153 wsinfoList.addWSInfoItem(f, type); 154 } 155 } 156 } 157 } 158 159 165 private boolean isServiceArchiveFile(String filename) { 166 if (filename.endsWith(".jar") | filename.endsWith(".aar")) { 167 return true; 168 } 169 return false; 170 } 171 172 private boolean isModuleArchiveFile(String filename) { 173 if (filename.endsWith(".jar") || filename.endsWith(".mar")) { 174 return true; 175 } 176 return false; 177 } 178 179 } 180 | Popular Tags |