All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.xins.client.XINSCallConfig Maven / Gradle / Ivy

The newest version!
/*
 * $Id: XINSCallConfig.java,v 1.27 2010/09/29 17:21:48 agoubard Exp $
 *
 * See the COPYRIGHT file for redistribution and use restrictions.
 */
package org.xins.client;

import org.xins.common.MandatoryArgumentChecker;
import org.xins.common.http.HTTPCallConfig;
import org.xins.common.http.HTTPMethod;
import org.xins.common.service.CallConfig;
import org.xins.common.text.TextUtils;

/**
 * Call configuration for the XINS service caller. The HTTP method can be configured.
 * By default it is set to POST.
 *
 * 

This class is not thread safe

* * @version $Revision: 1.27 $ $Date: 2010/09/29 17:21:48 $ * @author Ernst de Haan * @author Anthony Goubard * * @since XINS 1.1.0 */ public final class XINSCallConfig extends CallConfig { /** * The underlying HTTP call config. Cannot be null. */ private HTTPCallConfig _httpCallConfig; /** * Constructs a new XINSCallConfig object. */ public XINSCallConfig() { // Construct an underlying HTTPCallConfig _httpCallConfig = new HTTPCallConfig(); // Configure the User-Agent header String userAgent = "XINS/Java Client Framework " + Library.getVersion(); _httpCallConfig.setUserAgent(userAgent); // NOTE: HTTPCallConfig already defaults to HTTP POST } /** * Returns an HTTPCallConfig object that corresponds with this * XINS call configuration object. * * @return * an {@link HTTPCallConfig} object, never null. */ HTTPCallConfig getHTTPCallConfig() { return _httpCallConfig; } /** * Returns the HTTP method associated with this configuration. * * @return * the HTTP method, never null. */ public HTTPMethod getHTTPMethod() { return _httpCallConfig.getMethod(); } /** * Sets the HTTP method associated with this configuration. * * @param method * the HTTP method to be associated with this configuration, cannot be * null. * * @throws IllegalArgumentException * if method == null. */ public void setHTTPMethod(HTTPMethod method) throws IllegalArgumentException { // Check preconditions MandatoryArgumentChecker.check("method", method); // Store the setting in the HTTP call configuration _httpCallConfig.setMethod(method); } /** * Returns the action performed when a redirect is returned from the server. * * @return * true if it should call the redirected link, * false if it should fail. * * @since XINS 2.2 */ public boolean getFollowRedirect() { return _httpCallConfig.getFollowRedirect(); } /** * Sets the action to perform if a redirect is returned from the server. * * @param follow * true if it should call the redirected link, * false if it should fail. * * @since XINS 2.2 */ public void setFollowRedirect(boolean follow) { // Store the setting in the HTTP call configuration _httpCallConfig.setFollowRedirect(follow); } /** * Describes this configuration. * * @return * the description of this configuration, should never be * null, should never be empty and should never start or * end with whitespace characters. */ public String describe() { String description = "XINS call config [failOverAllowed=" + isFailOverAllowed() + "; method=" + TextUtils.quote(_httpCallConfig.getMethod().toString()) + ']'; return description; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy