diff -r 043eb173e2a5 j2ee.weblogic9/nbproject/project.xml
--- a/j2ee.weblogic9/nbproject/project.xml Fri Jan 07 16:08:07 2011 -0800
+++ b/j2ee.weblogic9/nbproject/project.xml Tue Jan 11 11:07:21 2011 +0100
@@ -140,7 +140,7 @@
4
- 1.72
+ 1.75
diff -r 043eb173e2a5 j2ee.weblogic9/src/org/netbeans/modules/j2ee/weblogic9/optional/WLFindJSPServlet.java
--- a/j2ee.weblogic9/src/org/netbeans/modules/j2ee/weblogic9/optional/WLFindJSPServlet.java Fri Jan 07 16:08:07 2011 -0800
+++ b/j2ee.weblogic9/src/org/netbeans/modules/j2ee/weblogic9/optional/WLFindJSPServlet.java Tue Jan 11 11:07:21 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,16 @@
}
@Override
+ public String getJspBasePackageName(String moduleContextPath) {
+ return "jsp_servlet"; // NOI18N
+ }
+
+ @Override
+ public String getJspSourcePathPrefix(String moduleContextPath) {
+ return "jsp_servlet"; // NOI18N
+ }
+
+ @Override
public String getServletEncoding(String moduleContextPath, String jspResourcePath) {
return "UTF8"; // NOI18N
}
diff -r 043eb173e2a5 j2eeserver/nbproject/project.properties
--- a/j2eeserver/nbproject/project.properties Fri Jan 07 16:08:07 2011 -0800
+++ b/j2eeserver/nbproject/project.properties Tue Jan 11 11:07:21 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 043eb173e2a5 j2eeserver/src/org/netbeans/modules/j2ee/deployment/devmodules/api/JSPServletFinder.java
--- a/j2eeserver/src/org/netbeans/modules/j2ee/deployment/devmodules/api/JSPServletFinder.java Fri Jan 07 16:08:07 2011 -0800
+++ b/j2eeserver/src/org/netbeans/modules/j2ee/deployment/devmodules/api/JSPServletFinder.java Tue Jan 11 11:07:21 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).getJspBasePackageName(webURL);
+ }
+
+ @CheckForNull
+ public String getJspSourcePathPrefix() {
+ FindJSPServlet find = getServletFinder();
+ if (!(find instanceof FindJSPServlet2)) {
+ return null;
+ }
+ String webURL = getWebURL();
+ if (webURL == null) {
+ return null;
+ }
+ return ((FindJSPServlet2) find).getJspSourcePathPrefix(webURL);
+ }
+
public OldJSPDebug.JspSourceMapper getSourceMapper(String jspResourcePath) {
// PENDING
return null;
diff -r 043eb173e2a5 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 11:07:21 2011 +0100
@@ -0,0 +1,75 @@
+/*
+ * 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 {
+
+ /**
+ * The package name of compiled JSPs.
+ *
+ * @param moduleContextPath the context path
+ * @return package name of compiled JSPs
+ */
+ String getJspBasePackageName(String moduleContextPath);
+
+ /**
+ * The prefix of source path 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".
+ *
+ * @param moduleContextPath
+ * @return prefix of the source path reported in class file
+ */
+ String getJspSourcePathPrefix(String moduleContextPath);
+
+}
diff -r 043eb173e2a5 web.debug/nbproject/project.xml
--- a/web.debug/nbproject/project.xml Fri Jan 07 16:08:07 2011 -0800
+++ b/web.debug/nbproject/project.xml Tue Jan 11 11:07:21 2011 +0100
@@ -77,6 +77,7 @@
4
+ 1.75
diff -r 043eb173e2a5 web.debug/src/org/netbeans/modules/web/debug/EngineContextProviderImpl.java
--- a/web.debug/src/org/netbeans/modules/web/debug/EngineContextProviderImpl.java Fri Jan 07 16:08:07 2011 -0800
+++ b/web.debug/src/org/netbeans/modules/web/debug/EngineContextProviderImpl.java Tue Jan 11 11:07:21 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,28 @@
LOGGER.log(Level.INFO, "Both netbeans.user and java.io.tmpdir properties are missing, returning null");
return null;
}
+ // XXX terrible hack
+ if (relativePath.startsWith("jsp_servlet")) {
+ SourcePathProvider provider = getDefaultContext();
+ if (provider != null) {
+ return provider.getURL(relativePath.substring(11), 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 043eb173e2a5 web.debug/src/org/netbeans/modules/web/debug/actions/JspToggleBreakpointActionProvider.java
--- a/web.debug/src/org/netbeans/modules/web/debug/actions/JspToggleBreakpointActionProvider.java Fri Jan 07 16:08:07 2011 -0800
+++ b/web.debug/src/org/netbeans/modules/web/debug/actions/JspToggleBreakpointActionProvider.java Tue Jan 11 11:07:21 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 043eb173e2a5 web.debug/src/org/netbeans/modules/web/debug/util/JspNameUtil.java
--- a/web.debug/src/org/netbeans/modules/web/debug/util/JspNameUtil.java Fri Jan 07 16:08:07 2011 -0800
+++ b/web.debug/src/org/netbeans/modules/web/debug/util/JspNameUtil.java Tue Jan 11 11:07:21 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 043eb173e2a5 web.debug/src/org/netbeans/modules/web/debug/util/Utils.java
--- a/web.debug/src/org/netbeans/modules/web/debug/util/Utils.java Fri Jan 07 16:08:07 2011 -0800
+++ b/web.debug/src/org/netbeans/modules/web/debug/util/Utils.java Tue Jan 11 11:07:21 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,6 +145,11 @@
if (wm != null)
jspRelativePath = FileUtil.getRelativePath(wm.getDocumentBase(), fo);
}
+ JSPServletFinder finder = JSPServletFinder.findJSPServletFinder (fo);
+ String prefix = finder.getJspSourcePathPrefix();
+ if (prefix != null) {
+ return prefix + "/" + jspRelativePath; // NOI18N
+ }
return jspRelativePath;
@@ -177,7 +181,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 +191,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;
}