com.webmethods.caf.wsclient.proxy.impl
Class WSClientDynamicProxy

java.lang.Object
  extended by com.webmethods.caf.wsclient.proxy.impl.WSClientDynamicProxy
All Implemented Interfaces:
IWSClientProxy, InvocationHandler

public class WSClientDynamicProxy
extends Object
implements IWSClientProxy

Dynamic proxy that implements the IWSClientProxy interface and proxies requests for a web service interface, providing services such as session managment via a IWSClientSession instance, as well as web service result caching via a IWSCacheManager.

The web service request is handled by the underlying Glue SOAP stack


Field Summary
protected  AuthCredentials m_authCredentials
           
protected  int m_clientSocketReadTimeout
           
protected  String m_endPointURL
           
protected  List m_failedAuthCallbacks
           
protected  String m_hostURL
           
protected  IWSProxyFactory m_proxyFactory
           
protected  boolean m_reuseSession
           
protected  boolean m_useCache
           
protected  Class m_webServiceClass
           
protected  String m_wsdlURL
           
 
Constructor Summary
WSClientDynamicProxy(IWSProxyFactory proxyFactory, Class clazz, String wsdlURL, String endPoint, boolean useCache, boolean reuseSession, int clientSocketReadTimeout, AuthCredentials authCredentials)
          Primary constructor for creating a new proxy instance for a web service interface stub NOTE: normally this constructor is not called directly, instead a new proxy is obtained via the proxy factory IWSProxyFactory.getProxy()
 
Method Summary
 void addFailedAuthCallback(IFailedAuthCallback callbackObj)
          Register a IFailedAuthCallback listener to be invoked when an authentication failure occurs when invoking a web service
 void flushCache()
          Flush the cache web service results cache associated with this proxy
 AuthCredentials getAuthCredentials()
          Get the AuthCredentials used by this proxy to authenticate web service request.
protected  Throwable getBaseException(Throwable t)
          helper method to unravel InvocationException and WrappedExceptions
protected  Object getBinding(ProxyContext context)
           
 int getClientSocketReadTimeout()
          Get the socket timeout.
protected  Throwable getCompatibleException(Method method, Throwable t)
          Translate an exception into a Throwable that is explicitly declared in the the method's throws clause, or wrapped as a RuntimeException (this avoids a UndeclaredThrowableException)
 String getEndPointURL()
          Get the endpoint that this web service proxy will invoke
 List getFailedAuthListeners()
          Get the list of all registered IFailedAuthCallback listeners
 String getHostURL()
          Get the host partion of the IWSClientProxy.getEndPointURL() }
protected  Set getInternalMethods()
           
 IWSProxyFactory getProxyFactory()
          The factory that instantiated this proxy
 boolean getReuseSession()
          Whether to attempt to recycle an existing IWSClientSession when invoking a web service
 boolean getUseCache()
          Whether invocations will check with the CacheManager
 Class getWebServiceClass()
          Get the portType class that this IWSClientProxy instance is proxying
 String getWsdlURL()
          The WSDL url for this proxy
 Object invoke(Object proxy, Method method, Object[] args)
          Invoke a web service method.
 Object invokeMethod(IWSClientSession session, Method method, Object[] args)
          Directly invoke a web service method.
protected  boolean isNonRetryableException(Throwable throwable)
          Determine if an exception is fatal (connection, transport, or other non-retry types of errors)
 void removeFailedAuthCallback(IFailedAuthCallback callbackObj)
          Remove a specific IFailedAuthCallback object from the list of listeners
 void setReuseSession(boolean reuseCache)
          Specify whether to attempt to recycle an existing IWSClientSession when invoking a web service
 void setUseCache(boolean useCache)
          Set option for the cache manager to cache web service results
protected  Throwable wrapWsClientException(Throwable throwable)
          Wrap the exception if with WsClientException with additional error text (if appropriate)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_proxyFactory

protected IWSProxyFactory m_proxyFactory

m_webServiceClass

