org.codehaus.xfire.service.binding
Class ObjectServiceFactory

java.lang.Object
  extended by org.codehaus.xfire.service.binding.ObjectServiceFactory
All Implemented Interfaces:
ServiceFactory

public class ObjectServiceFactory
extends java.lang.Object
implements ServiceFactory

Creates Services from java objects. This class is meant to be easily overridable so you can customize how your services are created.

Author:
Dan Diephouse, Arjen Poutsma

Field Summary
static java.lang.String CREATE_DEFAULT_BINDINGS
           
static java.lang.String PORT_NAME
           
static java.lang.String PORT_TYPE
           
static java.lang.String SCHEMAS
           
static java.lang.String SCOPE
           
static java.lang.String SOAP11_TRANSPORTS
           
static java.lang.String SOAP12_TRANSPORTS
           
static java.lang.String STYLE
           
static java.lang.String USE
           
 
Constructor Summary
ObjectServiceFactory()
          Initializes a new instance of the ObjectServiceFactory.
ObjectServiceFactory(BindingProvider bp)
           
ObjectServiceFactory(TransportManager transportManager)
          Initializes a new instance of the ObjectServiceFactory.
ObjectServiceFactory(TransportManager transportManager, BindingProvider provider)
          Initializes a new instance of the ObjectServiceFactory with the given transport manager and type mapping registry.
 
Method Summary
protected  FaultInfo addFault(Service service, OperationInfo op, java.lang.Class exClass)
           
 void addIgnoredMethods(java.lang.String className)
          Ignore the specified class' declared methods.
protected  OperationInfo addOperation(Service endpoint, java.lang.reflect.Method method, java.lang.String style)
           
 void addSoap11Transport(java.lang.String id)
           
 void addSoap12Transport(java.lang.String id)
           
protected  void configureHeaders(Service service, OperationInfo op, Binding b)
           
 Service create(java.lang.Class clazz)
          Creates a service from the specified class.
 Service create(java.lang.Class clazz, java.util.Map properties)
          Creates a service from the specified class.
 Service create(java.lang.Class clazz, javax.xml.namespace.QName name, javax.wsdl.Definition def, java.util.Map properties)
          Create a service from a WSDL file.
 Service create(java.lang.Class clazz, javax.xml.namespace.QName name, javax.wsdl.Definition def, java.util.Map properties, WSDLWriter writer)
           
 Service create(java.lang.Class clazz, javax.xml.namespace.QName name, java.net.URL wsdlUrl, java.util.Map properties)
          Creates a service via create(Class).
 Service create(java.lang.Class clazz, java.lang.String name, java.lang.String namespace, java.util.Map properties)
          Creates a service from the specified class, soap version, style and use.
protected  void createBindingOperation(Service service, AbstractSoapBinding binding, OperationInfo op)
           
protected  void createBindings(Service service, java.util.Collection s11, java.util.Collection s12)
           
protected  void createDocumentationProvider(ServiceInfo serviceInfo)
           
 Endpoint createEndpoint(Service service, javax.xml.namespace.QName name, java.lang.String url, Binding binding)
          Creates an endpoint for a service.
protected  javax.xml.namespace.QName createInputMessageName(OperationInfo op)
           
protected  javax.xml.namespace.QName createOutputMessageName(OperationInfo op)
           
 Soap11Binding createSoap11Binding(Service service, javax.xml.namespace.QName bindingName, java.lang.String bindingId)
          Create a SOAP 1.1 binding for the specified binding id.
 Soap12Binding createSoap12Binding(Service service, javax.xml.namespace.QName bindingName, java.lang.String bindingId)
          Create a SOAP 1.2 binding for the specified binding id.
protected  void createSoapBinding(Service service, AbstractSoapBinding binding)
           
protected  java.lang.String getAction(OperationInfo op)
           
 BindingProvider getBindingProvider()
           
 java.util.Map getCustomTypesMapping()
           
protected  DocumentationProvider getDocumentationProvider()
           
protected  javax.xml.namespace.QName getFaultName(Service service, OperationInfo o, java.lang.Class exClass, java.lang.Class beanClass)
           
 java.util.Set getIgnoredClasses()
           
protected  javax.xml.namespace.QName getInParameterName(Service service, OperationInfo op, java.lang.reflect.Method method, int paramNumber, boolean doc)
           
protected  java.lang.String getMEP(java.lang.reflect.Method method)
           
protected  java.lang.String getOperationName(ServiceInfo service, java.lang.reflect.Method method)
          Creates a name for the operation from the method name.
protected  javax.xml.namespace.QName getOutParameterName(Service service, OperationInfo op, java.lang.reflect.Method method, int paramNumber, boolean doc)
           
