de.fzj.unicore.wsrflite.xmlbeans.client
Class BaseWSRFClient

java.lang.Object
  extended by de.fzj.unicore.wsrflite.xmlbeans.client.BaseWSRFClient
Direct Known Subclasses:
AdminServiceClient, NotificationClient

public class BaseWSRFClient
extends Object

A basic WSRF client. Allows to access remote (wsrf) services

Author:
schuller

Field Summary
protected  org.w3.x2005.x08.addressing.EndpointReferenceType epr
           
protected static org.apache.log4j.Logger logger
           
protected  XFireClientFactory proxyMaker
           
protected  ReliableProxy.RetryDecider retryDecider
           
protected  ISecurityProperties securityProperties
           
protected  String url
           
 
Constructor Summary
BaseWSRFClient(org.w3.x2005.x08.addressing.EndpointReferenceType epr)
          create a Client to connect to service at 'epr' using the transport 'url'
BaseWSRFClient(String endpointUrl, org.w3.x2005.x08.addressing.EndpointReferenceType epr)
          create a Client to connect to service at 'epr' using the transport 'url'
BaseWSRFClient(String endpointUrl, org.w3.x2005.x08.addressing.EndpointReferenceType epr, ISecurityProperties sec)
          create a new wsrf client instance
BaseWSRFClient(String endpointUrl, org.w3.x2005.x08.addressing.EndpointReferenceType epr, ISecurityProperties sec, XFireClientFactory clientFactory)
          create a new wsrf client instance
 
Method Summary
 boolean checkConnection()
          check the connection to the service
 boolean checkConnection(int timeout)
          check the connection to the WSRF service by calling getCurrentTime().
 void destroy()
          destroy a WS-Resource
 String getConnectionStatus()
          check the connection status to the service
 Calendar getCurrentTime()
          get the current time of a WS-Resource
 org.w3.x2005.x08.addressing.EndpointReferenceType getEPR()
          get the EPR this client points to
 ResourceLifetime getLT()
           
 Map<QName,org.apache.xmlbeans.XmlObject[]> getMultipleResourceProperties(QName... names)
          get multiple resource properties
 String getResourceProperty(QName rpQname)
          retrieve a resource property
This is returned as a String, so you can easily build an XMLBeans object from it
 String getResourcePropertyDocument()
          get a string containing all resourceproperties
 org.oasisOpen.docs.wsrf.rp2.GetResourcePropertyDocumentResponseDocument GetResourcePropertyDocument()
          get a document containing all resourceproperties
 ResourceProperties getRP()
          lazily creates the proxy for the ResourceProperties interface
 ISecurityProperties getSecurityProperties()
          get the security properties used by this client
 Calendar getTerminationTime()
          get the termination time of a WS-Resource
 long getUpdateInterval()
          retrieves the minimum time between subsequent remote GetResourcePropertyDocument() calls.
 String getUrl()
          get the URL this client talks to
<T> T
makeProxy(Class<T> iFace)
          convenience method to create a proxy object for the given interface
 org.oasisOpen.docs.wsrf.rp2.QueryResourcePropertiesResponseDocument queryResourceProperties(String xpath)
          perform an xpath query on the resourceproperties
 void setConnectionTimeout(int timeout)
          set the connection timeout for this client.
protected  void setConnectionTimeout(Object proxy, int timeout)
          sets the timeout on the given proxy object
 void setRetryHandler(ReliableProxy.RetryDecider retry)
          set the ReliableProxy.RetryDecider that decides whether a failed ws call shall be retried
 Calendar setTerminationTime(Calendar newTerminationTime)
          set the termination time of a WS-Resource
 void setUpdateInterval(long updateInterval)
          Sets the update interval, i.e. the minimum time between subsequent remote GetResourcePropertyDocument() calls.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected static final org.apache.log4j.Logger logger

epr

protected final org.w3.x2005.x08.addressing.EndpointReferenceType epr

url

protected final String url

securityProperties

protected ISecurityProperties securityProperties

proxyMaker

protected final XFireClientFactory proxyMaker

retryDecider

protected ReliableProxy.RetryDecider retryDecider
Constructor Detail

BaseWSRFClient

public BaseWSRFClient(org.w3.x2005.x08.addressing.EndpointReferenceType epr)
               throws Exception