protected Class m_webServiceClass

m_wsdlURL

protected String m_wsdlURL

m_endPointURL

protected String m_endPointURL

m_hostURL

protected String m_hostURL

m_useCache

protected boolean m_useCache

m_reuseSession

protected boolean m_reuseSession

m_clientSocketReadTimeout

protected int m_clientSocketReadTimeout

m_authCredentials

protected AuthCredentials m_authCredentials

m_failedAuthCallbacks

protected List m_failedAuthCallbacks
Constructor Detail

WSClientDynamicProxy

public WSClientDynamicProxy(IWSProxyFactory proxyFactory,
                            Class clazz,
                            String wsdlURL,
                            String endPoint,
                            boolean useCache,
                            boolean reuseSession,
                            int clientSocketReadTimeout,
                            AuthCredentials authCredentials)
Primary constructor for creating a new proxy instance for a web service interface stub NOTE: normally this constructor is not called directly, instead a new proxy is obtained via the proxy factory IWSProxyFactory.getProxy()

Parameters:
proxyFactory - IWSProxyFactory the proxy factory
clazz - web service interface to proxy
wsdlURL - URL of the web service WSDL file
endPoint - The endpoint URL of the web service
useCache - enable/disable web service result caching for this proxy
reuseSession - true to enable/disable session reuse for this proxy
clientSocketReadTimeout - the web service timeout in milliseconds
authCredentials - AuthCredentials to use when authenticating the web service request. If null, the AuthCredentials of the WSProxyFactory will be used.
Method Detail

invokeMethod

public Object invokeMethod(IWSClientSession session,
                           Method method,
                           Object[] args)
                    throws Throwable
Directly invoke a web service method. Note: the normal use case is to invoke the invoke() method, which includes authentication retries and result caching

Parameters:
session - IWSClientSession instance to invoke the web service through
method - the Method on the web service interface to invoke
args - the web service method arguments as an Object[]
Returns:
the return value of the web service request
Throws:
Throwable

invoke

public Object invoke(Object proxy,
                     Method method,
                     Object[] args)
              throws Throwable
Invoke a web service method. When any method on the web service interface is invoked, it is chained this this invoke() method (that is the nature of a dynamic proxy, @see InvocationHandler)

Specified by:
invoke in interface InvocationHandler
Parameters:
proxy - IWSClientSession instance to invoke the web service through
method - the Method on the web service interface to invoke
args - the web service method arguments as an Object[]
Returns:
the return value of the web service request
Throws:
Throwable

getProxyFactory

public IWSProxyFactory getProxyFactory()
Description copied from interface: IWSClientProxy
The factory that instantiated this proxy

Specified by:
getProxyFactory in interface IWSClientProxy
Returns:
the IWSProxyFactory that created this proxy instance

getEndPointURL

public String getEndPointURL()
Description copied from interface: IWSClientProxy
Get the endpoint that this web service proxy will invoke

Specified by:
getEndPointURL in interface IWSClientProxy
Returns:
the endpoint URL as string

getHostURL

public String getHostURL()
Description copied from interface: IWSClientProxy
Get the host partion of the IWSClientProxy.getEndPointURL() }

Specified by:
getHostURL in interface IWSClientProxy
Returns:
the host name as string

getWsdlURL

public String getWsdlURL()
Description copied from interface: IWSClientProxy
The WSDL url for this proxy

Specified by:
getWsdlURL in interface IWSClientProxy
Returns:
the WSDL URL as a string

getUseCache

public boolean getUseCache()
Description copied from interface: IWSClientProxy
Whether invocations will check with the CacheManager

Specified by:
getUseCache in interface IWSClientProxy
Returns:
true if the cache manager is configured to use caching

setUseCache

public void setUseCache(boolean useCache)
Description copied from interface: IWSClientProxy
Set option for the cache manager to cache web service results

Specified by:
setUseCache in interface IWSClientProxy
Parameters:
useCache - true to enable caching, false to disable caching

getReuseSession

