1 package net.sf.invicta.handler; 2 3 import java.io.File ; 4 import java.util.Iterator ; 5 import java.util.Map ; 6 7 import java.util.List ; 8 import net.sf.invicta.InvictaException; 9 import net.sf.invicta.api.Product; 10 11 14 public class DependAppModulesHandler extends InvictaBasicHandler { 15 16 private final static String MODULE_TYPE_EJB = "ejb"; 17 private final static String MODULE_TYPE_JAVA = "java"; 18 private final static String MODULE_TYPE_WEB = "web"; 19 20 private final static String PRODUCT_TYPE_EJB = "ejb"; 21 private final static String PRODUCT_TYPE_JAVA = "jar"; 22 private final static String PRODUCT_TYPE_WEB = "war"; 23 24 27 public String getName() { 28 return "dependAppModules"; 29 } 30 31 34 public String handle(Map paramsMap) throws InvictaException { 35 return getDependModules(); 36 } 37 38 39 42 public String handle(List params) throws InvictaException { 43 return getDependModules(); 44 } 45 46 49 protected String getDependModules() { 50 String modulesStr = ""; 51 for (Iterator productIter = 53 getComponent().getRecursiveProducts().iterator(); 54 productIter.hasNext();) { 55 56 Product product = (Product)productIter.next(); 57 58 if (product.getFile() != null) { 59 File file = new File (product.getFile()); 60 if (product.getType().equals(PRODUCT_TYPE_EJB)) { 61 modulesStr += getEJBModule(file.getName()); 62 } else if (product.getType().equals(PRODUCT_TYPE_JAVA)) { 63 modulesStr += getJavaModule(file.getName()); 64 } else if (product.getType().equals(PRODUCT_TYPE_WEB)) { 65 modulesStr += getWebModule( 66 product.getAppName(), file.getName()); 67 } 68 } 69 } 70 return modulesStr; 71 } 72 73 76 private String getWebModule(String name, String file) { 77 78 return "<module type=\"" + MODULE_TYPE_WEB + "\" file=\"" + file + 79 "\" name=\"" + name + "\"/>\n"; 80 } 81 82 85 private String getJavaModule(String file) { 86 return "<module type=\"" + MODULE_TYPE_JAVA + "\" file=\"" + file + 87 "\"/>\n"; 88 } 89 90 93 private String getEJBModule(String file) { 94 return "<module type=\"" + MODULE_TYPE_EJB + "\" file=\"" + file + 95 "\"/>\n"; 96 } 97 98 } 99 | Popular Tags |