com.att.aft.dme2.request.HttpRequest Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dme2-api Show documentation
Show all versions of dme2-api Show documentation
Direct Messaging Engine dme2-api
The newest version!
package com.att.aft.dme2.request;
import java.net.URI;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.collections.MapUtils;
import com.att.aft.dme2.iterator.service.IteratorEndpointOrderHandler;
import com.att.aft.dme2.iterator.service.IteratorRouteOfferOrderHandler;
public class HttpRequest extends Request {
// public HttpRequest(HttpClient client, HttpConversation conversation,
// URI uri) {
public HttpRequest(URI uri) {
super(uri);
}
// DME2FaultHandlerIntf faultHandlers[];
protected long exchangeRoundTripTimeOut;
protected long connectTimeout;
protected long perEndpointTimeoutMs;
protected String httpMethod;
boolean presentExchangeRoundTripTimeOut = false;
private List endpointOrderHandlers = new ArrayList();
private List routeOfferOrderHandlers = new ArrayList();
public boolean isPresentExchangeRoundTripTimeOut() {
return presentExchangeRoundTripTimeOut;
}
public static final class RequestBuilder extends Request.RequestBuilder {
// public RequestBuilder(HttpClient client, HttpConversation conversation, URI uri) {
public RequestBuilder(URI uri) {
super(uri);
}
public RequestBuilder withExchangeRoundTripTimeOut(long exchangeRoundTripTimeOut) {
obj.exchangeRoundTripTimeOut = exchangeRoundTripTimeOut;
obj.presentExchangeRoundTripTimeOut = true;
return thisObj;
}
public RequestBuilder withPerEndpointTimeoutMs(long perEndpointTimeoutMs) {
obj.perEndpointTimeoutMs = perEndpointTimeoutMs;
return thisObj;
}
public RequestBuilder withHeaders(Map inHeaders) {
Map headers = null;
if (MapUtils.isNotEmpty(inHeaders)) {
if (obj.headers == null) {
headers = new HashMap(inHeaders);
obj.headers = headers;
} else {
obj.headers.putAll(inHeaders);
}
}
return thisObj;
}
public RequestBuilder withHeader(String name, String value) {
Map headers = null;
if (obj.headers == null) {
headers = new HashMap();
headers.put(name, value);
obj.headers = headers;
} else {
obj.headers.put(name, value);
}
return thisObj;
}
/*public RequestBuilder withResponseHandlers(AsyncResponseHandlerIntf responseHandler) {
obj.responseHandler = responseHandler;
return thisObj;
}*/
public RequestBuilder withHttpMethod(String method) {
obj.httpMethod = method;
return thisObj;
}
@Override
protected HttpRequest createObj(URI uri) {
return new HttpRequest(uri);
}
@Override
protected RequestBuilder getThis() {
return this;
}
public RequestBuilder withIteratorRouteOfferOrderHandler(IteratorRouteOfferOrderHandler handler) {
if (obj.routeOfferOrderHandlers == null)
obj.routeOfferOrderHandlers = new ArrayList ();
obj.routeOfferOrderHandlers.add(handler);
return thisObj;
}
public RequestBuilder withIteratorEndpointOrderHandler(IteratorEndpointOrderHandler handler) {
if (obj.endpointOrderHandlers == null)
obj.endpointOrderHandlers = new ArrayList ();
obj.endpointOrderHandlers.add(handler);
return thisObj;
}
public RequestBuilder withIteratorRouteOfferOrderHandlers(List handlers) {
if (obj.routeOfferOrderHandlers == null)
obj.routeOfferOrderHandlers = new ArrayList ();
obj.routeOfferOrderHandlers.addAll(handlers);
return thisObj;
}
public RequestBuilder withIteratorEndpointOrderHandlers(List handlers) {
if (obj.endpointOrderHandlers == null)
obj.endpointOrderHandlers = new ArrayList ();
obj.endpointOrderHandlers.addAll(handlers);
return thisObj;
}
}
//protected HttpRequest() {
//}
public long getExchangeRoundTripTimeOut() {
return exchangeRoundTripTimeOut;
}
public Map getRequestHeaders() {
if (headers == null)
return new HashMap();
return headers;
}
public long getConnectTimeout() {
return connectTimeout;
}
public long getPerEndpointTimeoutMs() {
return perEndpointTimeoutMs;
}
public void setHeaders(Map headers) {
this.headers = headers;
}
public String getHttpMethod() {
return httpMethod;
}
public void setHttpMethod(String httpMethod) {
this.httpMethod = httpMethod;
}
public List getIteratorRouteOfferOrderHandlers() {
return routeOfferOrderHandlers;
}
public List getEndpointOrderHandlers() {
return endpointOrderHandlers;
}
public void setIteratorEndpointOrderHandler(
IteratorEndpointOrderHandler iteratorEndpointOrderHandler) {
endpointOrderHandlers.add(iteratorEndpointOrderHandler);
}
public void setIteratorRouteOfferOrderHandler(
IteratorRouteOfferOrderHandler iteratorRouteOfferOrderHandler) {
routeOfferOrderHandlers.add(iteratorRouteOfferOrderHandler);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy