001: /*
002: * $Id: XINSCallConfig.java,v 1.22 2007/03/15 17:08:27 agoubard Exp $
003: *
004: * Copyright 2003-2007 Orange Nederland Breedband B.V.
005: * See the COPYRIGHT file for redistribution and use restrictions.
006: */
007: package org.xins.client;
008:
009: import org.xins.common.MandatoryArgumentChecker;
010: import org.xins.common.http.HTTPCallConfig;
011: import org.xins.common.http.HTTPMethod;
012: import org.xins.common.service.CallConfig;
013: import org.xins.common.text.TextUtils;
014:
015: /**
016: * Call configuration for the XINS service caller. The HTTP method can be configured.
017: * By default it is set to <em>POST</em>.
018: *
019: * <p>This class is not thread safe</p>
020: *
021: * @version $Revision: 1.22 $ $Date: 2007/03/15 17:08:27 $
022: * @author <a href="mailto:ernst@ernstdehaan.com">Ernst de Haan</a>
023: *
024: * @since XINS 1.1.0
025: */
026: public final class XINSCallConfig extends CallConfig {
027:
028: /**
029: * The underlying HTTP call config. Cannot be <code>null</code>.
030: */
031: private HTTPCallConfig _httpCallConfig;
032:
033: /**
034: * Constructs a new <code>XINSCallConfig</code> object.
035: */
036: public XINSCallConfig() {
037:
038: // Construct an underlying HTTPCallConfig
039: _httpCallConfig = new HTTPCallConfig();
040:
041: // Configure the User-Agent header
042: String userAgent = "XINS/Java Client Framework "
043: + Library.getVersion();
044: _httpCallConfig.setUserAgent(userAgent);
045:
046: // NOTE: HTTPCallConfig already defaults to HTTP POST
047: }
048:
049: /**
050: * Returns an <code>HTTPCallConfig</code> object that corresponds with this
051: * XINS call configuration object.
052: *
053: * @return
054: * an {@link HTTPCallConfig} object, never <code>null</code>.
055: */
056: HTTPCallConfig getHTTPCallConfig() {
057: return _httpCallConfig;
058: }
059:
060: /**
061: * Returns the HTTP method associated with this configuration.
062: *
063: * @return
064: * the HTTP method, never <code>null</code>.
065: */
066: public HTTPMethod getHTTPMethod() {
067: return _httpCallConfig.getMethod();
068: }
069:
070: /**
071: * Sets the HTTP method associated with this configuration.
072: *
073: * @param method
074: * the HTTP method to be associated with this configuration, cannot be
075: * <code>null</code>.
076: *
077: * @throws IllegalArgumentException
078: * if <code>method == null</code>.
079: */
080: public void setHTTPMethod(HTTPMethod method)
081: throws IllegalArgumentException {
082:
083: // Check preconditions
084: MandatoryArgumentChecker.check("method", method);
085:
086: // Store the setting in the HTTP call configuration
087: _httpCallConfig.setMethod(method);
088: }
089:
090: /**
091: * Describes this configuration.
092: *
093: * @return
094: * the description of this configuration, should never be
095: * <code>null</code>, should never be empty and should never start or
096: * end with whitespace characters.
097: */
098: public String describe() {
099:
100: String description = "XINS call config [failOverAllowed="
101: + isFailOverAllowed()
102: + "; method="
103: + TextUtils.quote(_httpCallConfig.getMethod()
104: .toString()) + ']';
105:
106: return description;
107: }
108: }
|