1 19 20 package org.netbeans.modules.j2ee.sun.ide.j2ee.jsps; 21 22 import java.io.File ; 23 import javax.enterprise.deploy.spi.DeploymentManager ; 24 import org.netbeans.modules.j2ee.deployment.plugins.api.FindJSPServlet; 25 import org.netbeans.modules.j2ee.sun.ide.dm.SunDeploymentManager; 26 27 import org.netbeans.modules.j2ee.sun.ide.j2ee.DeploymentManagerProperties; 28 29 33 public class FindJSPServletImpl implements FindJSPServlet { 34 35 private DeploymentManager tm; 36 37 38 public FindJSPServletImpl(DeploymentManager dm) { 39 tm =dm; 40 } 41 42 public File getServletTempDirectory(String moduleContextPath) { 43 44 DeploymentManagerProperties dmProps = new DeploymentManagerProperties(tm); 45 String domain = dmProps.getDomainName(); 46 if (domain==null){ 47 domain="domain1"; dmProps.setDomainName(domain); 49 } 50 String domainDir = dmProps.getLocation(); 51 SunDeploymentManager sunDM = (SunDeploymentManager)tm; 52 String modName = sunDM.getManagement().getWebModuleName(moduleContextPath); 53 File workDir = new File (domainDir, "/"+domain+"/generated/jsp/j2ee-modules/" +modName); if (!workDir.exists()){ workDir = new File (domainDir, "/"+domain+"/generated/jsp/j2ee-apps/" +modName); 58 } 59 return workDir; 61 } 62 63 64 65 private String getContextRootString(String moduleContextPath) { 66 String contextRootPath = moduleContextPath; 67 if (contextRootPath.startsWith("/")) { contextRootPath = contextRootPath.substring(1); 69 } 70 71 return contextRootPath; 72 73 } 74 75 public String getServletResourcePath(String moduleContextPath, String jspResourcePath) { 76 String s= getServletPackageName(jspResourcePath).replace('.', '/') + '/' + 78 getServletClassName(jspResourcePath) + ".java"; return s; 81 } 84 85 public String getServletPackageName(String jspUri) { 87 String dPackageName = getDerivedPackageName(jspUri); 88 if (dPackageName.length() == 0) { 89 return JspNameUtil.JSP_PACKAGE_NAME; 90 } 91 return JspNameUtil.JSP_PACKAGE_NAME + '.' + getDerivedPackageName(jspUri); 92 } 93 94 private String getDerivedPackageName(String jspUri) { 96 int iSep = jspUri.lastIndexOf('/'); 97 return (iSep > 0) ? JspNameUtil.makeJavaPackage(jspUri.substring(0,iSep)) : ""; } 99 100 public String getServletClassName(String jspUri) { 102 int iSep = jspUri.lastIndexOf('/') + 1; 103 return JspNameUtil.makeJavaIdentifier(jspUri.substring(iSep)); 104 } 105 106 public String getServletEncoding(String moduleContextPath, String jspResourcePath) { 107 return "UTF8"; } 109 110 public void setDeploymentManager(DeploymentManager manager) { 111 tm = manager; 112 } 113 114 } 115 | Popular Tags |