protected  MessageSerializer getSerializer(AbstractSoapBinding binding)
           
 java.util.List getServiceConfigurations()
           
 java.util.Collection getSoap11Transports()
          Get a list of Transports which are enabled over SOAP 1.1.
 java.util.Collection getSoap12Transports()
          Get a list of Transports which are enabled over SOAP 1.2.
 java.lang.String getStyle()
           
protected  java.lang.String getTargetNamespace(java.lang.Class clazz)
           
 TransportManager getTransportManager()
           
 java.lang.String getUse()
           
 WSDLBuilderFactory getWsdlBuilderFactory()
           
protected  boolean hasOutMessage(java.lang.String mep)
           
protected  void initializeFaults(Service service, OperationInfo op)
           
protected  void initializeOperations(Service endpoint, java.lang.String style)
           
protected  boolean isAsync(java.lang.reflect.Method method)
           
 boolean isBindingCreationEnabled()
           
 boolean isCustomFaultsEnabled()
           
protected  boolean isFaultInfoClass(java.lang.Class exClass)
           
protected  boolean isHeader(java.lang.reflect.Method method, int j)
           
protected  boolean isInParam(java.lang.reflect.Method method, int j)
           
protected  boolean isOutParam(java.lang.reflect.Method method, int j)
           
protected  boolean isValidMethod(java.lang.reflect.Method method)
           
 boolean isVoidOneWay()
           
protected  java.lang.String makeServiceNameFromClassName(java.lang.Class clazz)
           
protected  void registerHandlers(Service service)
           
 void setBindingCreationEnabled(boolean bindingCreationEnabled)
           
 void setBindingProvider(BindingProvider bindingProvider)
           
 void setCustomFaultsEnabled(boolean customFaultsEnabled)
           
 void setCustomTypesMapping(java.util.Map customTypesMapping)
           
protected  void setDocumentationProvider(DocumentationProvider documentationProvider)
           
 void setServiceConfigurations(java.util.List serviceConfigurations)
           
 void setStyle(java.lang.String style)
           
 void setTransportManager(TransportManager transportManager)
           
 void setUse(java.lang.String use)
           
 void setVoidOneWay(boolean voidOneWay)
           
 void setWsdlBuilderFactory(WSDLBuilderFactory wsdlBuilderFactory)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PORT_TYPE

public static final java.lang.String PORT_TYPE
See Also:
Constant Field Values

PORT_NAME

public static final java.lang.String PORT_NAME
See Also:
Constant Field Values

STYLE

public static final java.lang.String STYLE
See Also:
Constant Field Values

USE

public static final java.lang.String USE
See Also:
Constant Field Values

CREATE_DEFAULT_BINDINGS

public static final java.lang.String CREATE_DEFAULT_BINDINGS
See Also:
Constant Field Values

SOAP11_TRANSPORTS

public static final java.lang.String SOAP11_TRANSPORTS
See Also:
Constant Field Values

SOAP12_TRANSPORTS

public static final java.lang.String SOAP12_TRANSPORTS
See Also:
Constant Field Values

SCOPE

public static final java.lang.String SCOPE
See Also:
Constant Field Values

SCHEMAS

public static final java.lang.String SCHEMAS
See Also:
Constant Field Values
Constructor Detail

ObjectServiceFactory

public ObjectServiceFactory()
Initializes a new instance of the ObjectServiceFactory. Uses the XFireFactory to obtain an instance of the TransportManager.


ObjectServiceFactory

public ObjectServiceFactory(TransportManager transportManager,
                            BindingProvider provider)
Initializes a new instance of the ObjectServiceFactory with the given transport manager and type mapping registry.

Parameters:
transportManager - the transport manager
provider - the binding provider

ObjectServiceFactory

public ObjectServiceFactory(TransportManager transportManager)
Initializes a new instance of the ObjectServiceFactory.


ObjectServiceFactory

public ObjectServiceFactory(BindingProvider bp)
Method Detail

getCustomTypesMapping

public java.util.Map getCustomTypesMapping()

setCustomTypesMapping

public void setCustomTypesMapping(java.util.Map customTypesMapping)

getBindingProvider

public BindingProvider getBindingProvider()

create

public Service create(java.lang.Class clazz,
                      javax.xml.namespace.QName name,
                      java.net.URL wsdlUrl,
                      java.util.Map properties)
Creates a service via create(Class). It then configures the bindings and endpoints on the service via the WSDL.

Specified by:
create in interface ServiceFactory
Parameters:
clazz - The service class for the wsdl.
wsdlUrl - The WSDL URL.
Returns:

create

