类 AbstractHttpInvokerRequestExecutor
- java.lang.Object
- org.springframework.remoting.httpinvoker.AbstractHttpInvokerRequestExecutor
- 所有已实现的接口:
Aware
,BeanClassLoaderAware
,HttpInvokerRequestExecutor
public abstract class AbstractHttpInvokerRequestExecutor extends Object implements HttpInvokerRequestExecutor, BeanClassLoaderAware
Abstract base implementation of the HttpInvokerRequestExecutor interface.Pre-implements serialization of RemoteInvocation objects and deserialization of RemoteInvocationResults objects.
- 从以下版本开始:
- 1.1
- 作者:
- Juergen Hoeller
- 另请参阅:
doExecuteRequest(org.springframework.remoting.httpinvoker.HttpInvokerClientConfiguration, java.io.ByteArrayOutputStream)
字段概要
字段 修饰符和类型 字段 说明 static String
CONTENT_TYPE_SERIALIZED_OBJECT
Default content type: "application/x-java-serialized-object".protected static String
ENCODING_GZIP
protected static String
HTTP_HEADER_ACCEPT_ENCODING
protected static String
HTTP_HEADER_ACCEPT_LANGUAGE
protected static String
HTTP_HEADER_CONTENT_ENCODING
protected static String
HTTP_HEADER_CONTENT_LENGTH
protected static String
HTTP_HEADER_CONTENT_TYPE
protected static String
HTTP_METHOD_POST
protected Log
logger
构造器概要
构造器 构造器 说明 AbstractHttpInvokerRequestExecutor()
方法概要
所有方法 实例方法 抽象方法 具体方法 修饰符和类型 方法 说明 protected ObjectInputStream
createObjectInputStream(InputStream is, String codebaseUrl)
Create an ObjectInputStream for the given InputStream and codebase.protected InputStream
decorateInputStream(InputStream is)
Return the InputStream to use for reading remote invocation results, potentially decorating the given original InputStream.protected OutputStream
decorateOutputStream(OutputStream os)
Return the OutputStream to use for writing remote invocations, potentially decorating the given original OutputStream.protected abstract RemoteInvocationResult
doExecuteRequest(HttpInvokerClientConfiguration config, ByteArrayOutputStream baos)
Execute a request to send the given serialized remote invocation.protected RemoteInvocationResult
doReadRemoteInvocationResult(ObjectInputStream ois)
Perform the actual reading of an invocation object from the given ObjectInputStream.protected void
doWriteRemoteInvocation(RemoteInvocation invocation, ObjectOutputStream oos)
Perform the actual writing of the given invocation object to the given ObjectOutputStream.RemoteInvocationResult
executeRequest(HttpInvokerClientConfiguration config, RemoteInvocation invocation)
Execute a request to send the given remote invocation.protected ClassLoader
getBeanClassLoader()
Return the bean ClassLoader that this executor is supposed to use.protected ByteArrayOutputStream
getByteArrayOutputStream(RemoteInvocation invocation)
Serialize the given RemoteInvocation into a ByteArrayOutputStream.String
getContentType()
Return the content type to use for sending HTTP invoker requests.boolean
isAcceptGzipEncoding()
Return whether to accept GZIP encoding, that is, whether to send the HTTP "Accept-Encoding" header with "gzip" as value.protected RemoteInvocationResult
readRemoteInvocationResult(InputStream is, String codebaseUrl)
Deserialize a RemoteInvocationResult object from the given InputStream.void
setAcceptGzipEncoding(boolean acceptGzipEncoding)
Set whether to accept GZIP encoding, that is, whether to send the HTTP "Accept-Encoding" header with "gzip" as value.void
setBeanClassLoader(ClassLoader classLoader)
Callback that supplies the beanclass loader
to a bean instance.void
setContentType(String contentType)
Specify the content type to use for sending HTTP invoker requests.protected void
writeRemoteInvocation(RemoteInvocation invocation, OutputStream os)
Serialize the given RemoteInvocation to the given OutputStream.
字段详细资料
CONTENT_TYPE_SERIALIZED_OBJECT
public static final String CONTENT_TYPE_SERIALIZED_OBJECT
Default content type: "application/x-java-serialized-object".- 另请参阅:
- 常量字段值
HTTP_METHOD_POST
protected static final String HTTP_METHOD_POST
- 另请参阅:
- 常量字段值
HTTP_HEADER_ACCEPT_LANGUAGE
protected static final String HTTP_HEADER_ACCEPT_LANGUAGE
- 另请参阅:
- 常量字段值
HTTP_HEADER_ACCEPT_ENCODING
protected static final String HTTP_HEADER_ACCEPT_ENCODING
- 另请参阅:
- 常量字段值
HTTP_HEADER_CONTENT_ENCODING
protected static final String HTTP_HEADER_CONTENT_ENCODING
- 另请参阅:
- 常量字段值
HTTP_HEADER_CONTENT_TYPE
protected static final String HTTP_HEADER_CONTENT_TYPE
- 另请参阅:
- 常量字段值
HTTP_HEADER_CONTENT_LENGTH
protected static final String HTTP_HEADER_CONTENT_LENGTH
- 另请参阅:
- 常量字段值
ENCODING_GZIP
protected static final String ENCODING_GZIP
- 另请参阅:
- 常量字段值
构造器详细资料
AbstractHttpInvokerRequestExecutor
public AbstractHttpInvokerRequestExecutor()
方法详细资料
setContentType
public void setContentType(String contentType)
Specify the content type to use for sending HTTP invoker requests.Default is "application/x-java-serialized-object".
getContentType
public String getContentType()
Return the content type to use for sending HTTP invoker requests.
setAcceptGzipEncoding
public void setAcceptGzipEncoding(boolean acceptGzipEncoding)
Set whether to accept GZIP encoding, that is, whether to send the HTTP "Accept-Encoding" header with "gzip" as value.Default is "true". Turn this flag off if you do not want GZIP response compression even if enabled on the HTTP server.
isAcceptGzipEncoding
public boolean isAcceptGzipEncoding()
Return whether to accept GZIP encoding, that is, whether to send the HTTP "Accept-Encoding" header with "gzip" as value.
setBeanClassLoader
public void setBeanClassLoader(ClassLoader classLoader)
从接口复制的说明:BeanClassLoaderAware
Callback that supplies the beanclass loader
to a bean instance.Invoked after the population of normal bean properties but before an initialization callback such as
InitializingBean's
InitializingBean.afterPropertiesSet()
method or a custom init-method.- 指定者:
setBeanClassLoader
在接口中BeanClassLoaderAware
- 参数:
classLoader
- the owning class loader
getBeanClassLoader
@Nullable protected ClassLoader getBeanClassLoader()
Return the bean ClassLoader that this executor is supposed to use.
executeRequest
public final RemoteInvocationResult executeRequest(HttpInvokerClientConfiguration config, RemoteInvocation invocation) throws Exception
从接口复制的说明:HttpInvokerRequestExecutor
Execute a request to send the given remote invocation.- 指定者:
executeRequest
在接口中HttpInvokerRequestExecutor
- 参数:
config
- the HTTP invoker configuration that specifies the target serviceinvocation
- the RemoteInvocation to execute- 返回:
- the RemoteInvocationResult object
- 抛出:
IOException
- if thrown by I/O operationsClassNotFoundException
- if thrown during deserializationException
- in case of general errors
getByteArrayOutputStream
protected ByteArrayOutputStream getByteArrayOutputStream(RemoteInvocation invocation) throws IOException
Serialize the given RemoteInvocation into a ByteArrayOutputStream.- 参数:
invocation
- the RemoteInvocation object- 返回:
- a ByteArrayOutputStream with the serialized RemoteInvocation
- 抛出:
IOException
- if thrown by I/O methods
writeRemoteInvocation
protected void writeRemoteInvocation(RemoteInvocation invocation, OutputStream os) throws IOException
Serialize the given RemoteInvocation to the given OutputStream.The default implementation gives
decorateOutputStream
a chance to decorate the stream first (for example, for custom encryption or compression). Creates anObjectOutputStream
for the final stream and callsdoWriteRemoteInvocation
to actually write the object.Can be overridden for custom serialization of the invocation.
- 参数:
invocation
- the RemoteInvocation objectos
- the OutputStream to write to- 抛出:
IOException
- if thrown by I/O methods- 另请参阅:
decorateOutputStream(java.io.OutputStream)
,doWriteRemoteInvocation(org.springframework.remoting.support.RemoteInvocation, java.io.ObjectOutputStream)
decorateOutputStream
protected OutputStream decorateOutputStream(OutputStream os) throws IOException
Return the OutputStream to use for writing remote invocations, potentially decorating the given original OutputStream.The default implementation returns the given stream as-is. Can be overridden, for example, for custom encryption or compression.
- 参数:
os
- the original OutputStream- 返回:
- the potentially decorated OutputStream
- 抛出:
IOException
doWriteRemoteInvocation
protected void doWriteRemoteInvocation(RemoteInvocation invocation, ObjectOutputStream oos) throws IOException
Perform the actual writing of the given invocation object to the given ObjectOutputStream.The default implementation simply calls
writeObject
. Can be overridden for serialization of a custom wrapper object rather than the plain invocation, for example an encryption-aware holder.- 参数:
invocation
- the RemoteInvocation objectoos
- the ObjectOutputStream to write to- 抛出:
IOException
- if thrown by I/O methods- 另请参阅:
ObjectOutputStream.writeObject(java.lang.Object)
doExecuteRequest
protected abstract RemoteInvocationResult doExecuteRequest(HttpInvokerClientConfiguration config, ByteArrayOutputStream baos) throws Exception
Execute a request to send the given serialized remote invocation.Implementations will usually call
readRemoteInvocationResult
to deserialize a returned RemoteInvocationResult object.- 参数:
config
- the HTTP invoker configuration that specifies the target servicebaos
- the ByteArrayOutputStream that contains the serialized RemoteInvocation object- 返回:
- the RemoteInvocationResult object
- 抛出:
IOException
- if thrown by I/O operationsClassNotFoundException
- if thrown during deserializationException
- in case of general errors- 另请参阅:
readRemoteInvocationResult(java.io.InputStream, String)
readRemoteInvocationResult
protected RemoteInvocationResult readRemoteInvocationResult(InputStream is, @Nullable String codebaseUrl) throws IOException, ClassNotFoundException
Deserialize a RemoteInvocationResult object from the given InputStream.Gives
decorateInputStream
a chance to decorate the stream first (for example, for custom encryption or compression). Creates anObjectInputStream
viacreateObjectInputStream
and callsdoReadRemoteInvocationResult
to actually read the object.Can be overridden for custom serialization of the invocation.
- 参数:
is
- the InputStream to read fromcodebaseUrl
- the codebase URL to load classes from if not found locally- 返回:
- the RemoteInvocationResult object
- 抛出:
IOException
- if thrown by I/O methodsClassNotFoundException
- if thrown during deserialization- 另请参阅:
decorateInputStream(java.io.InputStream)
,createObjectInputStream(java.io.InputStream, java.lang.String)
,doReadRemoteInvocationResult(java.io.ObjectInputStream)
decorateInputStream
protected InputStream decorateInputStream(InputStream is) throws IOException
Return the InputStream to use for reading remote invocation results, potentially decorating the given original InputStream.The default implementation returns the given stream as-is. Can be overridden, for example, for custom encryption or compression.
- 参数:
is
- the original InputStream- 返回:
- the potentially decorated InputStream
- 抛出:
IOException
createObjectInputStream
protected ObjectInputStream createObjectInputStream(InputStream is, @Nullable String codebaseUrl) throws IOException
Create an ObjectInputStream for the given InputStream and codebase. The default implementation creates a CodebaseAwareObjectInputStream.- 参数:
is
- the InputStream to read fromcodebaseUrl
- the codebase URL to load classes from if not found locally (can benull
)- 返回:
- the new ObjectInputStream instance to use
- 抛出:
IOException
- if creation of the ObjectInputStream failed- 另请参阅:
CodebaseAwareObjectInputStream
doReadRemoteInvocationResult
protected RemoteInvocationResult doReadRemoteInvocationResult(ObjectInputStream ois) throws IOException, ClassNotFoundException
Perform the actual reading of an invocation object from the given ObjectInputStream.The default implementation simply calls
readObject
. Can be overridden for deserialization of a custom wrapper object rather than the plain invocation, for example an encryption-aware holder.- 参数:
ois
- the ObjectInputStream to read from- 返回:
- the RemoteInvocationResult object
- 抛出:
IOException
- if thrown by I/O methodsClassNotFoundException
- if the class name of a serialized object couldn't get resolved- 另请参阅:
ObjectOutputStream.writeObject(java.lang.Object)