public class HessianClientInterceptor extends UrlBasedRemoteAccessor implements MethodInterceptor
MethodInterceptor
for accessing a Hessian service.
Supports authentication via username and password.
The service URL must be an HTTP URL exposing a Hessian service.
Hessian is a slim, binary RPC protocol. For information on Hessian, see the Hessian website Note: As of Spring 4.0, this client requires Hessian 4.0 or above.
Note: There is no requirement for services accessed with this proxy factory
to have been exported using Spring's HessianServiceExporter
, as there is
no special handling involved. As a consequence, you can also access services that
have been exported using Caucho's HessianServlet
.
RemoteAccessor.setServiceInterface(java.lang.Class<?>)
,
UrlBasedRemoteAccessor.setServiceUrl(java.lang.String)
,
setUsername(java.lang.String)
,
setPassword(java.lang.String)
,
HessianServiceExporter
,
HessianProxyFactoryBean
,
HessianProxyFactory
,
HessianServlet
logger
Constructor and Description |
---|
HessianClientInterceptor() |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet()
Invoked by a BeanFactory after it has set all bean properties supplied
(and satisfied BeanFactoryAware and ApplicationContextAware).
|
protected RemoteAccessException |
convertHessianAccessException(Throwable ex)
Convert the given Hessian access exception to an appropriate
Spring RemoteAccessException.
|
protected Object |
createHessianProxy(com.caucho.hessian.client.HessianProxyFactory proxyFactory)
Create the Hessian proxy that is wrapped by this interceptor.
|
Object |
invoke(MethodInvocation invocation) |
void |
prepare()
Initialize the Hessian proxy for this interceptor.
|
void |
setAllowNonSerializable(boolean allowNonSerializable)
Set whether to allow non-serializable types as Hessian arguments
and return values.
|
void |
setChunkedPost(boolean chunkedPost)
Set whether to use a chunked post for sending a Hessian request.
|
void |
setConnectionFactory(com.caucho.hessian.client.HessianConnectionFactory connectionFactory)
Specify a custom HessianConnectionFactory to use for the Hessian client.
|
void |
setConnectTimeout(long timeout)
Set the socket connect timeout to use for the Hessian client.
|
void |
setDebug(boolean debug)
Set whether Hessian's debug mode should be enabled.
|
void |
setHessian2(boolean hessian2)
Set whether version 2 of the Hessian protocol should be used for
parsing requests and replies.
|
void |
setHessian2Reply(boolean hessian2)
Set whether version 2 of the Hessian protocol should be used for
parsing replies.
|
void |
setHessian2Request(boolean hessian2)
Set whether version 2 of the Hessian protocol should be used for
parsing requests.
|
void |
setOverloadEnabled(boolean overloadEnabled)
Set whether overloaded methods should be enabled for remote invocations.
|
void |
setPassword(String password)
Set the password that this factory should use to access the remote service.
|
void |
setProxyFactory(com.caucho.hessian.client.HessianProxyFactory proxyFactory)
Set the HessianProxyFactory instance to use.
|
void |
setReadTimeout(long timeout)
Set the timeout to use when waiting for a reply from the Hessian service.
|
void |
setSendCollectionType(boolean sendCollectionType)
Set whether to send the Java collection type for each serialized
collection.
|
void |
setSerializerFactory(com.caucho.hessian.io.SerializerFactory serializerFactory)
Specify the Hessian SerializerFactory to use.
|
void |
setUsername(String username)
Set the username that this factory should use to access the remote service.
|
getServiceUrl, setServiceUrl
getServiceInterface, setServiceInterface
getBeanClassLoader, overrideThreadContextClassLoader, resetThreadContextClassLoader, setBeanClassLoader
public void setProxyFactory(com.caucho.hessian.client.HessianProxyFactory proxyFactory)
Allows to use an externally configured factory instance, in particular a custom HessianProxyFactory subclass.
public void setSerializerFactory(com.caucho.hessian.io.SerializerFactory serializerFactory)
This will typically be passed in as an inner bean definition
of type com.caucho.hessian.io.SerializerFactory
,
with custom bean property values applied.
public void setSendCollectionType(boolean sendCollectionType)
public void setAllowNonSerializable(boolean allowNonSerializable)
public void setOverloadEnabled(boolean overloadEnabled)
HessianProxyFactory.setOverloadEnabled(boolean)
public void setUsername(String username)
The username will be sent by Hessian via HTTP Basic Authentication.
HessianProxyFactory.setUser(java.lang.String)
public void setPassword(String password)
The password will be sent by Hessian via HTTP Basic Authentication.
HessianProxyFactory.setPassword(java.lang.String)
public void setDebug(boolean debug)
HessianProxyFactory.setDebug(boolean)
public void setChunkedPost(boolean chunkedPost)
HessianProxyFactory.setChunkedPost(boolean)
public void setConnectionFactory(com.caucho.hessian.client.HessianConnectionFactory connectionFactory)
public void setConnectTimeout(long timeout)
HessianProxyFactory.setConnectTimeout(long)
public void setReadTimeout(long timeout)
HessianProxyFactory.setReadTimeout(long)
public void setHessian2(boolean hessian2)
HessianProxyFactory.setHessian2Request(boolean)
public void setHessian2Request(boolean hessian2)
HessianProxyFactory.setHessian2Request(boolean)
public void setHessian2Reply(boolean hessian2)
HessianProxyFactory.setHessian2Reply(boolean)
public void afterPropertiesSet()
InitializingBean
This method allows the bean instance to perform initialization only possible when all bean properties have been set and to throw an exception in the event of misconfiguration.
afterPropertiesSet
in interface InitializingBean
afterPropertiesSet
in class UrlBasedRemoteAccessor
public void prepare() throws RemoteLookupFailureException
RemoteLookupFailureException
- if the service URL is invalidprotected Object createHessianProxy(com.caucho.hessian.client.HessianProxyFactory proxyFactory) throws MalformedURLException
proxyFactory
- the proxy factory to useMalformedURLException
- if thrown by the proxy factoryHessianProxyFactory.create(java.lang.String)
public Object invoke(MethodInvocation invocation) throws Throwable
invoke
in interface MethodInterceptor
Throwable
protected RemoteAccessException convertHessianAccessException(Throwable ex)
ex
- the exception to convert