public Service create(java.lang.Class clazz,
                      javax.xml.namespace.QName name,
                      javax.wsdl.Definition def,
                      java.util.Map properties)
Description copied from interface: ServiceFactory
Create a service from a WSDL file.

Specified by:
create in interface ServiceFactory
Parameters:
clazz - The service class for the wsdl.
def - The WSDL definition.
Returns:

create

public Service create(java.lang.Class clazz,
                      javax.xml.namespace.QName name,
                      javax.wsdl.Definition def,
                      java.util.Map properties,
                      WSDLWriter writer)

configureHeaders

protected void configureHeaders(Service service,
                                OperationInfo op,
                                Binding b)

create

public Service create(java.lang.Class clazz)
Creates a service from the specified class. The service name will be the unqualified class name. The namespace will be based on the package. The service will use soap version 1.1, wrapped style, and literal use.

Specified by:
create in interface ServiceFactory
Parameters:
clazz - The service class used to populate the operations and parameters. If the class is an interface, then the implementation class that implements that interface must be set via AbstractContext.setProperty(String, Object) with the property key being ObjectInvoker.SERVICE_IMPL_CLASS
Returns:
The service.

create

public Service create(java.lang.Class clazz,
                      java.util.Map properties)
Creates a service from the specified class. The service name will be the unqualified class name. The namespace will be based on the package. The service will use soap version 1.1, wrapped style, and literal use.

Specified by:
create in interface ServiceFactory
Parameters:
clazz - The service class used to populate the operations and parameters. If the class is an interface, then the implementation class that implements that interface must be set via AbstractContext.setProperty(String, Object) with the property key being ObjectInvoker.SERVICE_IMPL_CLASS
properties - Properties to set on the service and use in construction.
Returns:
The service.

makeServiceNameFromClassName

protected java.lang.String makeServiceNameFromClassName(java.lang.Class clazz)

create

public Service create(java.lang.Class clazz,
                      java.lang.String name,
                      java.lang.String namespace,
                      java.util.Map properties)
Creates a service from the specified class, soap version, style and use. The returned service will have a name based on the class name, and a namespace based on the class package.

Some parameters can be null, and will be replaced with sensible defaults if so. See the specific parameters for more info.

Specified by:
create in interface ServiceFactory
Parameters:
clazz - The service class used to populate the operations and parameters.
name - The name of the service. If null, a name will be generated from the class name.
namespace - The default namespace of the service. If null, a namespace will be generated from the class package.
properties - Service specific properties which the ServiceFactory will use to create the service.
Returns:
The service.

createDocumentationProvider

protected void createDocumentationProvider(ServiceInfo serviceInfo)
Parameters:
serviceInfo -

getTargetNamespace

protected java.lang.String getTargetNamespace(java.lang.Class clazz)

getSoap11Transports

public java.util.Collection getSoap11Transports()
Get a list of Transports which are enabled over SOAP 1.1.

Returns:

addSoap11Transport

public void addSoap11Transport(java.lang.String id)

getSoap12Transports

public java.util.Collection getSoap12Transports()
Get a list of Transports which are enabled over SOAP 1.2.

Returns:

addSoap12Transport

public void addSoap12Transport(java.lang.String id)

createBindings

protected void createBindings(Service service,
                              java.util.Collection s11,
                              java.util.Collection s12)

createEndpoint

public Endpoint createEndpoint(Service service,
                               javax.xml.namespace.QName name,
                               java.lang.String url,
                               Binding binding)
                        throws java.lang.Exception
Creates an endpoint for a service. Additionally it opens a channel for this endpoint as well.

Parameters:
service -
name -
url -
binding -
Returns:
Throws:
java.lang.Exception

createSoap12Binding

public Soap12Binding createSoap12Binding(Service service,
                                         javax.xml.namespace.QName bindingName,
                                         java.lang.String bindingId)
Create a SOAP 1.2 binding for the specified binding id.

Parameters:
service -
bindingName - The name of the binding. If null, one will be created.
bindingId -
Returns:

createSoap11Binding

public Soap11Binding createSoap11Binding(Service service,
                                         javax.xml.namespace.QName bindingName,
                                         java.lang.String bindingId)
Create a SOAP 1.1 binding for the specified binding id.

Parameters:
service -
bindingName - The name of the binding. If null, one will be created.
bindingId -
Returns:

createSoapBinding

protected void createSoapBinding(Service service,
                                 AbstractSoapBinding binding)

getSerializer

protected MessageSerializer getSerializer(AbstractSoapBinding binding)

createBindingOperation

protected void createBindingOperation(Service service,
                                      AbstractSoapBinding binding,
                                      OperationInfo op)

registerHandlers

protected void registerHandlers(Service service)

initializeOperations

