Deprecated AuthSchemeRegistry and CookieSpecRegistry in favor of generic Registry

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1414676 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Oleg Kalnichevski 2012-11-28 13:37:32 +00:00
parent 2c1d3f797a
commit 8901aed494
6 changed files with 138 additions and 3 deletions

View File

@ -33,7 +33,10 @@ import org.apache.http.params.HttpParams;
* Factory for {@link AuthScheme} implementations.
*
* @since 4.0
*
* @deprecated (4.3) use {@link AuthSchemeProvider}
*/
@Deprecated
public interface AuthSchemeFactory {
/**

View File

@ -0,0 +1,46 @@
/*
* ====================================================================
* 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.auth;
import org.apache.http.protocol.HttpContext;
/**
* Factory for {@link AuthScheme} implementations.
*
* @since 4.3
*/
public interface AuthSchemeProvider {
/**
* Creates an instance of {@link AuthScheme}.
*
* @return auth scheme.
*/
AuthScheme create(HttpContext context);
}

View File

@ -32,18 +32,26 @@ import java.util.Locale;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.http.HttpRequest;
import org.apache.http.annotation.ThreadSafe;
import org.apache.http.config.Lookup;
import org.apache.http.config.Registry;
import org.apache.http.params.HttpParams;
import org.apache.http.protocol.ExecutionContext;
import org.apache.http.protocol.HttpContext;
/**
* Authentication scheme registry that can be used to obtain the corresponding
* authentication scheme implementation for a given type of authorization challenge.
*
* @since 4.0
*
* @deprecated (4.3) use {@link Registry}
*/
@ThreadSafe
public final class AuthSchemeRegistry {
@Deprecated
public final class AuthSchemeRegistry implements Lookup<AuthSchemeProvider> {
private final ConcurrentHashMap<String,AuthSchemeFactory> registeredSchemes;
@ -141,4 +149,16 @@ public final class AuthSchemeRegistry {
registeredSchemes.putAll(map);
}
public AuthSchemeProvider lookup(final String name) {
return new AuthSchemeProvider() {
public AuthScheme create(HttpContext context) {
HttpRequest request = (HttpRequest) context.getAttribute(
ExecutionContext.HTTP_REQUEST);
return getAuthScheme(name, request.getParams());
}
};
}
}

View File

@ -33,7 +33,10 @@ import org.apache.http.params.HttpParams;
* Factory for {@link CookieSpec} implementations.
*
* @since 4.0
*
* @deprecated (4.3) use {@link CookieSpecProvider}
*/
@Deprecated
public interface CookieSpecFactory {
/**

View File

@ -0,0 +1,46 @@
/*
* ====================================================================
* 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.cookie;
import org.apache.http.protocol.HttpContext;
/**
* Factory for {@link CookieSpec} implementations.
*
* @since 4.3
*/
public interface CookieSpecProvider {
/**
* Creates an instance of {@link CookieSpec}.
*
* @return auth scheme.
*/
CookieSpec create(HttpContext context);
}

View File

@ -33,19 +33,24 @@ import java.util.Locale;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.http.HttpRequest;
import org.apache.http.annotation.ThreadSafe;
import org.apache.http.config.Registry;
import org.apache.http.params.HttpParams;
import org.apache.http.protocol.ExecutionContext;
import org.apache.http.protocol.HttpContext;
/**
* Cookie specification registry that can be used to obtain the corresponding
* cookie specification implementation for a given type of type or version of
* cookie.
*
*
* @since 4.0
*
* @deprecated (4.3) use {@link Registry}.
*/
@ThreadSafe
@Deprecated
public final class CookieSpecRegistry {
private final ConcurrentHashMap<String,CookieSpecFactory> registeredSpecs;
@ -154,4 +159,16 @@ public final class CookieSpecRegistry {
registeredSpecs.putAll(map);
}
public CookieSpecProvider lookup(final String name) {
return new CookieSpecProvider() {
public CookieSpec create(HttpContext context) {
HttpRequest request = (HttpRequest) context.getAttribute(
ExecutionContext.HTTP_REQUEST);
return getCookieSpec(name, request.getParams());
}
};
}
}