类 HttpInvokerClientInterceptor
- java.lang.Object
- org.springframework.remoting.support.RemotingSupport
- org.springframework.remoting.support.RemoteAccessor
- org.springframework.remoting.support.UrlBasedRemoteAccessor
- org.springframework.remoting.support.RemoteInvocationBasedAccessor
- org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor
- 所有已实现的接口:
Advice
,Interceptor
,MethodInterceptor
,Aware
,BeanClassLoaderAware
,InitializingBean
,HttpInvokerClientConfiguration
- 直接已知子类:
HttpInvokerProxyFactoryBean
public class HttpInvokerClientInterceptor extends RemoteInvocationBasedAccessor implements MethodInterceptor, HttpInvokerClientConfiguration
MethodInterceptor
for accessing an HTTP invoker service. The service URL must be an HTTP URL exposing an HTTP invoker service.Serializes remote invocation objects and deserializes remote invocation result objects. Uses Java serialization just like RMI, but provides the same ease of setup as Caucho's HTTP-based Hessian protocol.
HTTP invoker is a very extensible and customizable protocol. It supports the RemoteInvocationFactory mechanism, like RMI invoker, allowing to include additional invocation attributes (for example, a security context). Furthermore, it allows to customize request execution via the
HttpInvokerRequestExecutor
strategy.Can use the JDK's
RMIClassLoader
to load classes from a givencodebase
, performing on-demand dynamic code download from a remote location. The codebase can consist of multiple URLs, separated by spaces. Note that RMIClassLoader requires a SecurityManager to be set, analogous to when using dynamic class download with standard RMI! (See the RMI documentation for details.)WARNING: Be aware of vulnerabilities due to unsafe Java deserialization: Manipulated input streams could lead to unwanted code execution on the server during the deserialization step. As a consequence, do not expose HTTP invoker endpoints to untrusted clients but rather just between your own services. In general, we strongly recommend any other message format (e.g. JSON) instead.
- 从以下版本开始:
- 1.1
- 作者:
- Juergen Hoeller
- 另请参阅:
UrlBasedRemoteAccessor.setServiceUrl(java.lang.String)
,setCodebaseUrl(java.lang.String)
,RemoteInvocationBasedAccessor.setRemoteInvocationFactory(org.springframework.remoting.support.RemoteInvocationFactory)
,setHttpInvokerRequestExecutor(org.springframework.remoting.httpinvoker.HttpInvokerRequestExecutor)
,HttpInvokerServiceExporter
,HttpInvokerProxyFactoryBean
,RMIClassLoader
字段概要
从类继承的字段 org.springframework.remoting.support.RemotingSupport
logger
构造器概要
构造器 构造器 说明 HttpInvokerClientInterceptor()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 void
afterPropertiesSet()
Invoked by the containingBeanFactory
after it has set all bean properties and satisfiedBeanFactoryAware
,ApplicationContextAware
etc.protected RemoteAccessException
convertHttpInvokerAccessException(Throwable ex)
Convert the given HTTP invoker access exception to an appropriate SpringRemoteAccessException
.protected RemoteInvocationResult
executeRequest(RemoteInvocation invocation)
Execute the given remote invocation via theHttpInvokerRequestExecutor
.protected RemoteInvocationResult
executeRequest(RemoteInvocation invocation, MethodInvocation originalInvocation)
Execute the given remote invocation via theHttpInvokerRequestExecutor
.String
getCodebaseUrl()
Return the codebase URL to download classes from if not found locally.HttpInvokerRequestExecutor
getHttpInvokerRequestExecutor()
Return the HttpInvokerRequestExecutor used by this remote accessor.Object
invoke(MethodInvocation methodInvocation)
Implement this method to perform extra treatments before and after the invocation.void
setCodebaseUrl(String codebaseUrl)
Set the codebase URL to download classes from if not found locally.void
setHttpInvokerRequestExecutor(HttpInvokerRequestExecutor httpInvokerRequestExecutor)
Set the HttpInvokerRequestExecutor implementation to use for executing remote invocations.从类继承的方法 org.springframework.remoting.support.RemoteInvocationBasedAccessor
createRemoteInvocation, getRemoteInvocationFactory, recreateRemoteInvocationResult, setRemoteInvocationFactory
从类继承的方法 org.springframework.remoting.support.UrlBasedRemoteAccessor
getServiceUrl, setServiceUrl
从类继承的方法 org.springframework.remoting.support.RemoteAccessor
getServiceInterface, setServiceInterface
从类继承的方法 org.springframework.remoting.support.RemotingSupport
getBeanClassLoader, overrideThreadContextClassLoader, resetThreadContextClassLoader, setBeanClassLoader
从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
从接口继承的方法 org.springframework.remoting.httpinvoker.HttpInvokerClientConfiguration
getServiceUrl
构造器详细资料
HttpInvokerClientInterceptor
public HttpInvokerClientInterceptor()
方法详细资料
setCodebaseUrl
public void setCodebaseUrl(@Nullable String codebaseUrl)
Set the codebase URL to download classes from if not found locally. Can consists of multiple URLs, separated by spaces.Follows RMI's codebase conventions for dynamic class download. In contrast to RMI, where the server determines the URL for class download (via the "java.rmi.server.codebase" system property), it's the client that determines the codebase URL here. The server will usually be the same as for the service URL, just pointing to a different path there.
getCodebaseUrl
@Nullable public String getCodebaseUrl()
Return the codebase URL to download classes from if not found locally.- 指定者:
getCodebaseUrl
在接口中HttpInvokerClientConfiguration
- 返回:
- the codebase URL, or
null
if none - 另请参阅:
RMIClassLoader
setHttpInvokerRequestExecutor
public void setHttpInvokerRequestExecutor(HttpInvokerRequestExecutor httpInvokerRequestExecutor)
Set the HttpInvokerRequestExecutor implementation to use for executing remote invocations.Default is
SimpleHttpInvokerRequestExecutor
. Alternatively, consider usingHttpComponentsHttpInvokerRequestExecutor
for more sophisticated needs.
getHttpInvokerRequestExecutor
public HttpInvokerRequestExecutor getHttpInvokerRequestExecutor()
Return the HttpInvokerRequestExecutor used by this remote accessor.Creates a default SimpleHttpInvokerRequestExecutor if no executor has been initialized already.
afterPropertiesSet
public void afterPropertiesSet()
从接口复制的说明:InitializingBean
Invoked by the containingBeanFactory
after it has set all bean properties and satisfiedBeanFactoryAware
,ApplicationContextAware
etc.This method allows the bean instance to perform validation of its overall configuration and final initialization when all bean properties have been set.
invoke
public Object invoke(MethodInvocation methodInvocation) throws Throwable
从接口复制的说明:MethodInterceptor
Implement this method to perform extra treatments before and after the invocation. Polite implementations would certainly like to invokeJoinpoint.proceed()
.- 指定者:
invoke
在接口中MethodInterceptor
- 参数:
methodInvocation
- the method invocation joinpoint- 返回:
- the result of the call to
Joinpoint.proceed()
; might be intercepted by the interceptor - 抛出:
Throwable
- if the interceptors or the target object throws an exception
executeRequest
protected RemoteInvocationResult executeRequest(RemoteInvocation invocation, MethodInvocation originalInvocation) throws Exception
Execute the given remote invocation via theHttpInvokerRequestExecutor
.This implementation delegates to
executeRequest(RemoteInvocation)
. Can be overridden to react to the specific original MethodInvocation.- 参数:
invocation
- the RemoteInvocation to executeoriginalInvocation
- the original MethodInvocation (can e.g. be cast to the ProxyMethodInvocation interface for accessing user attributes)- 返回:
- the RemoteInvocationResult object
- 抛出:
Exception
- in case of errors
executeRequest
protected RemoteInvocationResult executeRequest(RemoteInvocation invocation) throws Exception
Execute the given remote invocation via theHttpInvokerRequestExecutor
.Can be overridden in subclasses to pass a different configuration object to the executor. Alternatively, add further configuration properties in a subclass of this accessor: By default, the accessor passed itself as configuration object to the executor.
- 参数:
invocation
- the RemoteInvocation to execute- 返回:
- the RemoteInvocationResult object
- 抛出:
IOException
- if thrown by I/O operationsClassNotFoundException
- if thrown during deserializationException
- in case of general errors- 另请参阅:
getHttpInvokerRequestExecutor()
,HttpInvokerClientConfiguration
convertHttpInvokerAccessException
@Nullable protected RemoteAccessException convertHttpInvokerAccessException(Throwable ex)
Convert the given HTTP invoker access exception to an appropriate SpringRemoteAccessException
.- 参数:
ex
- the exception to convert- 返回:
- the RemoteAccessException to throw, or
null
to have the original exception propagated to the caller