create a Client to connect to service at 'epr' using the transport 'url'

Parameters:
epr -
Throws:
Exception

BaseWSRFClient

public BaseWSRFClient(String endpointUrl,
                      org.w3.x2005.x08.addressing.EndpointReferenceType epr)
               throws Exception
create a Client to connect to service at 'epr' using the transport 'url'

Parameters:
endpointUrl -
epr -
Throws:
Exception

BaseWSRFClient

public BaseWSRFClient(String endpointUrl,
                      org.w3.x2005.x08.addressing.EndpointReferenceType epr,
                      ISecurityProperties sec)
               throws Exception
create a new wsrf client instance

Parameters:
endpointUrl - the url to connect to
epr - the service EPR for WS-Addressing
sec - SecurityProperties to use
Throws:
Exception
See Also:
ISecurityProperties

BaseWSRFClient

public BaseWSRFClient(String endpointUrl,
                      org.w3.x2005.x08.addressing.EndpointReferenceType epr,
                      ISecurityProperties sec,
                      XFireClientFactory clientFactory)
               throws Exception
create a new wsrf client instance

Parameters:
endpointUrl - the url to connect to
epr - the service EPR for WS-Addressing
sec - SecurityProperties to use
clientFactory - the client factory to use
Throws:
Exception
See Also:
ISecurityProperties
Method Detail

getEPR

public org.w3.x2005.x08.addressing.EndpointReferenceType getEPR()
get the EPR this client points to

Returns:
epr

getUrl

public String getUrl()
get the URL this client talks to

Returns:
url

getSecurityProperties

public ISecurityProperties getSecurityProperties()
get the security properties used by this client


makeProxy

public <T> T makeProxy(Class<T> iFace)
            throws Exception
convenience method to create a proxy object for the given interface

Parameters:
iFace -
Returns:
Throws:
Exception

getResourceProperty

public String getResourceProperty(QName rpQname)
                           throws BaseFault,
                                  InvalidResourcePropertyQNameFault,
                                  ResourceUnavailableFault,
                                  ResourceUnknownFault,
                                  ClientException
retrieve a resource property
This is returned as a String, so you can easily build an XMLBeans object from it

Parameters:
in -
Returns:
the resource property as a String
Throws:
BaseFault
InvalidResourcePropertyQNameFault
ResourceUnavailableFault
ResourceUnknownFault
ClientException

destroy

public void destroy()
             throws BaseFault,
                    ResourceUnavailableFault,
                    ResourceUnknownFault,
                    ResourceNotDestroyedFault,
                    ClientException
destroy a WS-Resource

Throws:
BaseFault
ResourceUnavailableFault
ResourceUnknownFault
ResourceNotDestroyedFault
ClientException

setTerminationTime

public Calendar setTerminationTime(Calendar newTerminationTime)
                            throws BaseFault,
                                   UnableToSetTerminationTimeFault,
                                   TerminationTimeChangeRejectedFault,
                                   ResourceUnavailableFault,
                                   ResourceUnknownFault,
                                   ClientException
set the termination time of a WS-Resource

Parameters:
newTerminationTime -
Returns:
the new termination time
Throws:
Exception
BaseFault
UnableToSetTerminationTimeFault
TerminationTimeChangeRejectedFault
ResourceUnavailableFault
ResourceUnknownFault
ClientException

getTerminationTime

public Calendar getTerminationTime()
                            throws BaseFault,
                                   InvalidResourcePropertyQNameFault,
                                   ResourceUnavailableFault,
                                   ResourceUnknownFault,
                                   ClientException
get the termination time of a WS-Resource

Returns:
the termination time, which can be null if it is not available or set on the server
Throws:
Exception
BaseFault
InvalidResourcePropertyQNameFault
ResourceUnavailableFault
ResourceUnknownFault
ClientException

getCurrentTime

public Calendar getCurrentTime()
                        throws BaseFault,
                               ResourceUnavailableFault,
                               ResourceUnknownFault,
                               ClientException
get the current time of a WS-Resource

Parameters:
newTerminationTime -
Returns:
the new termination time
Throws:
Exception
BaseFault
ResourceUnavailableFault
ResourceUnknownFault
ClientException

getResourcePropertyDocument

