com.googlecode.xremoting.spring
Class XRemotingClientInterceptor

java.lang.Object
  extended by org.springframework.remoting.support.RemoteAccessor
      extended by org.springframework.remoting.support.UrlBasedRemoteAccessor
          extended by com.googlecode.xremoting.spring.XRemotingClientInterceptor
All Implemented Interfaces:
org.aopalliance.aop.Advice, org.aopalliance.intercept.Interceptor, org.aopalliance.intercept.MethodInterceptor, org.springframework.beans.factory.InitializingBean
Direct Known Subclasses:
XRemotingProxyFactoryBean

public class XRemotingClientInterceptor
extends org.springframework.remoting.support.UrlBasedRemoteAccessor
implements org.aopalliance.intercept.MethodInterceptor

Client interceptor for XRemoting to use for remote calls.

Author:
Roman Puchkovskiy
See Also:
HttpInvokerClientInterceptor, HessianClientInterceptor, BurlapClientInterceptor

Field Summary
 
Fields inherited from class org.springframework.remoting.support.RemoteAccessor
logger
 
Constructor Summary
XRemotingClientInterceptor()
           
 
Method Summary
 void afterPropertiesSet()
           
protected  org.springframework.remoting.RemoteAccessException convertXRemotingAccessException(Throwable ex)
           
protected  HttpClientBuilder createAndConfigureHttpClientBuilder()
           
protected  Requester createComplexRequester()
           
protected  org.apache.commons.httpclient.HttpClient createHttpClient()
           
protected  HttpConnectionFactory createHttpConnectionFactory()
           
protected  XRemotingProxyFactory createProxyFactory()
           
protected  Requester createRequester()
           
protected  Requester createSimpleRequester()
           
protected  Object createXRemotingProxy(XRemotingProxyFactory proxyFactory)
           
protected  ClassLoader getBeanClassLoader()
           
 Object invoke(org.aopalliance.intercept.MethodInvocation invocation)
           
 void prepare()
          Initializes the interceptor.
 void setAuthPreemptive(boolean authPreemptive)
          Sets whether to use authPreemptive by a built HttpClient (for Basic auth).
 void setBasicAuthHost(String basicAuthHost)
          Sets a host for which Basic auth will be used by a built HttpClient.
 void setBasicAuthPort(int basicAuthPort)
          Sets a port for which Basic auth will be used by a built HttpClient.
 void setBeanClassLoader(ClassLoader beanClassLoader)
          Sets classloader to use when constructing a Proxy.
 void setHttpClient(Object httpClient)
          Sets an HttpClient to use with CommonsHttpClientRequester.
 void setKeyStorePassword(String keyStorePassword)
          Sets a key store password to be used by a built HttpClient.
 void setKeyStoreResource(org.springframework.core.io.Resource keyStoreResource)
          Sets a key store resource to be used by a built HttpClient.
 void setKeyStoreUrl(URL keyStoreUrl)
          Sets a key store URL to be used by a built HttpClient.
 void setPassword(String password)
          Sets a password to be used by a built HttpClient (for Basic auth).
 void setProxyHost(String proxyHost)
          Sets a proxy host to be used by a built HttpClient.
 void setProxyPort(int proxyPort)
          Sets a proxy port to be used by a built HttpClient.
 void setRequester(Requester requester)
          Sets a Requester to use.
 void setSslHost(String sslHost)
          Sets SSL host to be used by a built HttpClient.
 void setSslPort(int sslPort)
          Sets SSL port to be used by a built HttpClient.
 void setTrustKeyStorePassword(String trustKeyStorePassword)
          Sets a trust store password to be used by a built HttpClient.
 void setTrustKeyStoreResource(org.springframework.core.io.Resource trustKeyStoreResource)
          Sets a trust store resource to be used by a built HttpClient.
 void setTrustKeyStoreUrl(URL trustKeyStoreUrl)
          Sets a trust store URL to be used by a built HttpClient.
 void setUsername(String username)
          Sets a username to be used by a built HttpClient (for Basic auth).
 
Methods inherited from class org.springframework.remoting.support.UrlBasedRemoteAccessor
getServiceUrl, setServiceUrl
 
Methods inherited from class org.springframework.remoting.support.RemoteAccessor
getServiceInterface, setServiceInterface
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XRemotingClientInterceptor

public XRemotingClientInterceptor()
Method Detail

setBeanClassLoader

public void setBeanClassLoader(ClassLoader beanClassLoader)
Sets classloader to use when constructing a Proxy.

Parameters:
beanClassLoader - classloader

setRequester

public void setRequester(Requester requester)
Sets a Requester to use. If this is set, requester will not be built but this one will be used.

Parameters:
requester - requester

setHttpClient

public void setHttpClient(Object httpClient)
Sets an HttpClient to use with CommonsHttpClientRequester. If setRequester(Requester) is not called, then CommonsHttpClientRequester will use the supplied HttpClient instead of building it from configuration like proxy config, SSL config etc.

Parameters:
httpClient - HTTPClient to set

setProxyHost

