org.xins.common.spring
Class XinsClientInterceptor

java.lang.Object
  extended byorg.springframework.remoting.support.RemoteAccessor
      extended byorg.springframework.remoting.support.UrlBasedRemoteAccessor
          extended byorg.xins.common.spring.XinsClientInterceptor
All Implemented Interfaces:
org.aopalliance.aop.Advice, org.springframework.beans.factory.InitializingBean, org.aopalliance.intercept.Interceptor, org.aopalliance.intercept.MethodInterceptor
Direct Known Subclasses:
XinsCapiFactoryBean

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

Interceptor for accessing a specific XINS API. This class requires the Spring library.

Since:
XINS 2.0
Version:
$Revision: 1.2 $ $Date: 2007/05/21 10:55:49 $
Author:
Anthony Goubard

Field Summary
protected  AbstractCAPI capi
          The CAPI used to call the web service.
 
Fields inherited from class org.springframework.remoting.support.RemoteAccessor
logger
 
Constructor Summary
XinsClientInterceptor()
           
 
Method Summary
 void afterPropertiesSet()
           
protected  org.springframework.remoting.RemoteAccessException convertXinsAccessException(Throwable ex)
          Convert the given XINS exception to an appropriate Spring RemoteAccessException.
 AbstractCAPI createCapi()
          Creates the CAPI to call the API.
 Descriptor createDescriptor()
          Creates the Descriptor containing the location of the API.
 XINSServiceCaller createXinsServiceCaller()
          Creates the XINSServiceCaller to call the API.
 String getServiceName()
          Gets the name of the API to call.
 Object invoke(org.aopalliance.intercept.MethodInvocation invocation)
           
 void prepare()
           
 void setServiceName(String serviceName)
          Sets the name of the API to call.
 void setServiceProperties(Properties descriptorProperties)
          Sets the location of the API to call.
 void setTimeout(int timeout)
          Sets the time-out for the call of the API.
 
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
 

Field Detail

capi

protected AbstractCAPI capi
The CAPI used to call the web service.

Constructor Detail

XinsClientInterceptor

public XinsClientInterceptor()
Method Detail

afterPropertiesSet

public void afterPropertiesSet()
Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean

prepare

public void prepare()

setServiceProperties

public void setServiceProperties(Properties descriptorProperties)
Sets the location of the API to call. If this method is call, it will invalidate the previous call to UrlBasedRemoteAccessor.setServiceUrl(java.lang.String) and setTimeout(int) methods.

Parameters:
descriptorProperties - the different destination as explained in DescriptorBuilder.

setTimeout

public void setTimeout(int timeout)
Sets the time-out for the call of the API. This method requires that you also call UrlBasedRemoteAccessor.setServiceUrl(java.lang.String).

Parameters:
timeout - the time-out for the call in milliseconds. This parameter will be used for the connection time-out, socket time-out and total time-out.

setServiceName

public void setServiceName(String serviceName)
Sets the name of the API to call. The name is used to detect the capi.<api name> in the service properties set.

Parameters:
serviceName - the name of the API to call.

getServiceName

public String getServiceName()
Gets the name of the API to call.

Returns:
the name of the API to call.

createDescriptor

public Descriptor createDescriptor()
                            throws Exception
Creates the Descriptor containing the location of the API.

Returns:
the specified descriptor or null no descriptorProperties or serviceURL is set.
Throws:
Exception - if the descriptorProperties or serviceURL is incorrect.

createCapi

public AbstractCAPI createCapi()
                        throws Exception
Creates the CAPI to call the API.

Returns:
the created CAPI.
Throws:
Exception - if the CAPI class is not found or the descriptor cannot be created.

createXinsServiceCaller

public XINSServiceCaller createXinsServiceCaller()
                                          throws Exception
Creates the XINSServiceCaller to call the API.

Returns:
the service caller to call the API.
Throws:
Exception - if the descriptor cannot be created or is incorrect.

invoke

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

convertXinsAccessException

protected org.springframework.remoting.RemoteAccessException convertXinsAccessException(Throwable ex)
Convert the given XINS exception to an appropriate Spring RemoteAccessException.

Parameters:
ex - the exception to convert.
Returns:
the RemoteAccessException to throw.


See http://www.xins.org/.