org.apache.axis.encoding

Class TypeMappingRegistryImpl

public class TypeMappingRegistryImpl extends Object implements TypeMappingRegistry

The TypeMappingRegistry keeps track of the individual TypeMappings.

The TypeMappingRegistry for axis contains a default type mapping that is set for either SOAP 1.1 or SOAP 1.2 The default type mapping is a singleton used for the entire runtime and should not have anything new registered in it.

Instead the new TypeMappings for the deploy and service are made in a separate TypeMapping which is identified by the soap encoding. These new TypeMappings delegate back to the default type mapping when information is not found.

So logically we have:

         TMR
         | |  
         | +---------------> DefaultTM 
         |                      ^
         |                      |
         +----> TM --delegate---+
 
But in the implementation, the TMR references "delegate" TypeMappings (TM') which then reference the actual TM's

So the picture is really:

         TMR
         | |  
         | +-----------TM'------> DefaultTM 
         |              ^
         |              |
         +-TM'-> TM ----+
 
This extra indirection is necessary because the user may want to change the default type mapping. In such cases, the TMR just needs to adjust the TM' for the DefaultTM, and all of the other TMs will properly delegate to the new one. Here's the picture:
         TMR
         | |  
         | +-----------TM'--+     DefaultTM 
         |              ^   |
         |              |   +---> New User Defined Default TM
         +-TM'-> TM ----+
 
The other reason that it is necessary is when a deploy has a TMR, and then TMR's are defined for the individual services in such cases the delegate() method is invoked on the service to delegate to the deploy TMR
       Deploy TMR
         | |  
         | +-----------TM'------> DefaultTM 
         |              ^
         |              |
         +-TM'-> TM ----+

       Service TMR
         | |  
         | +-----------TM'------> DefaultTM 
         |              ^
         |              |
         +-TM'-> TM ----+

    ServiceTMR.delegate(DeployTMR)

       Deploy TMR
         | |  
         | +------------TM'------> DefaultTM 
         |              ^ ^ 
         |              | |
         +-TM'-> TM ----+ |
           ^              |
   +-------+              |
   |                      |
   |   Service TMR        |
   |     | |              |
   |     | +----------TM'-+               
   |     |              
   |     |              
   |     +-TM'-> TM +
   |                |
   +----------------+
 
So now the service uses the DefaultTM of the Deploy TMR, and the Service TM properly delegates to the deploy's TM. And if either the deploy defaultTM or TMs change, the links are not broken.

Author: James Snell (jasnell@us.ibm.com) Sam Ruby (rubys@us.ibm.com) Re-written for JAX-RPC Compliance by Rich Scheuerle (scheu@us.ibm.com

Constructor Summary
TypeMappingRegistryImpl(TypeMappingImpl tm)
Construct TypeMappingRegistry
TypeMappingRegistryImpl()
Construct TypeMappingRegistry
TypeMappingRegistryImpl(boolean registerDefaults)
Method Summary
voidclear()
Removes all TypeMappings and namespaceURIs from this TypeMappingRegistry.
TypeMappingcreateTypeMapping()
Creates a new empty TypeMapping object for the specified encoding style or XML schema namespace.
voiddelegate(TypeMappingRegistry secondaryTMR)
delegate Changes the contained type mappings to delegate to their corresponding types in the secondary TMR.
voiddoRegisterFromVersion(String version)
Set up the default type mapping (and the SOAP encoding type mappings) as per the passed "version" option.
TypeMappinggetDefaultTypeMapping()
Return the default TypeMapping
TypeMappinggetOrMakeTypeMapping(String encodingStyle)
Obtain a type mapping for the given encodingStyle.
String[]getRegisteredEncodingStyleURIs()
Gets a list of namespace URIs registered with this TypeMappingRegistry.
TypeMappinggetTypeMapping(String namespaceURI)
Gets the TypeMapping for the namespace.
TypeMappingregister(String namespaceURI, TypeMapping mapping)
The method register adds a TypeMapping instance for a specific namespace
voidregisterDefault(TypeMapping mapping)
The method register adds a default TypeMapping instance.
booleanremoveTypeMapping(TypeMapping mapping)
Removes the TypeMapping for the namespace.
TypeMappingunregisterTypeMapping(String namespaceURI)
Unregisters the TypeMapping for the namespace.

Constructor Detail

TypeMappingRegistryImpl

public TypeMappingRegistryImpl(TypeMappingImpl tm)
Construct TypeMappingRegistry

Parameters: tm

TypeMappingRegistryImpl

public TypeMappingRegistryImpl()
Construct TypeMappingRegistry

TypeMappingRegistryImpl

public TypeMappingRegistryImpl(boolean registerDefaults)

Method Detail

clear

public void clear()
Removes all TypeMappings and namespaceURIs from this TypeMappingRegistry.

createTypeMapping

public TypeMapping createTypeMapping()
Creates a new empty TypeMapping object for the specified encoding style or XML schema namespace.

Returns: An empty generic TypeMapping object

delegate

public void delegate(TypeMappingRegistry secondaryTMR)
delegate Changes the contained type mappings to delegate to their corresponding types in the secondary TMR.

doRegisterFromVersion

public void doRegisterFromVersion(String version)
Set up the default type mapping (and the SOAP encoding type mappings) as per the passed "version" option.

Parameters: version

getDefaultTypeMapping

public TypeMapping getDefaultTypeMapping()
Return the default TypeMapping

Returns: TypeMapping or null

getOrMakeTypeMapping

public TypeMapping getOrMakeTypeMapping(String encodingStyle)
Obtain a type mapping for the given encodingStyle. If no specific mapping exists for this encodingStyle, we will create and register one before returning it.

Parameters: encodingStyle

Returns: a registered TypeMapping for the given encodingStyle

getRegisteredEncodingStyleURIs

public String[] getRegisteredEncodingStyleURIs()
Gets a list of namespace URIs registered with this TypeMappingRegistry.

Returns: String[] containing names of all registered namespace URIs

getTypeMapping

public TypeMapping getTypeMapping(String namespaceURI)
Gets the TypeMapping for the namespace. If not found, the default TypeMapping is returned.

Parameters: namespaceURI - The namespace URI of a Web Service

Returns: The registered TypeMapping (which may be the default TypeMapping) or null.

register

public TypeMapping register(String namespaceURI, TypeMapping mapping)
The method register adds a TypeMapping instance for a specific namespace

Parameters: namespaceURI mapping - TypeMapping for specific namespaces

Returns: Previous TypeMapping associated with the specified namespaceURI, or null if there was no TypeMapping associated with the specified namespaceURI

registerDefault

public void registerDefault(TypeMapping mapping)
The method register adds a default TypeMapping instance. If a specific TypeMapping is not found, the default TypeMapping is used.

Parameters: mapping - TypeMapping for specific type namespaces java.lang.IllegalArgumentException - if an invalid type mapping is specified or the delegate is already set

removeTypeMapping

public boolean removeTypeMapping(TypeMapping mapping)
Removes the TypeMapping for the namespace.

Parameters: mapping The type mapping to remove

Returns: true if found and removed

unregisterTypeMapping

public TypeMapping unregisterTypeMapping(String namespaceURI)
Unregisters the TypeMapping for the namespace.

Parameters: namespaceURI - The namespace URI

Returns: The registered TypeMapping .

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