org.apache.axis.encoding

Class TypeMappingImpl

Implemented Interfaces:
Serializable
Known Direct Subclasses:
DefaultTypeMappingImpl

public class TypeMappingImpl
extends java.lang.Object
implements Serializable

This is the implementation of the axis TypeMapping interface (which extends the JAX-RPC TypeMapping interface).

A TypeMapping is obtained from the singleton TypeMappingRegistry using the namespace of the webservice. The TypeMapping contains the tuples {Java type, SerializerFactory, DeserializerFactory, Type QName)

So if you have a Web Service with the namespace "XYZ", you call the TypeMappingRegistry.getTypeMapping("XYZ").

The wsdl in your web service will use a number of types. The tuple information for each of these will be accessed via the TypeMapping.

Because every web service uses the soap, schema, wsdl primitives, we could pre-populate the TypeMapping with these standard tuples. Instead, if the namespace/class matches is not found in the TypeMapping the request is delegated to the Default TypeMapping or another TypeMapping

Author:
Rich Scheuerle (scheu@us.ibm.com)

Nested Class Summary

static class
TypeMappingImpl.Pair

Field Summary

protected Boolean
doAutoTypes
static boolean
dotnet_soapenc_bugfix
Work around a .NET bug with soap encoded types.
protected static Log
log

Constructor Summary

TypeMappingImpl()
Construct TypeMapping

Method Summary

DeserializerFactory
finalGetDeserializer(Class javaType, QName xmlType, TypeMappingDelegate start)
SerializerFactory
finalGetSerializer(Class javaType)
Class[]
getAllClasses(TypeMappingDelegate next)
Returns an array of all the classes contained within this mapping
Class
getClassForQName(QName xmlType, Class javaType, TypeMappingDelegate next)
DeserializerFactory
getDeserializer(Class javaType, QName xmlType, TypeMappingDelegate start)
Gets the DeserializerFactory registered for the specified pair of Java type and XML data type.
SerializerFactory
getSerializer(Class javaType, QName xmlType)
Gets the SerializerFactory registered for the specified pair of Java type and XML data type.
String[]
getSupportedEncodings()
Gets the list of encoding styles supported by this TypeMapping object.
QName
getTypeQName(Class javaType, TypeMappingDelegate next)
QName
getTypeQNameExact(Class javaType, TypeMappingDelegate next)
Get the QName for this Java class, but only return a specific mapping if there is one.
QName
getTypeQNameRecursive(Class javaType)
Gets the QName for the type mapped to Class.
QName
getXMLType(Class javaType, QName xmlType, boolean encoded)
Get the exact XML type QName which will be used when serializing a given Class to a given type QName.
protected void
internalRegister(Class javaType, QName xmlType, SerializerFactory sf, DeserializerFactory dsf)
Internal version of register(), which allows null factories.
boolean
isRegistered(Class javaType, QName xmlType)
isRegistered returns true if the [javaType, xmlType] pair is registered.
void
register(Class javaType, QName xmlType, SerializerFactory sf, DeserializerFactory dsf)
Registers SerializerFactory and DeserializerFactory for a specific type mapping between an XML type and Java type.
void
removeDeserializer(Class javaType, QName xmlType)
Removes the DeserializerFactory registered for the specified pair of Java type and XML data type.
void
removeSerializer(Class javaType, QName xmlType)
Removes the SerializerFactory registered for the specified pair of Java type and XML data type.
void
setDoAutoTypes(boolean doAutoTypes)
void
setSupportedEncodings(String[] namespaceURIs)
Sets the list of encoding styles supported by this TypeMapping object.
boolean
shouldDoAutoTypes()

Field Details

doAutoTypes

protected Boolean doAutoTypes


dotnet_soapenc_bugfix

public static boolean dotnet_soapenc_bugfix
Work around a .NET bug with soap encoded types. This is a static property of the type mapping that will cause the class to ignore SOAPENC types when looking up QNames of java types. See getTypeQNameExact().


log

protected static Log log

Constructor Details

TypeMappingImpl

public TypeMappingImpl()
Construct TypeMapping

Method Details

finalGetDeserializer

public DeserializerFactory finalGetDeserializer(Class javaType,
                                                QName xmlType,
                                                TypeMappingDelegate start)


finalGetSerializer

public SerializerFactory finalGetSerializer(Class javaType)


getAllClasses

public Class[] getAllClasses(TypeMappingDelegate next)
Returns an array of all the classes contained within this mapping


getClassForQName

public Class getClassForQName(QName xmlType,
                              Class javaType,
                              TypeMappingDelegate next)


getDeserializer

public DeserializerFactory getDeserializer(Class javaType,
                                           QName xmlType,
                                           TypeMappingDelegate start)
            throws JAXRPCException
