001/*
002 * Copyright 2002-2015 the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *      https://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.springframework.remoting.httpinvoker;
018
019import java.io.IOException;
020
021import org.springframework.remoting.support.RemoteInvocation;
022import org.springframework.remoting.support.RemoteInvocationResult;
023
024/**
025 * Strategy interface for actual execution of an HTTP invoker request.
026 * Used by HttpInvokerClientInterceptor and its subclass
027 * HttpInvokerProxyFactoryBean.
028 *
029 * <p>Two implementations are provided out of the box:
030 * <ul>
031 * <li><b>{@code SimpleHttpInvokerRequestExecutor}:</b>
032 * Uses JDK facilities to execute POST requests, without support
033 * for HTTP authentication or advanced configuration options.
034 * <li><b>{@code HttpComponentsHttpInvokerRequestExecutor}:</b>
035 * Uses Apache's Commons HttpClient to execute POST requests,
036 * allowing to use a preconfigured HttpClient instance
037 * (potentially with authentication, HTTP connection pooling, etc).
038 * </ul>
039 *
040 * @author Juergen Hoeller
041 * @since 1.1
042 * @see HttpInvokerClientInterceptor#setHttpInvokerRequestExecutor
043 */
044public interface HttpInvokerRequestExecutor {
045
046        /**
047         * Execute a request to send the given remote invocation.
048         * @param config the HTTP invoker configuration that specifies the
049         * target service
050         * @param invocation the RemoteInvocation to execute
051         * @return the RemoteInvocationResult object
052         * @throws IOException if thrown by I/O operations
053         * @throws ClassNotFoundException if thrown during deserialization
054         * @throws Exception in case of general errors
055         */
056        RemoteInvocationResult executeRequest(HttpInvokerClientConfiguration config, RemoteInvocation invocation)
057                        throws Exception;
058
059}