protected void initializeOperations(Service endpoint,
                                    java.lang.String style)

addIgnoredMethods

public void addIgnoredMethods(java.lang.String className)
Ignore the specified class' declared methods. This can be used to not expose certain interfaces as a service. By default, the methods specified by the following interfaces/classes are ignored:
  • java.lang.Object
  • org.omg.CORBA_2_3.portable.ObjectImpl
  • org.omg.CORBA.portable.ObjectImpl
  • javax.ejb.EJBObject
  • javax.ejb.EJBLocalObject
  • javax.rmi.CORBA.Stub

    Parameters:
    className - the fully qualified class name

  • isValidMethod

    protected boolean isValidMethod(java.lang.reflect.Method method)

    addOperation

    protected OperationInfo addOperation(Service endpoint,
                                         java.lang.reflect.Method method,
                                         java.lang.String style)

    isOutParam

    protected boolean isOutParam(java.lang.reflect.Method method,
                                 int j)

    isInParam

    protected boolean isInParam(java.lang.reflect.Method method,
                                int j)

    createInputMessageName

    protected javax.xml.namespace.QName createInputMessageName(OperationInfo op)

    createOutputMessageName

    protected javax.xml.namespace.QName createOutputMessageName(OperationInfo op)

    hasOutMessage

    protected boolean hasOutMessage(java.lang.String mep)

    initializeFaults

    protected void initializeFaults(Service service,
                                    OperationInfo op)

    addFault

    protected FaultInfo addFault(Service service,
                                 OperationInfo op,
                                 java.lang.Class exClass)

    isFaultInfoClass

    protected boolean isFaultInfoClass(java.lang.Class exClass)

    getFaultName

    protected javax.xml.namespace.QName getFaultName(Service service,
                                                     OperationInfo o,
                                                     java.lang.Class exClass,
                                                     java.lang.Class beanClass)

    getAction

    protected java.lang.String getAction(OperationInfo op)

    isHeader

    protected boolean isHeader(java.lang.reflect.Method method,
                               int j)

    getOperationName

    protected java.lang.String getOperationName(ServiceInfo service,
                                                java.lang.reflect.Method method)
    Creates a name for the operation from the method name. If an operation with that name already exists, a name is create by appending an integer to the end. I.e. if there is already two methods named doSomething, the first one will have an operation name of "doSomething" and the second "doSomething1".

    Parameters:
    service -
    method -

    getMEP

    protected java.lang.String getMEP(java.lang.reflect.Method method)

    isAsync

    protected boolean isAsync(java.lang.reflect.Method method)

    getInParameterName

    protected javax.xml.namespace.QName getInParameterName(Service service,
                                                           OperationInfo op,
                                                           java.lang.reflect.Method method,
                                                           int paramNumber,
                                                           boolean doc)

    getOutParameterName

    protected javax.xml.namespace.QName getOutParameterName(Service service,
                                                            OperationInfo op,
                                                            java.lang.reflect.Method method,
                                                            int paramNumber,
                                                            boolean doc)

    getTransportManager

    public TransportManager getTransportManager()

    setTransportManager

    public void setTransportManager(TransportManager transportManager)

    setBindingProvider

    public void setBindingProvider(BindingProvider bindingProvider)

    getStyle

    public java.lang.String getStyle()

    setStyle

    public void setStyle(java.lang.String style)

    getUse

    public java.lang.String getUse()

    setUse

    public void setUse(java.lang.String use)

    isVoidOneWay

    public boolean isVoidOneWay()

    setVoidOneWay

    public void setVoidOneWay(boolean voidOneWay)

    getWsdlBuilderFactory

    public WSDLBuilderFactory getWsdlBuilderFactory()

    setWsdlBuilderFactory

    public void setWsdlBuilderFactory(WSDLBuilderFactory wsdlBuilderFactory)

    isCustomFaultsEnabled

    public boolean isCustomFaultsEnabled()

    setCustomFaultsEnabled

    public void setCustomFaultsEnabled(boolean customFaultsEnabled)

    isBindingCreationEnabled

    public boolean isBindingCreationEnabled()

    setBindingCreationEnabled

    public void setBindingCreationEnabled(boolean bindingCreationEnabled)

    getIgnoredClasses

    public java.util.Set getIgnoredClasses()

    getServiceConfigurations

    public java.util.List getServiceConfigurations()

    setServiceConfigurations

    public void setServiceConfigurations(java.util.List serviceConfigurations)

    getDocumentationProvider

    protected DocumentationProvider getDocumentationProvider()

    setDocumentationProvider

    protected void setDocumentationProvider(DocumentationProvider documentationProvider)


    Copyright © 2004-2010. All Rights Reserved.