Keeps lists of interceptors for processing requests and responses.
Method from org.apache.http.protocol.AbstractHttpProcessor Detail: |
public void addInterceptor(HttpRequestInterceptor interceptor) {
if (interceptor == null) {
return;
}
if (this.requestInterceptors == null) {
this.requestInterceptors = new ArrayList();
}
this.requestInterceptors.add(interceptor);
}
|
public void addInterceptor(HttpResponseInterceptor interceptor) {
if (interceptor == null) {
return;
}
if (this.responseInterceptors == null) {
this.responseInterceptors = new ArrayList();
}
this.responseInterceptors.add(interceptor);
}
|
public void clearInterceptors() {
this.requestInterceptors = null;
this.responseInterceptors = null;
}
|
protected void postprocessResponse(HttpResponse response,
HttpContext context) throws IOException, HttpException {
if (this.responseInterceptors != null) {
for (int i = 0; i < this.responseInterceptors.size(); i++) {
HttpResponseInterceptor interceptor = (HttpResponseInterceptor) this.responseInterceptors.get(i);
interceptor.process(response, context);
}
}
}
|
protected void preprocessRequest(HttpRequest request,
HttpContext context) throws IOException, HttpException {
if (this.requestInterceptors != null) {
for (int i = 0; i < this.requestInterceptors.size(); i++) {
HttpRequestInterceptor interceptor = (HttpRequestInterceptor) this.requestInterceptors.get(i);
interceptor.process(request, context);
}
}
}
|
public void removeInterceptor(HttpRequestInterceptor interceptor) {
if (interceptor == null) {
return;
}
if (this.requestInterceptors == null) {
return;
}
this.requestInterceptors.remove(interceptor);
if (this.requestInterceptors.isEmpty()) {
this.requestInterceptors = null;
}
}
|
public void removeInterceptor(HttpResponseInterceptor interceptor) {
if (interceptor == null) {
return;
}
if (this.responseInterceptors == null) {
return;
}
this.responseInterceptors.remove(interceptor);
if (this.responseInterceptors.isEmpty()) {
this.responseInterceptors = null;
}
}
|
public void removeInterceptors(Class clazz) {
if (clazz == null) {
return;
}
if (this.requestInterceptors != null) {
for (Iterator i = this.requestInterceptors.iterator(); i.hasNext(); ) {
if (clazz.isInstance(i.next())) {
i.remove();
}
}
}
if (this.responseInterceptors != null) {
for (Iterator i = this.responseInterceptors.iterator(); i.hasNext(); ) {
if (clazz.isInstance(i.next())) {
i.remove();
}
}
}
}
|
public void setInterceptors(List list) {
if (list == null) {
return;
}
if (this.requestInterceptors != null) {
this.requestInterceptors.clear();
}
if (this.responseInterceptors != null) {
this.responseInterceptors.clear();
}
for (int i = 0; i < list.size(); i++) {
Object obj = list.get(i);
if (obj instanceof HttpRequestInterceptor) {
addInterceptor((HttpRequestInterceptor)obj);
}
if (obj instanceof HttpResponseInterceptor) {
addInterceptor((HttpResponseInterceptor)obj);
}
}
}
|