org.codehaus.xfire.spring.remoting
Class XFireClientFactoryBean

java.lang.Object
  extended by org.codehaus.xfire.spring.remoting.XFireClientFactoryBean
All Implemented Interfaces:
org.springframework.beans.factory.FactoryBean, org.springframework.beans.factory.InitializingBean

public class XFireClientFactoryBean
extends java.lang.Object
implements org.springframework.beans.factory.FactoryBean, org.springframework.beans.factory.InitializingBean

Factory bean to easily create XFire clients via Spring, if the service's Java interface is available. Naming of properties is done to be the same as org.springframework.remoting.jaxrpc.JaxRpcPortProxyFactoryBean.
The only mandatory properties to set before using this factory are: setServiceClass(Class) and setWsdlDocumentUrl(String).
By default this factory bean creates a service endpoint using an instance of ObjectServiceFactory. Another one can be configured using setServiceFactory(ServiceFactory)
serviceName and namespaceUri can be derived from the content of the WSDL document (if the document only contains one service), but unfortunately that does not (yet) work if username/password needs to be supplied to get at the WSDL.

Author:
Fried Hoeben

Constructor Summary
XFireClientFactoryBean()
           
 
Method Summary
 void afterPropertiesSet()
           
 javax.xml.namespace.QName getEndpoint()
           
 java.util.List getFaultHandlers()
           
 java.util.List getInHandlers()
           
 boolean getLookupServiceOnStartup()
          Gets whether to look up the XFire service on startup.
 java.lang.String getNamespaceUri()
          Gets the default namespace for the service.
 java.lang.Object getObject()
           
 java.lang.Class getObjectType()
           
 java.util.List getOutHandlers()
           
 java.lang.String getPassword()
          Gets the password for HTTP basic authentication.
 java.util.Map getProperties()
          The properties that will be set on the Client.
 java.lang.Class getServiceClass()
           
 org.codehaus.xfire.service.ServiceFactory getServiceFactory()
           
 java.lang.Class getServiceInterface()
           
 java.lang.String getServiceName()
          Gets the name of the service.
 java.lang.String getUrl()
           
 java.lang.String getUsername()
          Gets the username for HTTP basic authentication.
protected  javax.wsdl.Definition getWSDLDefinition()
          Gets the Definition contained in the WSDL document (does not currently support reading WSDL that is protected with authentication).
 java.lang.String getWsdlDocumentUrl()
           
 boolean isSingleton()
           
 void setEndpoint(javax.xml.namespace.QName name)
          Set the name of the Endpoint/Port in the WSDL to use with the Client.
 void setFaultHandlers(java.util.List faultHandlers)
           
 void setInHandlers(java.util.List inHandlers)
           
 void setLookupServiceOnStartup(boolean lookupServiceOnStartup)
          Sets whether to look up the XFire service on startup.
 void setNamespaceUri(java.lang.String namespace)
          Sets the default namespace for the service.
 void setOutHandlers(java.util.List outHandlers)
           
 void setPassword(java.lang.String password)
          Sets the password for HTTP basic authentication.
 void setProperties(java.util.Map properties)
          Set the properties for the Client.
 void setServiceClass(java.lang.Class serviceClass)
           
 void setServiceFactory(org.codehaus.xfire.service.ServiceFactory factory)
          Sets the service factory that will be used to create a client.
 void setServiceInterface(java.lang.Class serviceClass)
           
 void setServiceName(java.lang.String serviceName)
          Sets the name of the service to access.
 void setUrl(java.lang.String _url)
          Set the URL the Client is to invoke.
 void setUsername(java.lang.String username)
          Sets the username for HTTP basic authentication.
 void setWsdlDocumentUrl(java.lang.String wsdlUrl)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

XFireClientFactoryBean

public XFireClientFactoryBean()
Method Detail

getObject

public java.lang.Object getObject()
                           throws java.lang.Exception
Specified by:
getObject in interface org.springframework.beans.factory.FactoryBean
Throws:
java.lang.Exception

getObjectType

public java.lang.Class getObjectType()
Specified by:
getObjectType in interface org.springframework.beans.factory.FactoryBean

isSingleton

public boolean isSingleton()
Specified by:
isSingleton in interface org.springframework.beans.factory.FactoryBean

afterPropertiesSet

public void afterPropertiesSet()
                        throws java.lang.Exception
Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
Throws:
java.lang.Exception

getServiceFactory

public org.codehaus.xfire.service.ServiceFactory getServiceFactory()
Returns:
the service factory that this factory will use

