diff -r 128b8fb9d391 j2ee.weblogic9/nbproject/project.xml --- a/j2ee.weblogic9/nbproject/project.xml Tue Jan 11 12:37:09 2011 +0300 +++ b/j2ee.weblogic9/nbproject/project.xml Tue Jan 11 14:43:53 2011 +0100 @@ -140,7 +140,7 @@ 4 - 1.72 + 1.75 diff -r 128b8fb9d391 j2ee.weblogic9/src/org/netbeans/modules/j2ee/weblogic9/config/WarDeploymentConfiguration.java --- a/j2ee.weblogic9/src/org/netbeans/modules/j2ee/weblogic9/config/WarDeploymentConfiguration.java Tue Jan 11 12:37:09 2011 +0300 +++ b/j2ee.weblogic9/src/org/netbeans/modules/j2ee/weblogic9/config/WarDeploymentConfiguration.java Tue Jan 11 14:43:53 2011 +0100 @@ -296,6 +296,7 @@ webLogicWebApp.setContextRoot(new String [] {""}); // NOI18N JspDescriptorType jspDescriptor = new JspDescriptorType(); jspDescriptor.setKeepgenerated(true); + jspDescriptor.setDebug(true); webLogicWebApp.setJspDescriptor(new JspDescriptorType[] {jspDescriptor}); return webLogicWebApp; } diff -r 128b8fb9d391 j2ee.weblogic9/src/org/netbeans/modules/j2ee/weblogic9/optional/WLFindJSPServlet.java --- a/j2ee.weblogic9/src/org/netbeans/modules/j2ee/weblogic9/optional/WLFindJSPServlet.java Tue Jan 11 12:37:09 2011 +0300 +++ b/j2ee.weblogic9/src/org/netbeans/modules/j2ee/weblogic9/optional/WLFindJSPServlet.java Tue Jan 11 14:43:53 2011 +0100 @@ -48,7 +48,7 @@ import java.util.logging.Logger; import javax.management.MBeanServerConnection; import javax.management.ObjectName; -import org.netbeans.modules.j2ee.deployment.plugins.spi.FindJSPServlet; +import org.netbeans.modules.j2ee.deployment.plugins.spi.FindJSPServlet2; import org.netbeans.modules.j2ee.weblogic9.WLConnectionSupport; import org.netbeans.modules.j2ee.weblogic9.WLPluginProperties; import org.netbeans.modules.j2ee.weblogic9.deploy.WLDeploymentManager; @@ -58,7 +58,7 @@ * @author Petr Hejl */ // FIXME user can configure the directory for JSP servlets -public class WLFindJSPServlet implements FindJSPServlet { +public class WLFindJSPServlet implements FindJSPServlet2 { private static final Logger LOGGER = Logger.getLogger(WLFindJSPServlet.class.getName()); @@ -70,6 +70,7 @@ @Override public File getServletTempDirectory(String moduleContextPath) { + // XXX should it be always existing directory ? ApplicationDescriptor desc = getApplicationDescriptor(moduleContextPath); if (desc == null) { return null; @@ -87,7 +88,8 @@ // FIXME multiple subdirs - what does that mean File servletDir = new File(subdir, "jsp_servlet"); // NOI18N if (servletDir.exists() && servletDir.isDirectory()) { - return servletDir; + // FIXME make simpler + return servletDir.getParentFile(); } } } @@ -104,7 +106,7 @@ String[] parts = fixedJspResourcePath.split("/"); // NOI18N String jspFile = parts[parts.length - 1]; - StringBuilder result = new StringBuilder(); + StringBuilder result = new StringBuilder("jsp_servlet/"); // NOI18N for (int i = 0; i < (parts.length - 1); i++) { result.append("_").append(parts[i]).append("/"); // NOI18N } @@ -120,6 +122,28 @@ } @Override + public String getServletBasePackageName(String moduleContextPath) { + return "jsp_servlet"; // NOI18N + } + + @Override + public String getServletSourcePath(String moduleContextPath, String jspRelativePath) { + StringBuilder builder = new StringBuilder("jsp_servlet/"); // NOI18N + String parts[] = jspRelativePath.split("/"); // NOI18N + for (int i = 0; i < parts.length; i++) { + String part = parts[i]; + if (part.length() > 0 && i < (parts.length - 1)) { + builder.append("_"); // NOI18N + } + builder.append(part); + if (i < (parts.length - 1)) { + builder.append("/"); // NOI18N + } + } + return builder.toString(); + } + + @Override public String getServletEncoding(String moduleContextPath, String jspResourcePath) { return "UTF8"; // NOI18N } diff -r 128b8fb9d391 j2eeserver/nbproject/project.properties --- a/j2eeserver/nbproject/project.properties Tue Jan 11 12:37:09 2011 +0300 +++ b/j2eeserver/nbproject/project.properties Tue Jan 11 14:43:53 2011 +0100 @@ -42,7 +42,7 @@ is.autoload=true javac.source=1.6 -spec.version.base=1.74.0 +spec.version.base=1.75.0 javadoc.arch=${basedir}/arch.xml javadoc.apichanges=${basedir}/apichanges.xml diff -r 128b8fb9d391 j2eeserver/src/org/netbeans/modules/j2ee/deployment/devmodules/api/JSPServletFinder.java --- a/j2eeserver/src/org/netbeans/modules/j2ee/deployment/devmodules/api/JSPServletFinder.java Tue Jan 11 12:37:09 2011 +0300 +++ b/j2eeserver/src/org/netbeans/modules/j2ee/deployment/devmodules/api/JSPServletFinder.java Tue Jan 11 14:43:53 2011 +0100 @@ -46,6 +46,7 @@ import java.beans.PropertyChangeListener; import java.io.File; +import org.netbeans.api.annotations.common.CheckForNull; import org.netbeans.api.project.FileOwnerQuery; import org.netbeans.api.project.Project; import org.netbeans.modules.j2ee.deployment.common.api.ConfigurationException; @@ -54,6 +55,7 @@ import org.netbeans.modules.j2ee.deployment.impl.ServerRegistry; import org.netbeans.modules.j2ee.deployment.impl.ServerString; import org.netbeans.modules.j2ee.deployment.plugins.spi.FindJSPServlet; +import org.netbeans.modules.j2ee.deployment.plugins.spi.FindJSPServlet2; import org.netbeans.modules.j2ee.deployment.plugins.spi.OldJSPDebug; import org.openide.filesystems.FileObject; @@ -172,6 +174,32 @@ return find.getServletEncoding(webURL, jspResourcePath); } + @CheckForNull + public String getServletBasePackageName() { + FindJSPServlet find = getServletFinder(); + if (!(find instanceof FindJSPServlet2)) { + return null; + } + String webURL = getWebURL(); + if (webURL == null) { + return null; + } + return ((FindJSPServlet2) find).getServletBasePackageName(webURL); + } + + @CheckForNull + public String getServletSourcePath(String jspRelativePath) { + FindJSPServlet find = getServletFinder(); + if (!(find instanceof FindJSPServlet2)) { + return null; + } + String webURL = getWebURL(); + if (webURL == null) { + return null; + } + return ((FindJSPServlet2) find).getServletSourcePath(webURL, jspRelativePath); + } + public OldJSPDebug.JspSourceMapper getSourceMapper(String jspResourcePath) { // PENDING return null; diff -r 128b8fb9d391 j2eeserver/src/org/netbeans/modules/j2ee/deployment/plugins/spi/FindJSPServlet2.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/j2eeserver/src/org/netbeans/modules/j2ee/deployment/plugins/spi/FindJSPServlet2.java Tue Jan 11 14:43:53 2011 +0100 @@ -0,0 +1,76 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2011 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2011 Sun Microsystems, Inc. + */ + +package org.netbeans.modules.j2ee.deployment.plugins.spi; + +/** + * Extends the functionality of {@link FindJSPServlet} by defining + * the package name of the compiled JSPs and the prefix of source + * path. In order to use it return implementation of this class from + * {@link OptionalDeploymentManagerFactory#getFindJSPServlet(javax.enterprise.deploy.spi.DeploymentManager)}. + * + * @author Petr Hejl + * @since 1.75 + */ +public interface FindJSPServlet2 extends FindJSPServlet { + + /** + * Returns the package name of compiled JSPs. + * + * @param moduleContextPath the context path + * @return package name of compiled JSPs + */ + String getServletBasePackageName(String moduleContextPath); + + /** + * Returns the relative source of the JSP reported in class file. For + * example the JSP in web root is "index.jsp", but the server compile it as + * coming from "jsp_servlet/index.jsp". This method should return + * "jsp_servlet/index.jsp". + * + * @param moduleContextPath the context path + * @param jspRelativePath the relative path of the JSP + * @return prefix of the source path reported in class file + */ + String getServletSourcePath(String moduleContextPath, String jspRelativePath); + +} diff -r 128b8fb9d391 web.debug/nbproject/project.xml --- a/web.debug/nbproject/project.xml Tue Jan 11 12:37:09 2011 +0300 +++ b/web.debug/nbproject/project.xml Tue Jan 11 14:43:53 2011 +0100 @@ -77,6 +77,7 @@ 4 + 1.75 diff -r 128b8fb9d391 web.debug/src/org/netbeans/modules/web/debug/EngineContextProviderImpl.java --- a/web.debug/src/org/netbeans/modules/web/debug/EngineContextProviderImpl.java Tue Jan 11 12:37:09 2011 +0300 +++ b/web.debug/src/org/netbeans/modules/web/debug/EngineContextProviderImpl.java Tue Jan 11 14:43:53 2011 +0100 @@ -49,9 +49,12 @@ import java.net.MalformedURLException; import java.util.Arrays; import java.util.HashSet; +import java.util.Iterator; +import java.util.List; import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; +import org.netbeans.api.debugger.DebuggerManager; import org.netbeans.spi.debugger.jpda.SourcePathProvider; @@ -70,7 +73,8 @@ new String[] { "org", // NOI18N "org/apache", // NOI18N - "org/apache/jsp" // NOI18N + "org/apache/jsp", // NOI18N + "jsp_servlet" } )); @@ -92,7 +96,8 @@ if ((relativePath == null) || (relativePath.endsWith(".java"))) { return null; } - if (virtualFolders.contains (relativePath) || relativePath.startsWith("org/apache/jsp")) { // NOI18N + if (virtualFolders.contains (relativePath) + || relativePath.startsWith("org/apache/jsp")) { // NOI18N if (verbose) System.out.println ("ECPI(JSP): fo virtual folder"); String userDir = System.getProperty("netbeans.user"); // NOI18N @@ -125,9 +130,33 @@ LOGGER.log(Level.INFO, "Both netbeans.user and java.io.tmpdir properties are missing, returning null"); return null; } + // XXX terrible hack - in addition WL specific code + if (relativePath.startsWith("jsp_servlet")) { // NOI18N + SourcePathProvider provider = getDefaultContext(); + if (provider != null) { + String path = relativePath.substring(11); + path = path.replaceAll("/_", "/"); // NOI8N + if (path.startsWith("/")) { + path = path.substring(1); + } + return provider.getURL(path, global); + } + } return null; } + private static SourcePathProvider getDefaultContext() { + List providers = DebuggerManager.getDebuggerManager(). + lookup("netbeans-JPDASession", SourcePathProvider.class); + for (Iterator it = providers.iterator(); it.hasNext(); ) { + Object provider = it.next(); + // Hack - find our provider: + if (provider.getClass().getName().equals("org.netbeans.modules.debugger.jpda.projects.SourcePathProviderImpl")) { + return (SourcePathProvider) provider; + } + } + return null; + } /** * Returns relative path for given url. diff -r 128b8fb9d391 web.debug/src/org/netbeans/modules/web/debug/actions/JspToggleBreakpointActionProvider.java --- a/web.debug/src/org/netbeans/modules/web/debug/actions/JspToggleBreakpointActionProvider.java Tue Jan 11 12:37:09 2011 +0300 +++ b/web.debug/src/org/netbeans/modules/web/debug/actions/JspToggleBreakpointActionProvider.java Tue Jan 11 14:43:53 2011 +0100 @@ -103,12 +103,10 @@ } //#issue 65969 fix: - //we allow bp setting only if the file is JSP or TAG file and target server of it's module is NOT WebLogic 9; + //we allow bp setting only if the file is JSP or TAG file //TODO it should be solved by adding new API into j2eeserver which should announce whether the target server //supports JSP debugging or not - String serverID = Utils.getTargetServerID(fo); - - setEnabled(ActionsManager.ACTION_TOGGLE_BREAKPOINT, owner != null && webRoot != null && isJsp && !"WebLogic9".equals(serverID)); //NOI18N + setEnabled(ActionsManager.ACTION_TOGGLE_BREAKPOINT, owner != null && webRoot != null && isJsp); if ( debugger != null && debugger.getState () == debugger.STATE_DISCONNECTED ) diff -r 128b8fb9d391 web.debug/src/org/netbeans/modules/web/debug/util/JspNameUtil.java --- a/web.debug/src/org/netbeans/modules/web/debug/util/JspNameUtil.java Tue Jan 11 12:37:09 2011 +0300 +++ b/web.debug/src/org/netbeans/modules/web/debug/util/JspNameUtil.java Tue Jan 11 14:43:53 2011 +0100 @@ -45,6 +45,7 @@ package org.netbeans.modules.web.debug.util; import java.util.Vector; +import org.netbeans.modules.j2ee.deployment.devmodules.api.JSPServletFinder; /** Various utilities copied over from org.apache.jasper.JspUtil. */ @@ -177,17 +178,22 @@ return false; } - public static String getServletResourcePath(String moduleContextPath, String jspResourcePath) { - return getServletPackageName(jspResourcePath).replace('.', '/') + '/' + + public static String getServletResourcePath(JSPServletFinder finder, String moduleContextPath, String jspResourcePath) { + return getServletPackageName(finder, jspResourcePath).replace('.', '/') + '/' + getServletClassName(jspResourcePath) + ".java"; } - private static String getServletPackageName(String jspUri) { + private static String getServletPackageName(JSPServletFinder finder, String jspUri) { String dPackageName = getDerivedPackageName(jspUri); + String basePackage = finder.getServletBasePackageName(); + if (basePackage == null) { + basePackage = JSP_PACKAGE_NAME; + } if (dPackageName.length() == 0) { - return JSP_PACKAGE_NAME; + return basePackage; } - return JSP_PACKAGE_NAME + '.' + getDerivedPackageName(jspUri); + + return basePackage + '.' + getDerivedPackageName(jspUri); } private static String getDerivedPackageName(String jspUri) { diff -r 128b8fb9d391 web.debug/src/org/netbeans/modules/web/debug/util/Utils.java --- a/web.debug/src/org/netbeans/modules/web/debug/util/Utils.java Tue Jan 11 12:37:09 2011 +0300 +++ b/web.debug/src/org/netbeans/modules/web/debug/util/Utils.java Tue Jan 11 14:43:53 2011 +0100 @@ -137,8 +137,7 @@ return (url == null) ? null : url.toString(); } - public static String getJspPath(String url) { - + public static String getJspPath(String url) { FileObject fo = getFileObjectFromUrl(url); String jspRelativePath = url; if (fo != null) { @@ -146,9 +145,13 @@ if (wm != null) jspRelativePath = FileUtil.getRelativePath(wm.getDocumentBase(), fo); } + JSPServletFinder finder = JSPServletFinder.findJSPServletFinder (fo); + String translated = finder.getServletSourcePath(jspRelativePath); + if (translated != null) { + return translated; + } return jspRelativePath; - } public static String getServletClass(String url) { @@ -177,7 +180,7 @@ String servletPath = finder.getServletResourcePath(jspRelativePath); if (servletPath == null) // we don't have class name, so assume we are debugging tomcat or appsrv - servletPath = JspNameUtil.getServletResourcePath(contextPath, jspRelativePath); + servletPath = JspNameUtil.getServletResourcePath(finder, contextPath, jspRelativePath); if (servletPath != null) { servletPath = servletPath.substring(0, servletPath.length()-5); // length of ".java" servletPath = servletPath.replace('/', '.'); //NOI18N @@ -187,12 +190,25 @@ } public static String getClassFilter(String url) { + FileObject fo = getFileObjectFromUrl(url); + if (fo == null) { + return null; + } + JSPServletFinder finder = JSPServletFinder.findJSPServletFinder (fo); + String filter = getServletClass(url); if (filter != null) { // get package only - filter = filter.substring(0, filter.lastIndexOf('.')) + ".*"; //NOI18N - if (filter.startsWith("org.apache.jsp")) - filter = "org.apache.jsp.*"; + int lastDot = filter.lastIndexOf('.'); + if (lastDot > 0) { + filter = filter.substring(0, lastDot) + ".*"; //NOI18N + String basePackageName = finder.getServletBasePackageName(); + if (basePackageName == null) { + basePackageName = "org.apache.jsp"; // NOI18N + } + if (filter.startsWith(basePackageName)) + filter = basePackageName + ".*"; // NOI18N + } } return filter; }