You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by di...@apache.org on 2002/09/04 04:59:26 UTC
cvs commit: jakarta-commons/latka/src/java/org/apache/commons/latka/http MethodFactory.java RequestImpl.java Request.java
dion 2002/09/03 19:59:26
Modified: latka/src/java/org/apache/commons/latka/http
RequestImpl.java Request.java
Added: latka/src/java/org/apache/commons/latka/http
MethodFactory.java
Log:
Patch from Ryan Lubke to refactor the creation of the HTTP method from RequestImpl
Revision Changes Path
1.29 +5 -22 jakarta-commons/latka/src/java/org/apache/commons/latka/http/RequestImpl.java
Index: RequestImpl.java
===================================================================
RCS file: /home/cvs/jakarta-commons/latka/src/java/org/apache/commons/latka/http/RequestImpl.java,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- RequestImpl.java 4 Sep 2002 01:00:37 -0000 1.28
+++ RequestImpl.java 4 Sep 2002 02:59:26 -0000 1.29
@@ -171,24 +171,7 @@
_session = session;
_targetURL = url;
-
- switch (httpMethod) {
- case HTTP_METHOD_GET:
- _httpMethod = new GetMethod(url.getPath());
- ((GetMethod) _httpMethod).setUseDisk(false);
- break;
- case HTTP_METHOD_POST:
- _httpMethod = new PostMethod(url.getPath());
- ((PostMethod) _httpMethod).setUseDisk(false);
- break;
- case HTTP_METHOD_HEAD:
- _httpMethod = new HeadMethod(url.getPath());
- break;
- default:
- throw new IllegalArgumentException("Unsupported HTTP Method");
- }
-
-
+ _httpMethod = MethodFactory.getInstance(httpMethod, url);
if (_query != null) {
_httpMethod.setQueryString(_query);
}
1.17 +3 -4 jakarta-commons/latka/src/java/org/apache/commons/latka/http/Request.java
Index: Request.java
===================================================================
RCS file: /home/cvs/jakarta-commons/latka/src/java/org/apache/commons/latka/http/Request.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- Request.java 16 Jul 2002 22:57:29 -0000 1.16
+++ Request.java 4 Sep 2002 02:59:26 -0000 1.17
@@ -1,8 +1,7 @@
/*
- *
- *
- *
- *
+ * $Header $
+ * $Revision $
+ * $Date $
* ====================================================================
*
* The Apache Software License, Version 1.1
1.1 jakarta-commons/latka/src/java/org/apache/commons/latka/http/MethodFactory.java
Index: MethodFactory.java
===================================================================
/*
* $Header $
* $Revision $
* $Date $
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-2002 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", "Commons", 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 apache@apache.org.
*
* 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/>.
*
*/
package org.apache.commons.latka.http;
import java.net.URL;
import org.apache.commons.httpclient.HttpMethod;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.HeadMethod;
/**
* This factory provides a single point to obtain
* implementations of HttpMethod base.
*
* @version $Revision $
*/
public final class MethodFactory {
/**
* Private default constructor
*/
private MethodFactory() {
}
/**
* Creates and returns an object implementing the
* HttpMethod interface.
*
* @param method - method type to create
* @return HttpMethod instance
*/
public static HttpMethod getInstance(int method, URL url) {
HttpMethod httpMethod = null;
switch (method) {
case Request.HTTP_METHOD_GET:
httpMethod = new GetMethod(url.getPath());
((GetMethod) httpMethod).setUseDisk(false);
break;
case Request.HTTP_METHOD_POST:
httpMethod = new PostMethod(url.getPath());
((PostMethod) httpMethod).setUseDisk(false);
break;
case Request.HTTP_METHOD_HEAD:
httpMethod = new HeadMethod(url.getPath());
break;
default:
throw new IllegalArgumentException("Unsupported HTTP Method");
}
return httpMethod;
}
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>