Gets the DeserializerFactory registered for the specified pair of Java type and XML data type.

Parameters:
javaType - - Class of the Java type
xmlType - - Qualified name of the XML data type

Returns:
Registered DeserializerFactory

Throws:
JAXRPCException - - If there is no registered DeserializerFactory for this pair of Java type and XML data type java.lang.IllegalArgumentException - If invalid or unsupported XML/Java type is specified


getSerializer

public SerializerFactory getSerializer(Class javaType,
                                       QName xmlType)
            throws JAXRPCException
Gets the SerializerFactory registered for the specified pair of Java type and XML data type.

Parameters:
javaType - - Class of the Java type
xmlType - - Qualified name of the XML data type

Returns:
Registered SerializerFactory

Throws:
JAXRPCException - - If there is no registered SerializerFactory for this pair of Java type and XML data type java.lang.IllegalArgumentException - If invalid or unsupported XML/Java type is specified


getSupportedEncodings

public String[] getSupportedEncodings()
Gets the list of encoding styles supported by this TypeMapping object.

Returns:
String[] of namespace URIs for the supported encoding styles and XML schema namespaces.


getTypeQName

public QName getTypeQName(Class javaType,
                          TypeMappingDelegate next)


getTypeQNameExact

public QName getTypeQNameExact(Class javaType,
                               TypeMappingDelegate next)
Get the QName for this Java class, but only return a specific mapping if there is one. In other words, don't do special array processing, etc.

Parameters:
javaType -

Returns:


getTypeQNameRecursive

public QName getTypeQNameRecursive(Class javaType)
Gets the QName for the type mapped to Class.

Parameters:
javaType - class or type

Returns:
xmlType qname or null


getXMLType

public QName getXMLType(Class javaType,
                        QName xmlType,
                        boolean encoded)
            throws JAXRPCException
Get the exact XML type QName which will be used when serializing a given Class to a given type QName. In other words, if we have: Class TypeQName ---------------------- Base myNS:Base Child myNS:Child and call getXMLType(Child.class, BASE_QNAME), we should get CHILD_QNAME.

Parameters:
javaType -
xmlType -

Returns:
the type's QName

Throws:
JAXRPCException -


internalRegister

protected void internalRegister(Class javaType,
                                QName xmlType,
                                SerializerFactory sf,
                                DeserializerFactory dsf)
            throws JAXRPCException
Internal version of register(), which allows null factories.

Parameters:
javaType -
xmlType -
sf -
dsf -

Throws:
JAXRPCException -


isRegistered

public boolean isRegistered(Class javaType,
                            QName xmlType)
isRegistered returns true if the [javaType, xmlType] pair is registered.

Parameters:
javaType - - Class of the Java type
xmlType - - Qualified name of the XML data type

Returns:
true if there is a mapping for the given pair, or false if the pair is not specifically registered. For example if called with (java.lang.String[], soapenc:Array) this routine will return false because this pair is probably not specifically registered. However if getSerializer is called with the same pair, the default TypeMapping will use extra logic to find a serializer (i.e. array serializer)


register

public void register(Class javaType,
                     QName xmlType,
                     SerializerFactory sf,
                     DeserializerFactory dsf)
            throws JAXRPCException
Registers SerializerFactory and DeserializerFactory for a specific type mapping between an XML type and Java type.

Parameters:
javaType - - Class of the Java type
xmlType - - Qualified name of the XML data type
sf - - SerializerFactory
dsf - - DeserializerFactory

Throws:
JAXRPCException - - If any error during the registration


removeDeserializer

public void removeDeserializer(Class javaType,
                               QName xmlType)
            throws JAXRPCException
Removes the DeserializerFactory registered for the specified pair of Java type and XML data type.

Parameters:
javaType - - Class of the Java type
xmlType - - Qualified name of the XML data type

Throws:
JAXRPCException - - If there is error in removing the registered DeserializerFactory


removeSerializer

public void removeSerializer(Class javaType,
                             QName xmlType)
            throws JAXRPCException
Removes the SerializerFactory registered for the specified pair of Java type and XML data type.

Parameters:
javaType - - Class of the Java type
xmlType - - Qualified name of the XML data type

Throws:
JAXRPCException - - If there is error in removing the registered SerializerFactory


setDoAutoTypes

public void setDoAutoTypes(boolean doAutoTypes)


setSupportedEncodings

public void setSupportedEncodings(String[] namespaceURIs)
Sets the list of encoding styles supported by this TypeMapping object. (Not sure why this is useful...this information is automatically updated during registration.

Parameters:
namespaceURIs - String[] of namespace URI's


shouldDoAutoTypes

public boolean shouldDoAutoTypes()


Copyright B) 2005 Apache Web Services Project. All Rights Reserved.