You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2007/12/12 15:03:22 UTC
svn commit: r603615 - in
/jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http:
conn/params/ impl/client/
Author: olegk
Date: Wed Dec 12 06:03:21 2007
New Revision: 603615
URL: http://svn.apache.org/viewvc?rev=603615&view=rev
Log:
Generics in o.a.h.impl.client
Added:
jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/RedirectLocations.java (with props)
Modified:
jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/params/HttpConnectionManagerParams.java
jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/AbstractHttpClient.java
jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/BasicCookieStore.java
jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/BasicCredentialsProvider.java
jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/DefaultClientRequestDirector.java
jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/DefaultHttpClient.java
jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/DefaultProxyAuthenticationHandler.java
jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/DefaultRedirectHandler.java
jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/DefaultTargetAuthenticationHandler.java
Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/params/HttpConnectionManagerParams.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/params/HttpConnectionManagerParams.java?rev=603615&r1=603614&r2=603615&view=diff
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/params/HttpConnectionManagerParams.java (original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/params/HttpConnectionManagerParams.java Wed Dec 12 06:03:21 2007
@@ -114,7 +114,7 @@
("The maximum must be greater than 0.");
}
- Map<?,?> currentValues = (Map) params.getParameter
+ Map<?,?> currentValues = (Map<?,?>) params.getParameter
(ConnManagerPNames.MAX_HOST_CONNECTIONS);
// param values are meant to be immutable so we'll make a copy
// to modify
@@ -183,7 +183,7 @@
// if neither a specific nor a default maximum is configured...
int result = DEFAULT_MAX_HOST_CONNECTIONS;
- Map<?,?> m = (Map) params.getParameter
+ Map<?,?> m = (Map<?,?>) params.getParameter
(ConnManagerPNames.MAX_HOST_CONNECTIONS);
if (m != null) {
Integer max = (Integer) m.get(key);
Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/AbstractHttpClient.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/AbstractHttpClient.java?rev=603615&r1=603614&r2=603615&view=diff
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/AbstractHttpClient.java (original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/AbstractHttpClient.java Wed Dec 12 06:03:21 2007
@@ -33,7 +33,6 @@
import java.io.IOException;
import java.net.URI;
-import java.util.List;
import org.apache.http.ConnectionReuseStrategy;
import org.apache.http.HttpException;
@@ -59,10 +58,6 @@
import org.apache.http.protocol.BasicHttpProcessor;
import org.apache.http.protocol.HttpContext;
import org.apache.http.protocol.BasicHttpContext;
-import org.apache.http.protocol.HttpRequestInterceptorList;
-import org.apache.http.protocol.HttpResponseInterceptorList;
-
-
/**
* Convenience base class for HTTP client implementations.
@@ -75,9 +70,7 @@
*
* @since 4.0
*/
-public abstract class AbstractHttpClient
- implements HttpClient, HttpRequestInterceptorList, HttpResponseInterceptorList {
-
+public abstract class AbstractHttpClient implements HttpClient {
/** The default context. */
private HttpContext defaultContext;
@@ -387,7 +380,7 @@
}
- public void removeResponseInterceptorByClass(Class clazz) {
+ public void removeResponseInterceptorByClass(Class<HttpResponseInterceptor> clazz) {
getHttpProcessor().removeResponseInterceptorByClass(clazz);
}
@@ -417,15 +410,9 @@
}
- public void removeRequestInterceptorByClass(Class clazz) {
+ public void removeRequestInterceptorByClass(Class<HttpRequestInterceptor> clazz) {
getHttpProcessor().removeRequestInterceptorByClass(clazz);
}
-
-
- public synchronized void setInterceptors(final List itcps) {
- getHttpProcessor().setInterceptors(itcps);
- }
-
// non-javadoc, see interface HttpClient
Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/BasicCookieStore.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/BasicCookieStore.java?rev=603615&r1=603614&r2=603615&view=diff
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/BasicCookieStore.java (original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/BasicCookieStore.java Wed Dec 12 06:03:21 2007
@@ -55,9 +55,9 @@
*/
public class BasicCookieStore implements CookieStore {
- private final ArrayList cookies;
+ private final ArrayList<Cookie> cookies;
- private final Comparator cookieComparator;
+ private final Comparator<Cookie> cookieComparator;
// -------------------------------------------------------- Class Variables
@@ -66,7 +66,7 @@
*/
public BasicCookieStore() {
super();
- this.cookies = new ArrayList();
+ this.cookies = new ArrayList<Cookie>();
this.cookieComparator = new CookieIdentityComparator();
}
@@ -83,9 +83,8 @@
public synchronized void addCookie(Cookie cookie) {
if (cookie != null) {
// first remove any old cookie that is equivalent
- for (Iterator it = cookies.iterator(); it.hasNext();) {
- Cookie tmp = (Cookie) it.next();
- if (cookieComparator.compare(cookie, tmp) == 0) {
+ for (Iterator<Cookie> it = cookies.iterator(); it.hasNext();) {
+ if (cookieComparator.compare(cookie, it.next()) == 0) {
it.remove();
break;
}
@@ -137,9 +136,8 @@
return false;
}
boolean removed = false;
- Iterator it = cookies.iterator();
- while (it.hasNext()) {
- if (((Cookie) (it.next())).isExpired(date)) {
+ for (Iterator<Cookie> it = cookies.iterator(); it.hasNext();) {
+ if (it.next().isExpired(date)) {
it.remove();
removed = true;
}
Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/BasicCredentialsProvider.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/BasicCredentialsProvider.java?rev=603615&r1=603614&r2=603615&view=diff
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/BasicCredentialsProvider.java (original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/BasicCredentialsProvider.java Wed Dec 12 06:03:21 2007
@@ -31,7 +31,6 @@
package org.apache.http.impl.client;
import java.util.HashMap;
-import java.util.Iterator;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.Credentials;
@@ -53,14 +52,14 @@
*/
public class BasicCredentialsProvider implements CredentialsProvider {
- private final HashMap credMap;
+ private final HashMap<AuthScope, Credentials> credMap;
/**
* Default constructor.
*/
public BasicCredentialsProvider() {
super();
- this.credMap = new HashMap();
+ this.credMap = new HashMap<AuthScope, Credentials>();
}
/**
@@ -73,7 +72,9 @@
*
* @see #getCredentials(AuthScope)
*/
- public synchronized void setCredentials(final AuthScope authscope, final Credentials credentials) {
+ public synchronized void setCredentials(
+ final AuthScope authscope,
+ final Credentials credentials) {
if (authscope == null) {
throw new IllegalArgumentException("Authentication scope may not be null");
}
@@ -88,7 +89,9 @@
* @return the credentials
*
*/
- private static Credentials matchCredentials(final HashMap map, final AuthScope authscope) {
+ private static Credentials matchCredentials(
+ final HashMap<AuthScope, Credentials> map,
+ final AuthScope authscope) {
// see if we get a direct hit
Credentials creds = (Credentials)map.get(authscope);
if (creds == null) {
@@ -96,9 +99,7 @@
// Do a full scan
int bestMatchFactor = -1;
AuthScope bestMatch = null;
- Iterator items = map.keySet().iterator();
- while (items.hasNext()) {
- AuthScope current = (AuthScope)items.next();
+ for (AuthScope current: map.keySet()) {
int factor = authscope.match(current);
if (factor > bestMatchFactor) {
bestMatchFactor = factor;
Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/DefaultClientRequestDirector.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/DefaultClientRequestDirector.java?rev=603615&r1=603614&r2=603615&view=diff
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/DefaultClientRequestDirector.java (original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/DefaultClientRequestDirector.java Wed Dec 12 06:03:21 2007
@@ -602,7 +602,8 @@
if (this.proxyAuthHandler.isAuthenticationRequested(response, context)) {
LOG.debug("Proxy requested authentication");
- Map challenges = this.proxyAuthHandler.getChallenges(response, context);
+ Map<String, Header> challenges = this.proxyAuthHandler.getChallenges(
+ response, context);
try {
processChallenges(
challenges, this.proxyAuthState, this.proxyAuthHandler,
@@ -819,7 +820,8 @@
}
LOG.debug("Target requested authentication");
- Map challenges = this.targetAuthHandler.getChallenges(response, context);
+ Map<String, Header> challenges = this.targetAuthHandler.getChallenges(
+ response, context);
try {
processChallenges(challenges,
this.targetAuthState, this.targetAuthHandler,
@@ -846,7 +848,8 @@
if (this.proxyAuthHandler.isAuthenticationRequested(response, context)) {
LOG.debug("Proxy requested authentication");
- Map challenges = this.proxyAuthHandler.getChallenges(response, context);
+ Map<String, Header> challenges = this.proxyAuthHandler.getChallenges(
+ response, context);
try {
processChallenges(challenges,
this.proxyAuthState, this.proxyAuthHandler,
@@ -902,7 +905,7 @@
private void processChallenges(
- final Map challenges,
+ final Map<String, Header> challenges,
final AuthState authState,
final AuthenticationHandler authHandler,
final HttpResponse response,
Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/DefaultHttpClient.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/DefaultHttpClient.java?rev=603615&r1=603614&r2=603615&view=diff
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/DefaultHttpClient.java (original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/DefaultHttpClient.java Wed Dec 12 06:03:21 2007
@@ -161,7 +161,7 @@
if (className != null) {
try {
- Class clazz = Class.forName(className);
+ Class<?> clazz = Class.forName(className);
ClientConnectionManagerFactory factory =
(ClientConnectionManagerFactory) clazz.newInstance();
connManager = factory.newInstance(params, registry);
Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/DefaultProxyAuthenticationHandler.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/DefaultProxyAuthenticationHandler.java?rev=603615&r1=603614&r2=603615&view=diff
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/DefaultProxyAuthenticationHandler.java (original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/DefaultProxyAuthenticationHandler.java Wed Dec 12 06:03:21 2007
@@ -59,7 +59,7 @@
return status == HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED;
}
- public Map getChallenges(
+ public Map<String, Header> getChallenges(
final HttpResponse response,
final HttpContext context) throws MalformedChallengeException {
if (response == null) {
Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/DefaultRedirectHandler.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/DefaultRedirectHandler.java?rev=603615&r1=603614&r2=603615&view=diff
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/DefaultRedirectHandler.java (original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/DefaultRedirectHandler.java Wed Dec 12 06:03:21 2007
@@ -33,8 +33,6 @@
import java.net.URI;
import java.net.URISyntaxException;
-import java.util.HashSet;
-import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -154,10 +152,11 @@
if (params.isParameterFalse(ClientPNames.ALLOW_CIRCULAR_REDIRECTS)) {
- Set redirectLocations = (Set) context.getAttribute(REDIRECT_LOCATIONS);
+ RedirectLocations redirectLocations = (RedirectLocations) context.getAttribute(
+ REDIRECT_LOCATIONS);
if (redirectLocations == null) {
- redirectLocations = new HashSet();
+ redirectLocations = new RedirectLocations();
context.setAttribute(REDIRECT_LOCATIONS, redirectLocations);
}
Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/DefaultTargetAuthenticationHandler.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/DefaultTargetAuthenticationHandler.java?rev=603615&r1=603614&r2=603615&view=diff
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/DefaultTargetAuthenticationHandler.java (original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/DefaultTargetAuthenticationHandler.java Wed Dec 12 06:03:21 2007
@@ -59,7 +59,7 @@
return status == HttpStatus.SC_UNAUTHORIZED;
}
- public Map getChallenges(
+ public Map<String, Header> getChallenges(
final HttpResponse response,
final HttpContext context) throws MalformedChallengeException {
if (response == null) {
Added: jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/RedirectLocations.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/RedirectLocations.java?rev=603615&view=auto
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/RedirectLocations.java (added)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/RedirectLocations.java Wed Dec 12 06:03:21 2007
@@ -0,0 +1,59 @@
+/*
+ * $HeadURL$
+ * $Revision$
+ * $Date$
+ *
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * 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.http.impl.client;
+
+import java.net.URI;
+import java.util.HashSet;
+import java.util.Set;
+
+public class RedirectLocations {
+
+ private final Set<URI> uris;
+
+ public RedirectLocations() {
+ super();
+ this.uris = new HashSet<URI>();
+ }
+
+ public boolean contains(final URI uri) {
+ return this.uris.contains(uri);
+ }
+
+ public void add(final URI uri) {
+ this.uris.add(uri);
+ }
+
+ public boolean remove(final URI uri) {
+ return this.uris.remove(uri);
+ }
+
+}
Propchange: jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/RedirectLocations.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/RedirectLocations.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/client/RedirectLocations.java
------------------------------------------------------------------------------
svn:mime-type = text/plain