1 19 20 package org.netbeans.modules.j2ee.jboss4.ide; 21 22 import java.io.File ; 23 import org.netbeans.modules.j2ee.deployment.plugins.api.FindJSPServlet; 24 import org.netbeans.modules.j2ee.deployment.plugins.api.InstanceProperties; 25 import org.netbeans.modules.j2ee.jboss4.JBDeploymentManager; 26 import org.netbeans.modules.j2ee.jboss4.ide.ui.JBPluginProperties; 27 28 32 public class JBFindJSPServlet implements FindJSPServlet { 33 34 JBDeploymentManager dm; 35 36 public JBFindJSPServlet(JBDeploymentManager manager) { 37 dm = manager; 38 } 39 40 public File getServletTempDirectory(String moduleContextPath) { 41 InstanceProperties ip = dm.getInstanceProperties(); 42 String domainPath = ip.getProperty(JBPluginProperties.PROPERTY_SERVER_DIR); 43 File servletRoot = new File (domainPath, "work/jboss.web/localhost".replace('/', File.separatorChar)); String contextRootPath = getContextRootPath(moduleContextPath); 45 File workDir = new File (servletRoot, contextRootPath); 46 return workDir; 47 } 48 49 private String getContextRootPath(String moduleContextPath) { 50 if (moduleContextPath.startsWith("/")) { 51 moduleContextPath = moduleContextPath.substring(1); 52 } 53 if (moduleContextPath.length() == 0) { 54 moduleContextPath = "/"; 55 } 56 57 return moduleContextPath.replace('/', '_'); 58 } 59 60 public String getServletResourcePath(String moduleContextPath, String jspResourcePath) { 61 62 String path = null; 63 64 String extension = jspResourcePath.substring(jspResourcePath.lastIndexOf(".")); 65 if (".jsp".equals(extension)) { String pkgName = getServletPackageName(jspResourcePath); 67 String pkgPath = pkgName.replace('.', '/'); 68 String clzName = getServletClassName(jspResourcePath); 69 path = pkgPath + '/' + clzName + ".java"; } 71 72 return path; 73 } 74 75 public String getServletPackageName(String jspUri) { 77 String dPackageName = getDerivedPackageName(jspUri); 78 if (dPackageName.length() == 0) { 79 return JspNameUtil.JSP_PACKAGE_NAME; 80 } 81 return JspNameUtil.JSP_PACKAGE_NAME + '.' + getDerivedPackageName(jspUri); 82 } 83 84 private String getDerivedPackageName(String jspUri) { 86 int iSep = jspUri.lastIndexOf('/'); 87 return (iSep > 0) ? JspNameUtil.makeJavaPackage(jspUri.substring(0,iSep)) : ""; 88 } 89 90 public String getServletClassName(String jspUri) { 92 int iSep = jspUri.lastIndexOf('/') + 1; 93 return JspNameUtil.makeJavaIdentifier(jspUri.substring(iSep)); 94 } 95 96 public String getServletEncoding(String moduleContextPath, String jspResourcePath) { 97 return "UTF8"; } 99 100 101 102 } 103 | Popular Tags |