com.lonepulse.zombielink.response.AbstractResponseProcessor Maven / Gradle / Ivy
package com.lonepulse.zombielink.response;
/*
* #%L
* ZombieLink
* %%
* Copyright (C) 2013 - 2014 Lonepulse
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
import static com.lonepulse.zombielink.util.Assert.assertAssignable;
import static com.lonepulse.zombielink.util.Assert.assertLength;
import static com.lonepulse.zombielink.util.Assert.assertNotNull;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpRequestBase;
import com.lonepulse.zombielink.processor.Processor;
import com.lonepulse.zombielink.proxy.InvocationContext;
/**
* This is an abstract implementation of {@link Processor} which specifies a template for processing
* the response of a request execution by referencing the metadata on a proxy endpoint
* request. It includes an implementation of {@link Processor#run(Object...)} that checks the
* preconditions for executing {@link #process(InvocationContext, HttpRequestBase)}.
*
* All implementations must be aware of the {@link InvocationContext} which can be used to discover
* information about the endpoint and the request declaration. This information can be queried based on
* the targeting criteria for this response processor and the resulting information should be used
* to deserialize the given {@link HttpResponse}.
*
* It is advised to adhere to RFC 2616 of
* HTTP 1.1 when designing an implementation.
*
* @version 1.1.0
*
* @since 1.3.0
*
* @author Lahiru Sahan Jayasinghe
*/
abstract class AbstractResponseProcessor implements Processor