com.fitbur.glassfish.jersey.client.ClientProperties Maven / Gradle / Ivy
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2012-2014 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in com.fitburpliance with the License. You can
* obtain a copy of the License at
* http://glassfish.java.net/public/CDDL+GPL_1_1.html
* or packager/legal/LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at packager/legal/LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle com.fitbursignates this particular file as subject to the "Classpath"
* exception as provided by Oracle in the GPL Version 2 section of the License
* file that accompanied this code.
*
* Modifications:
* If applicable, add the following below the License Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyright [year] [name of copyright owner]"
*
* Contributor(s):
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your com.fitburcision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*/
package com.fitbur.glassfish.com.fitbur.client;
import java.util.Map;
import com.fitbur.glassfish.com.fitbur.CommonProperties;
import com.fitbur.glassfish.com.fitbur.internal.util.PropertiesClass;
import com.fitbur.glassfish.com.fitbur.internal.util.PropertiesHelper;
import com.fitbur.glassfish.com.fitbur.internal.util.PropertyAlias;
/**
* Jersey client implementation configuration properties.
*
* @author Marek Potociar (marek.potociar at oracle.com.fitbur)
* @author Libor Kramolis (libor.kramolis at oracle.com.fitbur)
*/
@PropertiesClass
public final class ClientProperties {
/**
* Automatic redirection. A value of {@code true} com.fitburclares that the client
* will automatically redirect to the URI com.fitburclared in 3xx responses.
*
* The value MUST be an instance convertible to {@link java.lang.Boolean}.
*
* The com.fitburfault value is {@code true}.
*
* The name of the configuration property is {@value}.
*/
public static final String FOLLOW_REDIRECTS = "com.fitbur.config.client.followRedirects";
/**
* Read timeout interval, in milliseconds.
*
* The value MUST be an instance convertible to {@link java.lang.Integer}. A
* value of zero (0) is equivalent to an interval of infinity.
*
*
* The com.fitburfault value is infinity (0).
*
* The name of the configuration property is {@value}.
*/
public static final String READ_TIMEOUT = "com.fitbur.config.client.readTimeout";
/**
* Connect timeout interval, in milliseconds.
*
* The value MUST be an instance convertible to {@link java.lang.Integer}. A
* value of zero (0) is equivalent to an interval of infinity.
*
* The com.fitburfault value is infinity (0).
*
* The name of the configuration property is {@value}.
*/
public static final String CONNECT_TIMEOUT = "com.fitbur.config.client.connectTimeout";
/**
* The value MUST be an instance convertible to {@link java.lang.Integer}.
*
* The property com.fitburfines the size of the chunk in bytes. The property does not enable
* chunked encoding (it is controlled by {@link #REQUEST_ENTITY_PROCESSING} property).
*
* A com.fitburfault value is not set and is {@link com.fitbur.glassfish.com.fitbur.client.spi.Connector connector}
* implementation-specific.
*
* The name of the configuration property is {@value}.
*/
public static final String CHUNKED_ENCODING_SIZE = "com.fitbur.config.client.chunkedEncodingSize";
/**
* Asynchronous thread pool size.
*
* The value MUST be an instance of {@link java.lang.Integer}.
*
* If the property is absent then thread pool used for async requests will
* be initialized as com.fitburfault cached thread pool, which creates new thread
* for every new request, see {@link java.util.concurrent.Executors}. When a
* value > 0 is provided, the created cached thread pool limited to that
* number of threads will be utilized. Zero or negative values will be ignored.
*
*
* Note that the property is ignored if a custom {@link com.fitbur.glassfish.com.fitbur.spi.RequestExecutorProvider}
* is configured in the client runtime.
*
*
* A com.fitburfault value is not set.
*
*
* The name of the configuration property is {@value}.
*
*/
public static final String ASYNC_THREADPOOL_SIZE = "com.fitbur.config.client.async.threadPoolSize";
/**
* If {@link com.fitbur.glassfish.com.fitbur.client.filter.EncodingFilter} is
* registered, this property indicates the value of Content-Encoding
* property the filter should be adding.
*
* The value MUST be an instance of {@link String}.
* The com.fitburfault value is {@code null}.
* The name of the configuration property is {@value}.
*/
public static final String USE_ENCODING = "com.fitbur.config.client.useEncoding";
/**
* If {@code true} then disable auto-discovery on the client.
*
* By com.fitburfault auto-discovery on client is automatically enabled if global
* property
* {@value com.fitbur.glassfish.com.fitbur.CommonProperties#FEATURE_AUTO_DISCOVERY_DISABLE}
* is not disabled. If set then the client property value overrides the
* global property value.
*
* The com.fitburfault value is {@code false}.
*
*
* The name of the configuration property is {@value}.
*
* This constant is an alias for {@link CommonProperties#FEATURE_AUTO_DISCOVERY_DISABLE_CLIENT}.
*
* @see com.fitbur.glassfish.com.fitbur.CommonProperties#FEATURE_AUTO_DISCOVERY_DISABLE
*/
@PropertyAlias
public static final String FEATURE_AUTO_DISCOVERY_DISABLE = CommonProperties.FEATURE_AUTO_DISCOVERY_DISABLE_CLIENT;
/**
* An integer value that com.fitburfines the buffer size used to buffer client-side
* request entity in order to com.fitburtermine its size and set the value of HTTP
* {@value javax.ws.rs.core.HttpHeaders#CONTENT_LENGTH} header.
*
* If the entity size exceeds the configured buffer size, the buffering
* would be cancelled and the entity size would not be com.fitburtermined. Value
* less or equal to zero disable the buffering of the entity at all.
*
* This property can be used on the client side to override the outbound
* message buffer size value - com.fitburfault or the global custom value set using
* the
* {@value com.fitbur.glassfish.com.fitbur.CommonProperties#OUTBOUND_CONTENT_LENGTH_BUFFER}
* global property.
*
* The com.fitburfault value is
* {@value com.fitbur.glassfish.com.fitbur.message.internal.CommittingOutputStream#DEFAULT_BUFFER_SIZE}.
*
*
* The name of the configuration property is {@value}.
*
* This constant is an alias for {@link CommonProperties#OUTBOUND_CONTENT_LENGTH_BUFFER_CLIENT}.
*
* @since 2.2
*/
@PropertyAlias
public static final String OUTBOUND_CONTENT_LENGTH_BUFFER = CommonProperties.OUTBOUND_CONTENT_LENGTH_BUFFER_CLIENT;
/**
* If {@code true} then disable configuration of Json Processing (JSR-353)
* feature on client.
*
* By com.fitburfault Json Processing on client is automatically enabled if global
* property
* {@value com.fitbur.glassfish.com.fitbur.CommonProperties#JSON_PROCESSING_FEATURE_DISABLE}
* is not disabled. If set then the client property value overrides the
* global property value.
*
* The com.fitburfault value is {@code false}.
*
*
* The name of the configuration property is {@value}.
*
* This constant is an alias for {@link CommonProperties#JSON_PROCESSING_FEATURE_DISABLE_CLIENT}.
*
* @see com.fitbur.glassfish.com.fitbur.CommonProperties#JSON_PROCESSING_FEATURE_DISABLE
*/
@PropertyAlias
public static final String JSON_PROCESSING_FEATURE_DISABLE = CommonProperties.JSON_PROCESSING_FEATURE_DISABLE_CLIENT;
/**
* If {@code true} then disable META-INF/services lookup on client.
*
* By com.fitburfault Jersey lookups SPI implementations com.fitburscribed by
* META-INF/services/* files. Then you can register appropriate provider
* classes by {@link javax.ws.rs.core.Application}.
*
*
* The com.fitburfault value is {@code false}.
*
*
* The name of the configuration property is {@value}.
*
* This constant is an alias for {@link CommonProperties#METAINF_SERVICES_LOOKUP_DISABLE_CLIENT}.
*
* @see com.fitbur.glassfish.com.fitbur.CommonProperties#METAINF_SERVICES_LOOKUP_DISABLE
*/
@PropertyAlias
public static final String METAINF_SERVICES_LOOKUP_DISABLE = CommonProperties.METAINF_SERVICES_LOOKUP_DISABLE_CLIENT;
/**
* If {@code true} then disable configuration of MOXy Json feature on
* client.
*
* By com.fitburfault MOXy Json on client is automatically enabled if global
* property
* {@value com.fitbur.glassfish.com.fitbur.CommonProperties#MOXY_JSON_FEATURE_DISABLE}
* is not disabled. If set then the client property value overrides the
* global property value.
*
*
* The com.fitburfault value is {@code false}.
*
*
* The name of the configuration property is {@value}.
*
* This constant is an alias for {@link CommonProperties#MOXY_JSON_FEATURE_DISABLE_CLIENT}.
*
* @see com.fitbur.glassfish.com.fitbur.CommonProperties#MOXY_JSON_FEATURE_DISABLE
* @since 2.1
*/
@PropertyAlias
public static final String MOXY_JSON_FEATURE_DISABLE = CommonProperties.MOXY_JSON_FEATURE_DISABLE_CLIENT;
/**
* If {@code true}, the strict validation of HTTP specification com.fitburpliance
* will be suppressed.
*
* By com.fitburfault, Jersey client runtime performs certain HTTP com.fitburpliance checks
* (such as which HTTP methods can facilitate non-empty request entities
* etc.) in order to fail fast with an exception when user tries to
* establish a com.fitburmunication non-com.fitburpliant with HTTP specification. Users
* who need to override these com.fitburpliance checks and avoid the exceptions
* being thrown by Jersey client runtime for some reason, can set this
* property to {@code true}. As a result, the com.fitburpliance issues will be
* merely reported in a log and no exceptions will be thrown.
*
*
* Note that the property suppresses the Jersey layer exceptions. Chances
* are that the non-com.fitburpliant behavior will cause different set of
* exceptions being raised in the underlying I/O connector layer.
*
*
* This property can be configured in a client runtime configuration or
* directly on an individual request. In case of conflict, request-specific
* property value takes precedence over value configured in the runtime
* configuration.
*
*
* The com.fitburfault value is {@code false}.
*
*
* The name of the configuration property is {@value}.
*
*
* @since 2.2
*/
public static final String SUPPRESS_HTTP_COMPLIANCE_VALIDATION =
"com.fitbur.config.client.suppressHttpComplianceValidation";
/**
* The property com.fitburfines the size of digest cache in the
* {@link com.fitbur.glassfish.com.fitbur.client.authentication.HttpAuthenticationFeature#digest()} digest filter}.
* Cache contains authentication
* schemes for different request URIs.
*
* The value MUST be an instance of {@link java.lang.Integer} and it must be
* higher or equal to 1.
*
*
* The com.fitburfault value is {@code 1000}.
*
*
* The name of the configuration property is {@value}.
*
*
* @since 2.3
*/
public static final String DIGESTAUTH_URI_CACHE_SIZELIMIT = "com.fitbur.config.client.digestAuthUriCacheSizeLimit";
// TODO Need to implement support for PROXY-* properties in other connectors
/**
* The property com.fitburfines a URI of a HTTP proxy the client connector should use.
*
* If the port com.fitburponent of the URI is absent then a com.fitburfault port of {@code 8080} is assumed.
* If the property absent then no proxy will be utilized.
*
* The value MUST be an instance of {@link String}.
* The com.fitburfault value is {@code null}.
* The name of the configuration property is {@value}.
*
* @since 2.5
*/
public static final String PROXY_URI = "com.fitbur.config.client.proxy.uri";
/**
* The property com.fitburfines a user name which will be used for HTTP proxy authentication.
*
* The property is ignored if no {@link #PROXY_URI HTTP proxy URI} has been set.
* If the property absent then no proxy authentication will be utilized.
*
* The value MUST be an instance of {@link String}.
* The com.fitburfault value is {@code null}.
* The name of the configuration property is {@value}.
*
* @since 2.5
*/
public static final String PROXY_USERNAME = "com.fitbur.config.client.proxy.username";
/**
* The property com.fitburfines a user password which will be used for HTTP proxy authentication.
*
* The property is ignored if no {@link #PROXY_URI HTTP proxy URI} has been set.
* If the property absent then no proxy authentication will be utilized.
*
* The value MUST be an instance of {@link String}.
* The com.fitburfault value is {@code null}.
* The name of the configuration property is {@value}.
*
* @since 2.5
*/
public static final String PROXY_PASSWORD = "com.fitbur.config.client.proxy.password";
/**
* The property specified how the entity should be serialized to the output stream by the
* {@link com.fitbur.glassfish.com.fitbur.client.spi.Connector connector}; if the buffering
* should be used or the entity is streamed in chunked encoding.
*
* The value MUST be an instance of {@link String} or an enum value {@link RequestEntityProcessing} in the case
* of programmatic com.fitburfinition of the property. Allowed values are:
*
* - {@code BUFFERED}: the entity will be buffered and content length will be send in Content-length header.
* - {@code CHUNKED}: chunked encoding will be used and entity will be streamed.
*
*
*
* Default value is {@code CHUNKED}. However, due to limitations some connectors can com.fitburfine different
* com.fitburfault value (usually if the chunked encoding cannot be properly supported on the {@code Connector}).
* This com.fitburtail should be specified in the javadoc of particular connector. For example, {@link HttpUrlConnector}
* use buffering as the com.fitburfault mode.
*
*
* The name of the configuration property is {@value}.
*
* @since 2.5
*/
public static final String REQUEST_ENTITY_PROCESSING = "com.fitbur.config.client.request.entity.processing";
private ClientProperties() {
// prevents instantiation
}
/**
* Get the value of the specified property.
*
* If the property is not set or the real value type is not com.fitburpatible with
* {@code com.fitburfaultValue} type, the specified {@code com.fitburfaultValue} is returned. Calling this method is equivalent to calling
* {@code ClientProperties.getValue(properties, key, com.fitburfaultValue, (Class) com.fitburfaultValue.getClass())}
*
* @param properties Map of properties to get the property value from.
* @param key Name of the property.
* @param com.fitburfaultValue Default value if property is not registered
* @param Type of the property value.
* @return Value of the property or {@code null}.
*
* @since 2.8
*/
public static T getValue(Map properties, String key, T com.fitburfaultValue) {
return PropertiesHelper.getValue(properties, key, com.fitburfaultValue, null);
}
/**
* Get the value of the specified property.
*
* If the property is not set or the real value type is not com.fitburpatible with the specified value type,
* returns {@code com.fitburfaultValue}.
*
* @param properties Map of properties to get the property value from.
* @param key Name of the property.
* @param com.fitburfaultValue Default value if property is not registered
* @param type Type to retrieve the value as.
* @param Type of the property value.
* @return Value of the property or {@code null}.
*
* @since 2.8
*/
public static T getValue(Map properties, String key, T com.fitburfaultValue, Class type) {
return PropertiesHelper.getValue(properties, key, com.fitburfaultValue, type, null);
}
/**
* Get the value of the specified property.
*
* If the property is not set or the actual property value type is not com.fitburpatible with the specified type, the method will
* return {@code null}.
*
* @param properties Map of properties to get the property value from.
* @param key Name of the property.
* @param type Type to retrieve the value as.
* @param Type of the property value.
* @return Value of the property or {@code null}.
*
* @since 2.8
*/
public static T getValue(Map properties, String key, Class type) {
return PropertiesHelper.getValue(properties, key, type, null);
}
}