1 19 20 package org.netbeans.modules.j2ee.deployment.devmodules.api; 21 22 import java.beans.PropertyChangeListener ; 23 import java.io.File ; 24 import org.netbeans.api.project.FileOwnerQuery; 25 import org.netbeans.api.project.Project; 26 import org.netbeans.modules.j2ee.deployment.devmodules.spi.J2eeModuleProvider; 27 import org.netbeans.modules.j2ee.deployment.impl.ServerInstance; 28 import org.netbeans.modules.j2ee.deployment.impl.ServerRegistry; 29 import org.netbeans.modules.j2ee.deployment.impl.ServerString; 30 import org.netbeans.modules.j2ee.deployment.plugins.api.FindJSPServlet; 31 import org.netbeans.modules.j2ee.deployment.plugins.api.OldJSPDebug; 32 import org.openide.filesystems.FileObject; 33 34 38 public final class JSPServletFinder { 39 40 public static final String SERVLET_FINDER_CHANGED = "servlet-finder-changed"; 42 private Project project; 43 44 47 public static JSPServletFinder findJSPServletFinder(FileObject f) { 48 Project prj = FileOwnerQuery.getOwner (f); 49 return prj == null ? null : new JSPServletFinder(prj); 50 } 51 52 53 private JSPServletFinder (Project project) { 54 this.project = project; 55 } 56 57 private J2eeModuleProvider getProvider() { 58 return (J2eeModuleProvider) project.getLookup ().lookup (J2eeModuleProvider.class); 59 } 60 61 64 private ServerString getServerString() { 65 J2eeModuleProvider dl = getProvider (); 66 if (dl == null) 67 return null; 68 ServerInstance instance = ServerRegistry.getInstance ().getServerInstance (dl.getServerInstanceID ()); 69 return instance == null ? null : new ServerString (instance); 70 } 71 72 73 private String getWebURL() { 74 J2eeModuleProvider provider = (J2eeModuleProvider) project.getLookup ().lookup (J2eeModuleProvider.class); 75 return provider.getConfigSupport().getWebContextRoot(); 76 } 77 78 81 private FindJSPServlet getServletFinder() { 82 ServerString serverS = getServerString(); 83 if (serverS == null) 84 return null; 85 ServerInstance inst = serverS.getServerInstance(); 86 if (inst == null) 87 return null; 88 return inst.getFindJSPServlet(); 89 } 90 91 public File getServletTempDirectory () { 92 FindJSPServlet find = getServletFinder(); 93 if (find == null) 94 return null; 95 String webURL = getWebURL(); 96 if (webURL == null) 97 return null; 98 return find.getServletTempDirectory(webURL); 102 103 121 } 122 123 public String getServletResourcePath(String jspResourcePath) { 124 FindJSPServlet find = getServletFinder(); 125 if (find == null) 126 return null; 127 String webURL = getWebURL(); 128 if (webURL == null) 129 return null; 130 return find.getServletResourcePath(webURL, jspResourcePath); 131 } 132 133 public String getServletEncoding(String jspResourcePath) { 134 FindJSPServlet find = getServletFinder(); 135 if (find == null) 136 return null; 137 String webURL = getWebURL(); 138 if (webURL == null) 139 return null; 140 return find.getServletEncoding(webURL, jspResourcePath); 141 } 142 143 public OldJSPDebug.JspSourceMapper getSourceMapper(String jspResourcePath) { 144 return null; 146 } 147 148 public void addPropertyChangeListener(PropertyChangeListener l) { 149 } 151 152 public void removePropertyChangeListener(PropertyChangeListener l) { 153 } 155 } 156 | Popular Tags |