public void setProxyHost(String proxyHost)
Sets a proxy host to be used by a built HttpClient. Only used if HttpClient is built (see setRequester(Requester), setHttpClient(Object).

Parameters:
proxyHost - host

setProxyPort

public void setProxyPort(int proxyPort)
Sets a proxy port to be used by a built HttpClient. Only used if HttpClient is built (see setRequester(Requester), setHttpClient(Object).

Parameters:
proxyPort - port

setUsername

public void setUsername(String username)
Sets a username to be used by a built HttpClient (for Basic auth). Only used if HttpClient is built (see setRequester(Requester), setHttpClient(Object).

Parameters:
username - name

setPassword

public void setPassword(String password)
Sets a password to be used by a built HttpClient (for Basic auth). Only used if HttpClient is built (see setRequester(Requester), setHttpClient(Object).

Parameters:
password - password

setAuthPreemptive

public void setAuthPreemptive(boolean authPreemptive)
Sets whether to use authPreemptive by a built HttpClient (for Basic auth). Only used if HttpClient is built (see setRequester(Requester), setHttpClient(Object).

Parameters:
authPreemptive - value

setBasicAuthHost

public void setBasicAuthHost(String basicAuthHost)
Sets a host for which Basic auth will be used by a built HttpClient. Only used if HttpClient is built (see setRequester(Requester), setHttpClient(Object).

Parameters:
basicAuthHost - host

setBasicAuthPort

public void setBasicAuthPort(int basicAuthPort)
Sets a port for which Basic auth will be used by a built HttpClient. Only used if HttpClient is built (see setRequester(Requester), setHttpClient(Object).

Parameters:
basicAuthPort - port

setTrustKeyStoreUrl

public void setTrustKeyStoreUrl(URL trustKeyStoreUrl)
Sets a trust store URL to be used by a built HttpClient. If this is set, server SSL certificate will be requested and validated. Only used if HttpClient is built (see setRequester(Requester), setHttpClient(Object).

Parameters:
trustKeyStoreUrl - URL

setTrustKeyStoreResource

public void setTrustKeyStoreResource(org.springframework.core.io.Resource trustKeyStoreResource)
Sets a trust store resource to be used by a built HttpClient. If this is set, server SSL certificate will be requested and validated. Only used if HttpClient is built (see setRequester(Requester), setHttpClient(Object).

Parameters:
trustKeyStoreResource - resource

setKeyStoreUrl

public void setKeyStoreUrl(URL keyStoreUrl)
Sets a key store URL to be used by a built HttpClient. If this is set, client will send its certificate to the server. Only used if HttpClient is built (see setRequester(Requester), setHttpClient(Object).

Parameters:
keyStoreUrl - URL

setKeyStoreResource

public void setKeyStoreResource(org.springframework.core.io.Resource keyStoreResource)
Sets a key store resource to be used by a built HttpClient. If this is set, client will send its certificate to the server. Only used if HttpClient is built (see setRequester(Requester), setHttpClient(Object).

Parameters:
keyStoreResource - resource

setTrustKeyStorePassword

public void setTrustKeyStorePassword(String trustKeyStorePassword)
Sets a trust store password to be used by a built HttpClient. Only used if HttpClient is built (see setRequester(Requester), setHttpClient(Object).

Parameters:
trustKeyStorePassword - password

setKeyStorePassword

public void setKeyStorePassword(String keyStorePassword)
Sets a key store password to be used by a built HttpClient. Only used if HttpClient is built (see setRequester(Requester), setHttpClient(Object).

Parameters:
keyStorePassword - password

setSslHost

public void setSslHost(String sslHost)
Sets SSL host to be used by a built HttpClient. This must match a host to which requests will be made (i.e. UrlBasedRemoteAccessor.getServiceUrl()). Only used if HttpClient is built (see setRequester(Requester), setHttpClient(Object).

Parameters:
sslHost - host

setSslPort

public void setSslPort(int sslPort)
Sets SSL port to be used by a built HttpClient. This must match a port to which requests will be made (i.e. UrlBasedRemoteAccessor.getServiceUrl()). Only used if HttpClient is built (see setRequester(Requester), setHttpClient(Object).

Parameters:
sslPort - port

getBeanClassLoader

protected final ClassLoader getBeanClassLoader()

afterPropertiesSet

public void afterPropertiesSet()
Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
Overrides:
afterPropertiesSet in class org.springframework.remoting.support.UrlBasedRemoteAccessor

prepare

public void prepare()
             throws IOException
Initializes the interceptor. Must be called prior to making invocations.

Throws:
IOException - thrown if truststore or keystore could not be obtained

createProxyFactory

protected XRemotingProxyFactory createProxyFactory()
                                            throws IOException
Throws:
IOException

createRequester

protected Requester createRequester()
                             throws IOException
Throws:
IOException

createSimpleRequester

protected Requester createSimpleRequester()

createHttpConnectionFactory

protected HttpConnectionFactory createHttpConnectionFactory()

createComplexRequester

protected Requester createComplexRequester()
                                    throws IOException
Throws:
IOException

createHttpClient

protected org.apache.commons.httpclient.HttpClient createHttpClient()
                                                             throws IOException
Throws:
IOException

createAndConfigureHttpClientBuilder

protected HttpClientBuilder createAndConfigureHttpClientBuilder()
                                                         throws IOException
Throws:
IOException

createXRemotingProxy

protected Object createXRemotingProxy(XRemotingProxyFactory proxyFactory)

invoke

public Object invoke(org.aopalliance.intercept.MethodInvocation invocation)
              throws Throwable
Specified by:
invoke in interface org.aopalliance.intercept.MethodInterceptor
Throws:
Throwable

convertXRemotingAccessException

protected org.springframework.remoting.RemoteAccessException convertXRemotingAccessException(Throwable ex)


Copyright © 2010. All Rights Reserved.