com.google.api.ads.common.lib.soap
Class SoapClientHandler<T>

java.lang.Object
  extended by com.google.api.ads.common.lib.soap.SoapClientHandler<T>
Type Parameters:
T - the SOAP client type
All Implemented Interfaces:
SoapClientHandlerInterface<T>

public abstract class SoapClientHandler<T>
extends Object
implements SoapClientHandlerInterface<T>

Base class for SOAP client handlers. Calling invoke(SoapCall) will perform the method retrieved from SoapCall.getSoapClientMethod() on the SoapCall.getSoapClient() with the arguments retrieved from SoapCall.getSoapArgs().

Author:
Adam Rogal
See Also:
SoapClientHandlerInterface

Constructor Summary
protected SoapClientHandler()
          Default constructor.
 
Method Summary
 Method getSoapClientMethod(T soapClient, Method method)
          Gets the method from the SOAP client that matches the supplied method.
protected  Object invoke(SoapCall<T> soapCall)
          Takes a SoapCall object and invokes the method by reflection.
protected  Object[] processSoapArguments(Method soapClientMethod, Object[] args)
          Processes the arguments such that they will be ready to be passed into the supplied SOAP client method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.google.api.ads.common.lib.soap.SoapClientHandlerInterface
clearHeaders, createSoapClient, createSoapHeaderElement, getEndpointAddress, getHeader, invokeSoapCall, putAllHttpHeaders, setCompression, setEndpointAddress, setHeader
 

Constructor Detail

SoapClientHandler

protected SoapClientHandler()
Default constructor.

Method Detail

processSoapArguments

protected Object[] processSoapArguments(Method soapClientMethod,
                                        Object[] args)
Processes the arguments such that they will be ready to be passed into the supplied SOAP client method. This method can be overridden in the case that a particular framework must additionally process the arguments.

In the default implementation of processing arguments, if the number of arguments is too small, the argument list will be padded with null. If args is null, null will be returned.

Parameters:
soapClientMethod - the SOAP client method that will be called with the args
args - the arguments that will be processed
Returns:
the arguments ready to be passed into the soapClientMethod.

getSoapClientMethod

public Method getSoapClientMethod(T soapClient,
                                  Method method)
                           throws NoSuchMethodException
Gets the method from the SOAP client that matches the supplied method.

In the default implementation, only the method name and return type will be matched.

Specified by:
getSoapClientMethod in interface SoapClientHandlerInterface<T>
Parameters:
soapClient - the SOAP client within which to search for the method
method - the method to match
Returns:
the SOAP client's matching method
Throws:
NoSuchMethodException - thrown if the SOAP client does not contain the requested method. TODO(api.arogal): Needs to check parameter types as well as name/return.

invoke

protected Object invoke(SoapCall<T> soapCall)
                 throws Exception
Takes a SoapCall object and invokes the method by reflection.

Parameters:
soapCall - contains the SOAP method, SOAP client, and args to be called
Returns:
the response from the SOAP web service
Throws:
Exception - thrown if calling the operation on the remote service fails


Copyright © 2012. All Rights Reserved.