You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by gr...@locus.apache.org on 2000/11/17 00:44:37 UTC
cvs commit: xml-cocoon/src/org/apache/cocoon Utils.java
greenrd 00/11/16 15:44:37
Modified: . changes.xml
src/org/apache/cocoon Utils.java
Log:
abstractmethoderror workaround
Revision Changes Path
1.148 +4 -0 xml-cocoon/changes.xml
Index: changes.xml
===================================================================
RCS file: /home/cvs/xml-cocoon/changes.xml,v
retrieving revision 1.147
retrieving revision 1.148
diff -u -r1.147 -r1.148
--- changes.xml 2000/11/16 17:31:53 1.147
+++ changes.xml 2000/11/16 23:44:36 1.148
@@ -4,7 +4,7 @@
<!--
History of Cocoon changes
- $Id: changes.xml,v 1.147 2000/11/16 17:31:53 greenrd Exp $
+ $Id: changes.xml,v 1.148 2000/11/16 23:44:36 greenrd Exp $
-->
<changes title="History of Changes">
@@ -18,6 +18,10 @@
</devs>
<release version="@version@" date="@date@">
+ <action dev="RDG" type="fix" due-to="Mike Ehlers"
+ due-to-email="maehlers@hewitt.com">
+ Workaround for an AbstractMethodError bug on some JDKs.
+ </action>
<action dev="RDG" type="add">
Added ability for Engine components to implement
org.apache.cocoon.framework.DestroyListener and be notified for cleanup
1.19 +18 -12 xml-cocoon/src/org/apache/cocoon/Utils.java
Index: Utils.java
===================================================================
RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/Utils.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- Utils.java 2000/11/07 18:30:13 1.18
+++ Utils.java 2000/11/16 23:44:37 1.19
@@ -1,4 +1,4 @@
-/*-- $Id: Utils.java,v 1.18 2000/11/07 18:30:13 greenrd Exp $ --
+/*-- $Id: Utils.java,v 1.19 2000/11/16 23:44:37 greenrd Exp $ --
============================================================================
The Apache Software License, Version 1.1
@@ -65,7 +65,8 @@
* Utility methods for Cocoon and its classes.
*
* @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
- * @version $Revision: 1.18 $ $Date: 2000/11/07 18:30:13 $
+ * @author <a href="mailto:greenrd@hotmail.com">Robin Green</a>
+ * @version $Revision: 1.19 $ $Date: 2000/11/16 23:44:37 $
*/
public final class Utils {
@@ -241,7 +242,8 @@
try {
// detect if the engine supports at least Servlet API 2.2
- request.getContextPath();
+ request.getClass ().getMethod ("getContextPath", null);
+
// we need to check this in case we've been included in a servlet or jsp
path = (String) request.getAttribute("javax.servlet.include.servlet_path");
// otherwise, we find it out ourselves
@@ -255,22 +257,26 @@
return resource.replace('\\','/');
} else {
throw new RuntimeException("Cannot access non-file/war resources");
- }
- } catch (NoSuchMethodError e) {
- // if there is no such method we must be in Servlet API 2.1
- if (request.getPathInfo() != null) {
- // this must be Apache JServ
- path = request.getPathTranslated();
- } else {
- // otherwise use the deprecated method on all other servlet engines.
- path = request.getRealPath(request.getRequestURI());
}
-
- return (path == null) ? "" : path.replace('\\','/');
+ } catch (NoSuchMethodException e) { // thrown from detection line
+ // if there is no such method we're not in Servlet API 2.2
+ return getBaseName_Old (request);
} catch (NullPointerException e) {
// if there is no context set, we must be called from the command line
return request.getPathTranslated().replace('\\','/');
}
+ }
+
+ private static String getBaseName_Old (HttpServletRequest request) {
+ String path;
+ if (request.getPathInfo() != null) {
+ // this must be Apache JServ
+ path = request.getPathTranslated();
+ } else {
+ // otherwise use the deprecated method on all other servlet engines.
+ path = request.getRealPath(request.getRequestURI());
+ }
+ return (path == null) ? "" : path.replace('\\','/');
}
/*