public String getResourcePropertyDocument()
                                   throws BaseFault,
                                          ResourceUnknownFault,
                                          ResourceUnavailableFault,
                                          ClientException
get a string containing all resourceproperties

Returns:
Throws:
Exception
BaseFault
ResourceUnknownFault
ResourceUnavailableFault
ClientException

GetResourcePropertyDocument

public org.oasisOpen.docs.wsrf.rp2.GetResourcePropertyDocumentResponseDocument GetResourcePropertyDocument()
                                                                                                    throws BaseFault,
                                                                                                           ResourceUnknownFault,
                                                                                                           ResourceUnavailableFault,
                                                                                                           ClientException
get a document containing all resourceproperties

Returns:
Throws:
Exception
BaseFault
ResourceUnknownFault
ResourceUnavailableFault
ClientException

queryResourceProperties

public org.oasisOpen.docs.wsrf.rp2.QueryResourcePropertiesResponseDocument queryResourceProperties(String xpath)
                                                                                            throws BaseFault,
                                                                                                   ResourceUnknownFault,
                                                                                                   ResourceUnavailableFault,
                                                                                                   ClientException
perform an xpath query on the resourceproperties

Throws:
BaseFault
ResourceUnknownFault
ResourceUnavailableFault
ClientException

getMultipleResourceProperties

public Map<QName,org.apache.xmlbeans.XmlObject[]> getMultipleResourceProperties(QName... names)
                                                                         throws BaseFault,
                                                                                ResourceUnknownFault,
                                                                                ResourceUnavailableFault,
                                                                                ClientException
get multiple resource properties

Parameters:
names - - the QNames of the RPs to get
Returns:
a Map mapping the QName to the RP Array
Throws:
Exception
BaseFault
ResourceUnknownFault
ResourceUnavailableFault
ClientException

getLT

public ResourceLifetime getLT()
                       throws ClientException
Throws:
ClientException

getRP

public ResourceProperties getRP()
                         throws ClientException
lazily creates the proxy for the ResourceProperties interface

Returns:
RP proxy
Throws:
RuntimeException - - wraps any exception as a runtime exception
ClientException

setRetryHandler

public void setRetryHandler(ReliableProxy.RetryDecider retry)
set the ReliableProxy.RetryDecider that decides whether a failed ws call shall be retried

Parameters:
retry - - the ReliableProxy.RetryDecider

getUpdateInterval

public long getUpdateInterval()
retrieves the minimum time between subsequent remote GetResourcePropertyDocument() calls. (default: 500 ms)
Between calls, the resourceproperty document is cached


setUpdateInterval

public void setUpdateInterval(long updateInterval)
Sets the update interval, i.e. the minimum time between subsequent remote GetResourcePropertyDocument() calls. Between calls, the resourceproperty document is cached.
To disble the cache, set to a negative value

Parameters:
updateInterval -
See Also:
getUpdateInterval()

getConnectionStatus

public String getConnectionStatus()
                           throws ClientException
check the connection status to the service

Returns:
a human readable status message
Throws:
ClientException

checkConnection

public boolean checkConnection()
                        throws ClientException
check the connection to the service

Returns:
true if service can be accessed
Throws:
ClientException

checkConnection

public boolean checkConnection(int timeout)
                        throws ClientException
check the connection to the WSRF service by calling getCurrentTime(). If the service does not reply within the given timeout, returns false

Parameters:
timeout - - connection timeout in milliseconds
Returns:
false in case of problems contacting the remote service
Throws:
ClientException

setConnectionTimeout

public void setConnectionTimeout(int timeout)
                          throws ClientException
set the connection timeout for this client.
In subclasses, you should override this method according to the following pattern. public void setConnectionTimeout(int timeout){ super.setConnectionTimeout(timeout): setConnectionTimeout(yourProxy, timeout); } where yourProxy is the proxy object for the
The default implementation sets the timeout for resource lifetime and resource property calls

Parameters:
timeout - - timeout in millis
Throws:
ClientException

setConnectionTimeout

protected void setConnectionTimeout(Object proxy,
                                    int timeout)
sets the timeout on the given proxy object

Parameters:
proxy - - the web service proxy
timeout - - the timeout in millis


Copyright © 2010. All Rights Reserved.