remm 02/05/21 18:15:18 Modified: coyote/src/java/org/apache/coyote/tomcat4 CoyoteRequest.java CoyoteResponse.java Added: coyote/src/java/org/apache/coyote/tomcat4 CoyoteRequestFacade.java CoyoteResponseFacade.java Log: - Fix compatibility problems between Tomcat 4.0.x and Coyote 1.0 RC 1. Unfortunately, there is no clean way to add the missing method to the facades from 4.0.x. - The version of Coyote included in 4.0.4 Beta 3 works fine. - Coyote 1.0 RC 1 has been pulled, and a 1.0 RC 2 will be made available shortly to replace it. - Many thanks to Jon Stevens for testing this and for the report (and shame on me for not testing it again before release ;-)). Revision Changes Path 1.22 +6 -8 jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat4/CoyoteRequest.java Index: CoyoteRequest.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat4/CoyoteRequest.java,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- CoyoteRequest.java 15 May 2002 04:24:45 -0000 1.21 +++ CoyoteRequest.java 22 May 2002 01:15:18 -0000 1.22 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat4/CoyoteRequest.java,v 1.21 2002/05/15 04:24:45 remm Exp $ - * $Revision: 1.21 $ - * $Date: 2002/05/15 04:24:45 $ + * $Header: /home/cvs/jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat4/CoyoteRequest.java,v 1.22 2002/05/22 01:15:18 remm Exp $ + * $Revision: 1.22 $ + * $Date: 2002/05/22 01:15:18 $ * * ==================================================================== * @@ -110,8 +110,6 @@ import org.apache.catalina.Session; import org.apache.catalina.Wrapper; -import org.apache.catalina.connector.HttpRequestFacade; - import org.apache.catalina.util.Enumerator; import org.apache.catalina.util.ParameterMap; import org.apache.catalina.util.RequestUtil; @@ -124,7 +122,7 @@ * * @author Remy Maucherat * @author Craig R. McClanahan - * @version $Revision: 1.21 $ $Date: 2002/05/15 04:24:45 $ + * @version $Revision: 1.22 $ $Date: 2002/05/22 01:15:18 $ */ public class CoyoteRequest @@ -512,7 +510,7 @@ /** * The facade associated with this request. */ - protected HttpRequestFacade facade = null; + protected CoyoteRequestFacade facade = null; /** * Return the <code>ServletRequest</code> for which this object @@ -520,7 +518,7 @@ */ public ServletRequest getRequest() { if (facade == null) { - facade = new HttpRequestFacade(this); + facade = new CoyoteRequestFacade(this); } return (facade); } 1.16 +6 -7 jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat4/CoyoteResponse.java Index: CoyoteResponse.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat4/CoyoteResponse.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- CoyoteResponse.java 15 May 2002 04:24:45 -0000 1.15 +++ CoyoteResponse.java 22 May 2002 01:15:18 -0000 1.16 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat4/CoyoteResponse.java,v 1.15 2002/05/15 04:24:45 remm Exp $ - * $Revision: 1.15 $ - * $Date: 2002/05/15 04:24:45 $ + * $Header: /home/cvs/jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat4/CoyoteResponse.java,v 1.16 2002/05/22 01:15:18 remm Exp $ + * $Revision: 1.16 $ + * $Date: 2002/05/22 01:15:18 $ * * ==================================================================== * @@ -105,7 +105,6 @@ import org.apache.catalina.Realm; import org.apache.catalina.Session; import org.apache.catalina.Wrapper; -import org.apache.catalina.connector.HttpResponseFacade; import org.apache.catalina.util.CharsetMapper; import org.apache.catalina.util.RequestUtil; import org.apache.catalina.util.StringManager; @@ -116,7 +115,7 @@ * * @author Remy Maucherat * @author Craig R. McClanahan - * @version $Revision: 1.15 $ $Date: 2002/05/15 04:24:45 $ + * @version $Revision: 1.16 $ $Date: 2002/05/22 01:15:18 $ */ public class CoyoteResponse @@ -406,7 +405,7 @@ /** * The facade associated with this response. */ - protected HttpResponseFacade facade = null; + protected CoyoteResponseFacade facade = null; /** * Return the <code>ServletResponse</code> for which this object @@ -414,7 +413,7 @@ */ public ServletResponse getResponse() { if (facade == null) { - facade = new HttpResponseFacade(this); + facade = new CoyoteResponseFacade(this); } return (facade); } 1.1 jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat4/CoyoteRequestFacade.java Index: CoyoteRequestFacade.java =================================================================== /* * $Header: /home/cvs/jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat4/CoyoteRequestFacade.java,v 1.1 2002/05/22 01:15:18 remm Exp $ * $Revision: 1.1 $ * $Date: 2002/05/22 01:15:18 $ * * ==================================================================== * * The Apache Software License, Version 1.1 * * Copyright (c) 1999 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, if * any, must include the following acknowlegement: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowlegement may appear in the software itself, * if and wherever such third-party acknowlegements normally appear. * * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software * Foundation" must not be used to endorse or promote products derived * from this software without prior written permission. For written * permission, please contact [EMAIL PROTECTED] * * 5. Products derived from this software may not be called "Apache" * nor may "Apache" appear in their names without prior written * permission of the Apache Group. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. * * [Additional notices, if required by prior licensing conditions] * */ package org.apache.coyote.tomcat4; import java.io.InputStream; import java.io.BufferedReader; import java.io.IOException; import java.util.Enumeration; import java.util.Map; import java.util.Locale; import java.net.Socket; import javax.servlet.ServletException; import javax.servlet.ServletInputStream; import javax.servlet.ServletRequest; import javax.servlet.RequestDispatcher; import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; import org.apache.catalina.connector.RequestFacade; import org.apache.catalina.session.StandardSessionFacade; /** * Facade class that wraps a Coyote request object. * All methods are delegated to the wrapped request. * * @author Craig R. McClanahan * @author Remy Maucherat * @version $Revision: 1.1 $ $Date: 2002/05/22 01:15:18 $ */ public class CoyoteRequestFacade extends RequestFacade implements HttpServletRequest { // ----------------------------------------------------------- Constructors /** * Construct a wrapper for the specified request. * * @param request The request to be wrapped */ public CoyoteRequestFacade(CoyoteRequest request) { super(request); this.request = request; } // ----------------------------------------------------- Instance Variables /** * The wrapped request. */ protected CoyoteRequest request = null; // --------------------------------------------------------- Public Methods /** * Clear facade. */ public void clear() { request = null; } // ------------------------------------------------- ServletRequest Methods public Object getAttribute(String name) { return request.getAttribute(name); } public Enumeration getAttributeNames() { return request.getAttributeNames(); } public String getCharacterEncoding() { return request.getCharacterEncoding(); } public void setCharacterEncoding(String env) throws java.io.UnsupportedEncodingException { request.setCharacterEncoding(env); } public int getContentLength() { return request.getContentLength(); } public String getContentType() { return request.getContentType(); } public ServletInputStream getInputStream() throws IOException { return request.getInputStream(); } public String getParameter(String name) { return request.getParameter(name); } public Enumeration getParameterNames() { return request.getParameterNames(); } public String[] getParameterValues(String name) { return request.getParameterValues(name); } public Map getParameterMap() { return request.getParameterMap(); } public String getProtocol() { return request.getProtocol(); } public String getScheme() { return request.getScheme(); } public String getServerName() { return request.getServerName(); } public int getServerPort() { return request.getServerPort(); } public BufferedReader getReader() throws IOException { return request.getReader(); } public String getRemoteAddr() { return request.getRemoteAddr(); } public String getRemoteHost() { return request.getRemoteHost(); } public void setAttribute(String name, Object o) { request.setAttribute(name, o); } public void removeAttribute(String name) { request.removeAttribute(name); } public Locale getLocale() { return request.getLocale(); } public Enumeration getLocales() { return request.getLocales(); } public boolean isSecure() { return request.isSecure(); } public RequestDispatcher getRequestDispatcher(String path) { // TODO : Facade !! return request.getRequestDispatcher(path); } public String getRealPath(String path) { return request.getRealPath(path); } public String getAuthType() { return request.getAuthType(); } public Cookie[] getCookies() { return request.getCookies(); } public long getDateHeader(String name) { return request.getDateHeader(name); } public String getHeader(String name) { return request.getHeader(name); } public Enumeration getHeaders(String name) { return request.getHeaders(name); } public Enumeration getHeaderNames() { return request.getHeaderNames(); } public int getIntHeader(String name) { return request.getIntHeader(name); } public String getMethod() { return request.getMethod(); } public String getPathInfo() { return request.getPathInfo(); } public String getPathTranslated() { return request.getPathTranslated(); } public String getContextPath() { return request.getContextPath(); } public String getQueryString() { return request.getQueryString(); } public String getRemoteUser() { return request.getRemoteUser(); } public boolean isUserInRole(String role) { return request.isUserInRole(role); } public java.security.Principal getUserPrincipal() { return request.getUserPrincipal(); } public String getRequestedSessionId() { return request.getRequestedSessionId(); } public String getRequestURI() { return request.getRequestURI(); } public StringBuffer getRequestURL() { return request.getRequestURL(); } public String getServletPath() { return request.getServletPath(); } public HttpSession getSession(boolean create) { HttpSession session = request.getSession(create); if (session == null) return null; else return new StandardSessionFacade(session); } public HttpSession getSession() { return getSession(true); } public boolean isRequestedSessionIdValid() { return request.isRequestedSessionIdValid(); } public boolean isRequestedSessionIdFromCookie() { return request.isRequestedSessionIdFromCookie(); } public boolean isRequestedSessionIdFromURL() { return request.isRequestedSessionIdFromURL(); } public boolean isRequestedSessionIdFromUrl() { return request.isRequestedSessionIdFromURL(); } } 1.1 jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat4/CoyoteResponseFacade.java Index: CoyoteResponseFacade.java =================================================================== /* * $Header: /home/cvs/jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat4/CoyoteResponseFacade.java,v 1.1 2002/05/22 01:15:18 remm Exp $ * $Revision: 1.1 $ * $Date: 2002/05/22 01:15:18 $ * * ==================================================================== * * The Apache Software License, Version 1.1 * * Copyright (c) 1999 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, if * any, must include the following acknowlegement: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowlegement may appear in the software itself, * if and wherever such third-party acknowlegements normally appear. * * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software * Foundation" must not be used to endorse or promote products derived * from this software without prior written permission. For written * permission, please contact [EMAIL PROTECTED] * * 5. Products derived from this software may not be called "Apache" * nor may "Apache" appear in their names without prior written * permission of the Apache Group. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. * * [Additional notices, if required by prior licensing conditions] * */ package org.apache.coyote.tomcat4; import java.io.IOException; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Locale; import javax.servlet.ServletException; import javax.servlet.ServletOutputStream; import javax.servlet.ServletResponse; import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletResponse; import org.apache.catalina.connector.ResponseFacade; /** * Facade class that wraps a Coyote response object. * All methods are delegated to the wrapped response. * * @author Remy Maucherat * @version $Revision: 1.1 $ $Date: 2002/05/22 01:15:18 $ */ public class CoyoteResponseFacade extends ResponseFacade implements HttpServletResponse { // ----------------------------------------------------------- Constructors /** * Construct a wrapper for the specified response. * * @param response The response to be wrapped */ public CoyoteResponseFacade(CoyoteResponse response) { super(response); this.response = response; } // ----------------------------------------------------- Instance Variables /** * The wrapped response. */ protected CoyoteResponse response = null; // --------------------------------------------------------- Public Methods /** * Clear facade. */ public void clear() { response = null; } public void finish() { response.setSuspended(true); } public boolean isFinished() { return response.isSuspended(); } // ------------------------------------------------ ServletResponse Methods public String getCharacterEncoding() { return response.getCharacterEncoding(); } public ServletOutputStream getOutputStream() throws IOException { // if (isFinished()) // throw new IllegalStateException // (/*sm.getString("responseFacade.finished")*/); ServletOutputStream sos = response.getOutputStream(); if (isFinished()) response.setSuspended(true); return (sos); } public PrintWriter getWriter() throws IOException { // if (isFinished()) // throw new IllegalStateException // (/*sm.getString("responseFacade.finished")*/); PrintWriter writer = response.getWriter(); if (isFinished()) response.setSuspended(true); return (writer); } public void setContentLength(int len) { if (isCommitted()) return; response.setContentLength(len); } public void setContentType(String type) { if (isCommitted()) return; response.setContentType(type); } public void setBufferSize(int size) { if (isCommitted()) throw new IllegalStateException (/*sm.getString("responseBase.reset.ise")*/); response.setBufferSize(size); } public int getBufferSize() { return response.getBufferSize(); } public void flushBuffer() throws IOException { if (isFinished()) // throw new IllegalStateException // (/*sm.getString("responseFacade.finished")*/); return; response.setAppCommitted(true); response.flushBuffer(); } public void resetBuffer() { if (isCommitted()) throw new IllegalStateException (/*sm.getString("responseBase.reset.ise")*/); response.resetBuffer(); } public boolean isCommitted() { return (response.isAppCommitted()); } public void reset() { if (isCommitted()) throw new IllegalStateException (/*sm.getString("responseBase.reset.ise")*/); response.reset(); } public void setLocale(Locale loc) { if (isCommitted()) return; response.setLocale(loc); } public Locale getLocale() { return response.getLocale(); } public void addCookie(Cookie cookie) { if (isCommitted()) return; response.addCookie(cookie); } public boolean containsHeader(String name) { return response.containsHeader(name); } public String encodeURL(String url) { return response.encodeURL(url); } public String encodeRedirectURL(String url) { return response.encodeRedirectURL(url); } public String encodeUrl(String url) { return response.encodeURL(url); } public String encodeRedirectUrl(String url) { return response.encodeRedirectURL(url); } public void sendError(int sc, String msg) throws IOException { if (isCommitted()) throw new IllegalStateException (/*sm.getString("responseBase.reset.ise")*/); response.setAppCommitted(true); response.sendError(sc, msg); } public void sendError(int sc) throws IOException { if (isCommitted()) throw new IllegalStateException (/*sm.getString("responseBase.reset.ise")*/); response.setAppCommitted(true); response.sendError(sc); } public void sendRedirect(String location) throws IOException { if (isCommitted()) throw new IllegalStateException (/*sm.getString("responseBase.reset.ise")*/); response.setAppCommitted(true); response.sendRedirect(location); } public void setDateHeader(String name, long date) { if (isCommitted()) return; response.setDateHeader(name, date); } public void addDateHeader(String name, long date) { if (isCommitted()) return; response.addDateHeader(name, date); } public void setHeader(String name, String value) { if (isCommitted()) return; response.setHeader(name, value); } public void addHeader(String name, String value) { if (isCommitted()) return; response.addHeader(name, value); } public void setIntHeader(String name, int value) { if (isCommitted()) return; response.setIntHeader(name, value); } public void addIntHeader(String name, int value) { if (isCommitted()) return; response.addIntHeader(name, value); } public void setStatus(int sc) { if (isCommitted()) return; response.setStatus(sc); } public void setStatus(int sc, String sm) { if (isCommitted()) return; response.setStatus(sc, sm); } }
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>