public boolean getReuseSession()
Description copied from interface: IWSClientProxy
Whether to attempt to recycle an existing IWSClientSession when invoking a web service

Specified by:
getReuseSession in interface IWSClientProxy
Returns:
boolean true if session reuse is enabled, false if session reuse is disabled

setReuseSession

public void setReuseSession(boolean reuseCache)
Description copied from interface: IWSClientProxy
Specify whether to attempt to recycle an existing IWSClientSession when invoking a web service

Specified by:
setReuseSession in interface IWSClientProxy
Parameters:
reuseCache - true to enable session reuse, false to create a new session on each service invocation

getAuthCredentials

public AuthCredentials getAuthCredentials()
Description copied from interface: IWSClientProxy
Get the AuthCredentials used by this proxy to authenticate web service request. Specifying null credentials will use global credentials set on the @WSClient instance.

Specified by:
getAuthCredentials in interface IWSClientProxy
Returns:
the AuthCredentials for this proxy

getWebServiceClass

public Class getWebServiceClass()
Description copied from interface: IWSClientProxy
Get the portType class that this IWSClientProxy instance is proxying

Specified by:
getWebServiceClass in interface IWSClientProxy
Returns:
the portType as Class

getClientSocketReadTimeout

public int getClientSocketReadTimeout()
Description copied from interface: IWSClientProxy
Get the socket timeout. This is the number of milliseconds the web service request will wait before it gives up waiting for a response from the web service provider.

Specified by:
getClientSocketReadTimeout in interface IWSClientProxy
Returns:
the socket timeout value in milliseconds

getBinding

protected Object getBinding(ProxyContext context)

addFailedAuthCallback

public void addFailedAuthCallback(IFailedAuthCallback callbackObj)
Description copied from interface: IWSClientProxy
Register a IFailedAuthCallback listener to be invoked when an authentication failure occurs when invoking a web service

Specified by:
addFailedAuthCallback in interface IWSClientProxy
Parameters:
callbackObj - - the IFailedAuthCallback object instance

removeFailedAuthCallback

public void removeFailedAuthCallback(IFailedAuthCallback callbackObj)
Description copied from interface: IWSClientProxy
Remove a specific IFailedAuthCallback object from the list of listeners

Specified by:
removeFailedAuthCallback in interface IWSClientProxy
Parameters:
callbackObj - - the IFailedAuthCallback object instance to remove

getFailedAuthListeners

public List getFailedAuthListeners()
Description copied from interface: IWSClientProxy
Get the list of all registered IFailedAuthCallback listeners

Specified by:
getFailedAuthListeners in interface IWSClientProxy
Returns:
a List of IFailedAuthCallback instances

getInternalMethods

protected Set getInternalMethods()

getBaseException

protected Throwable getBaseException(Throwable t)
helper method to unravel InvocationException and WrappedExceptions


getCompatibleException

protected Throwable getCompatibleException(Method method,
                                           Throwable t)
Translate an exception into a Throwable that is explicitly declared in the the method's throws clause, or wrapped as a RuntimeException (this avoids a UndeclaredThrowableException)

Parameters:
method - - the invoked method
t - - the exception thrown by the method
Returns:
a Throwable that will not result in a UndeclaredThrowableException NOTE: this code is lifted from Glue's Proxy.java

flushCache

public void flushCache()
Description copied from interface: IWSClientProxy
Flush the cache web service results cache associated with this proxy

Specified by:
flushCache in interface IWSClientProxy

wrapWsClientException

protected Throwable wrapWsClientException(Throwable throwable)
Wrap the exception if with WsClientException with additional error text (if appropriate)

Parameters:
throwable - exception thrown by the web service invocation
Returns:
a new WSClientException wrapping the web service exception

isNonRetryableException

protected boolean isNonRetryableException(Throwable throwable)
Determine if an exception is fatal (connection, transport, or other non-retry types of errors)

Parameters:
throwable - the Exception to examine
Returns:
true if the error is fatal and we shouldn't retry the invocation