1 19 20 package org.netbeans.modules.tomcat5.ide; 21 22 import javax.enterprise.deploy.spi.*; 23 import javax.enterprise.deploy.shared.ModuleType ; 24 import org.netbeans.modules.tomcat5.TomcatManager; 25 import org.netbeans.modules.tomcat5.TomcatModule; 26 import org.openide.ErrorManager; 27 28 import java.util.ArrayList ; 29 30 35 public class TMIDResolver extends org.netbeans.modules.j2ee.deployment.plugins.api.TargetModuleIDResolver { 36 37 TomcatManager tm; 38 39 40 public TMIDResolver(DeploymentManager dm) { 41 this.tm = (TomcatManager) dm; 42 } 43 44 public TargetModuleID[] lookupTargetModuleID(java.util.Map queryInfo, Target[] targetList) { 45 String contextRoot = (String ) queryInfo.get(KEY_CONTEXT_ROOT); 46 if (contextRoot == null) 47 return EMPTY_TMID_ARRAY; 48 if ("".equals(contextRoot)) { contextRoot = "/"; } 52 ArrayList result = new ArrayList (); 53 try { 54 TargetModuleID[] tmidList = tm.getAvailableModules(ModuleType.WAR, targetList); 55 for (int i=0; i<tmidList.length; i++) { 56 TomcatModule tm = (TomcatModule) tmidList[i]; 57 if (contextRoot.equals(tm.getPath())) 58 result.add(tm); 59 } 60 } catch(Exception ex) { 61 ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex); 62 } 63 64 return (TargetModuleID[]) result.toArray(new TargetModuleID[result.size()]); 65 } 66 } 67 | Popular Tags |