setServiceFactory

public void setServiceFactory(org.codehaus.xfire.service.ServiceFactory factory)
Sets the service factory that will be used to create a client. If this method is never called an instance of ObjectServiceFactory will be used.

Parameters:
factory - service factory this factory should use to create a client

getServiceClass

public java.lang.Class getServiceClass()
Returns:
Returns the service's interface.

setServiceInterface

public void setServiceInterface(java.lang.Class serviceClass)
Parameters:
serviceClass - The interface implemented by the service called via the proxy.

getServiceInterface

public java.lang.Class getServiceInterface()
Returns:
Returns the service's interface.

setServiceClass

public void setServiceClass(java.lang.Class serviceClass)
Parameters:
serviceClass - The interface implemented by the service called via the proxy.

getWsdlDocumentUrl

public java.lang.String getWsdlDocumentUrl()
Returns:
Returns the URL where the WSDL to this service can be found.

setWsdlDocumentUrl

public void setWsdlDocumentUrl(java.lang.String wsdlUrl)
Parameters:
wsdlUrl - The URL where the WSDL to this service can be found.

getServiceName

public java.lang.String getServiceName()
Gets the name of the service. If null the name will be looked up from the WSDL, or generated from the interface name by XFire.

Returns:
Returns the serviceName.

setServiceName

public void setServiceName(java.lang.String serviceName)
Sets the name of the service to access. If left null the name will be looked up from the WSDL, or generated from the interface name by XFire.

Parameters:
serviceName - The service name to set.

getNamespaceUri

public java.lang.String getNamespaceUri()
Gets the default namespace for the service. If null the namespace will be looked up from the WSDL, or generated from the interface package by XFire.

Returns:
Returns the namespace for the service.

setNamespaceUri

public void setNamespaceUri(java.lang.String namespace)
Sets the default namespace for the service. If left null the namespace will be looked up from the WSDL, or generated from the interface package by XFire.

Parameters:
namespace - The namespace to set.

getLookupServiceOnStartup

public boolean getLookupServiceOnStartup()
Gets whether to look up the XFire service on startup.

Returns:
whether to look up the service on startup.

setLookupServiceOnStartup

public void setLookupServiceOnStartup(boolean lookupServiceOnStartup)
Sets whether to look up the XFire service on startup. Default is true.

Can be set to false to allow for late start of the target server. In this case, the XFire service client proxy will be created on first access. This does add some overhead (on each call) since synchronization is used to ensure only one client proxy is ever created, furthermore errors in the WSDL document URL are not detected until the first call.

Parameters:
lookupServiceOnStartup - whether to look up the service on startup.

getUsername

public java.lang.String getUsername()
Gets the username for HTTP basic authentication.

Returns:
Returns the username to send.

setUsername

public void setUsername(java.lang.String username)
Sets the username for HTTP basic authentication.

Parameters:
username - The username to set.

getPassword

public java.lang.String getPassword()
Gets the password for HTTP basic authentication.

Returns:
Returns the password to send.

setPassword

public void setPassword(java.lang.String password)
Sets the password for HTTP basic authentication.

Parameters:
password - The password to set.

getProperties

public java.util.Map getProperties()
The properties that will be set on the Client.


setProperties

public void setProperties(java.util.Map properties)
Set the properties for the Client.


getEndpoint

public javax.xml.namespace.QName getEndpoint()

setEndpoint

public void setEndpoint(javax.xml.namespace.QName name)
Set the name of the Endpoint/Port in the WSDL to use with the Client.

Parameters:
name -

getUrl

public java.lang.String getUrl()

setUrl

public void setUrl(java.lang.String _url)
Set the URL the Client is to invoke. If this is not supplied, the one from the WSDL will be used instead.


getFaultHandlers

public java.util.List getFaultHandlers()

setFaultHandlers

public void setFaultHandlers(java.util.List faultHandlers)

getInHandlers

public java.util.List getInHandlers()

setInHandlers

public void setInHandlers(java.util.List inHandlers)

getOutHandlers

public java.util.List getOutHandlers()

setOutHandlers

public void setOutHandlers(java.util.List outHandlers)

getWSDLDefinition

protected javax.wsdl.Definition getWSDLDefinition()
                                           throws java.lang.Exception
Gets the Definition contained in the WSDL document (does not currently support reading WSDL that is protected with authentication).

Returns:
Definition describing the service(s)
Throws:
java.lang.Exception - if the definition could not be read

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2004-2008. All Rights Reserved.