Novell exteNd Web Services SDK API

com.sssw.jbroker.web.encoding
Class DefaultTypeMappingRegistry

java.lang.Object
  extended bycom.sssw.jbroker.web.encoding.DefaultTypeMappingRegistry
All Implemented Interfaces:
Serializable, TypeMappingRegistry, TypeMappingRegistry

public class DefaultTypeMappingRegistry
extends Object
implements TypeMappingRegistry

The DefaultTypeMappingRegistry class is an implementation of the standard TypeMappingRegistry interface. It supports additional utility methods for importing type mappings. The default type mapper is an expert facility that will not be used by most applications.

Since:
jBroker Web 2.0
See Also:
Serialized Form

Constructor Summary
DefaultTypeMappingRegistry()
          Construct an empty type mapping registry.
DefaultTypeMappingRegistry(TypeMapper mapper)
          Construct a type mapping registry using a jBroker Web 1.1 type mapper.
 
Method Summary
 void clear()
          Removes all registered TypeMappings and encodingStyleURIs from this TypeMappingRegistry.
 TypeMapping createTypeMapping()
          Creates a new empty TypeMapping object.
 TypeMapping createTypeMapping(String uri)
           
 TypeMap get(Class javaType)
          Get a type map for a Java class.
 TypeMap get(Class javaType, QName xmlType)
          Get a type map between Java class and XML type.
 TypeMap get(Class javaType, String uri)
          Get a type map for a Java class from a particular namespace.
 TypeMap get(Class javaType, String typeNS, String typeName)
          Get a type map between Java class and XML type.
 TypeMap get(QName qname)
          Get a type map for a QName.
 TypeMap get(QName qname)
          Deprecated. use standard QName instead
 TypeMapping getDefaultTypeMapping()
          Gets the registered default TypeMapping instance.
 String[] getRegisteredEncodingStyleURIs()
          Returns a list of registered encodingStyle URIs in this TypeMappingRegistry instance.
 TypeMapping getTypeMapping(String encodingStyleURI)
          Returns the registered TypeMapping for the specified encodingStyle URI.
 void importTypeMappings(InputStream is, ClassLoader loader)
          Import type mappings from an input stream into this registry
 void importTypeMappings(Properties mappings)
          Import type mappings from a property object
 void importTypeMappings(Properties mappings, ClassLoader loader)
          Import the mappings from the given properties.
 void importTypeMappings(String resourceName)
          Import type mappings from a resource into this registry
 void importTypeMappings(String resourceName, ClassLoader loader)
          Import type mappings from a resource into this registry
 void importTypeMappings(String propResource, Servlet servlet)
          Import type mappings from property resource in servlet
 void importTypeMappings(String propResource, Servlet servlet, ClassLoader loader)
          Import type mappings from property resource in servlet
 void importTypeMappingsFromFile(String fileName)
          Import type mappings from a file into this registry
 void importTypeMappingsFromFile(String fileName, ClassLoader loader)
          Import type mappings from a file into this registry
 Iterator iterator()
          Iterator for all the type maps in the registry.
 void put(TypeMap tm)
          Put a type map into the registry.
 TypeMapping register(String encodingStyleURI, TypeMapping tm)
          Registers a TypeMapping instance with the TypeMappingRegistry.
 void registerDefault(TypeMapping tm)
          Registers the TypeMapping instance that is default for all encoding styles supported by the TypeMappingRegistry.
 boolean removeTypeMapping(TypeMapping tm)
          Removes a TypeMapping from the TypeMappingRegistry.
 String toString()
          Get a pretty printed string with type mappings in this registry
 TypeMapping unregisterTypeMapping(String encodingStyleURI)
          Unregisters a TypeMapping instance, if present, from the specified encodingStyleURI.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DefaultTypeMappingRegistry

public DefaultTypeMappingRegistry()
Construct an empty type mapping registry.


DefaultTypeMappingRegistry

public DefaultTypeMappingRegistry(TypeMapper mapper)
Construct a type mapping registry using a jBroker Web 1.1 type mapper. This constructor can be used by existing applications that quickly want to adapt to the new API's. The default type mapping registry will be populated with all mapping from the type mapper.

Parameters:
mapper - a jBroker Web 1.1 type mapper object
Method Detail

register

public TypeMapping register(String encodingStyleURI,
                            TypeMapping tm)
Description copied from interface: TypeMappingRegistry
Registers a TypeMapping instance with the TypeMappingRegistry. This method replaces any existing registered TypeMapping instance for the specified encodingStyleURI.

Specified by:
register in interface TypeMappingRegistry
Parameters:
encodingStyleURI - An encoding style specified as an URI. An example is "http://schemas.xmlsoap.org/soap/encoding/"
tm - TypeMapping instance
Returns:
Previous TypeMapping associated with the specified encodingStyleURI, or null if there was no TypeMapping associated with the specified encodingStyleURI

registerDefault

public void registerDefault(TypeMapping tm)
Description copied from interface: TypeMappingRegistry
Registers the TypeMapping instance that is default for all encoding styles supported by the TypeMappingRegistry. A default TypeMapping should include serializers and deserializers that are independent of and usable with any encoding style. Successive invocations of the registerDefault method replace any existing default TypeMapping instance.

If the default TypeMapping is registered, any other TypeMapping instances registered through the TypeMappingRegistry.register method (for a set of encodingStyle URIs) override the default TypeMapping.

Specified by:
registerDefault in interface TypeMappingRegistry
Parameters:
tm - TypeMapping instance

getDefaultTypeMapping

public TypeMapping getDefaultTypeMapping()
Description copied from interface: TypeMappingRegistry
Gets the registered default TypeMapping instance. This method returns null if there is no registered default TypeMapping in the registry.

Specified by:
getDefaultTypeMapping in interface TypeMappingRegistry
Returns:
The registered default TypeMapping instance or null

getRegisteredEncodingStyleURIs

public String[] getRegisteredEncodingStyleURIs()
Description copied from interface: TypeMappingRegistry
Returns a list of registered encodingStyle URIs in this TypeMappingRegistry instance.

Specified by:
getRegisteredEncodingStyleURIs in interface TypeMappingRegistry
Returns:
Array of the registered encodingStyle URIs

getTypeMapping

public TypeMapping getTypeMapping(String encodingStyleURI)
Description copied from interface: TypeMappingRegistry
Returns the registered TypeMapping for the specified encodingStyle URI. If there is no registered TypeMapping for the specified encodingStyleURI, this method returns null.

Specified by:
getTypeMapping in interface TypeMappingRegistry
Parameters:
encodingStyleURI - Encoding style specified as an URI
Returns:
TypeMapping for the specified encodingStyleURI or null

createTypeMapping

public TypeMapping createTypeMapping(String uri)

createTypeMapping

public TypeMapping createTypeMapping()
Description copied from interface: TypeMappingRegistry
Creates a new empty TypeMapping object.

Specified by:
createTypeMapping in interface TypeMappingRegistry
Returns:
TypeMapping instance

unregisterTypeMapping

public TypeMapping unregisterTypeMapping(String encodingStyleURI)
Description copied from interface: TypeMappingRegistry
Unregisters a TypeMapping instance, if present, from the specified encodingStyleURI.

Specified by:
unregisterTypeMapping in interface TypeMappingRegistry
Parameters:
encodingStyleURI - Encoding style specified as an URI
Returns:
TypeMapping instance that has been unregistered or null if there was no TypeMapping registered for the specified encodingStyleURI

removeTypeMapping

public boolean removeTypeMapping(TypeMapping tm)
Description copied from interface: TypeMappingRegistry
Removes a TypeMapping from the TypeMappingRegistry. A TypeMapping is associated with 1 or more encodingStyleURIs. This method unregisters the specified TypeMapping instance from all associated encodingStyleURIs and then removes this TypeMapping instance from the registry.

Specified by:
removeTypeMapping in interface TypeMappingRegistry
Parameters:
tm - TypeMapping to be removed
Returns:
true if specified TypeMapping is removed from the TypeMappingRegistry; false if the specified TypeMapping was not in the TypeMappingRegistry

clear

public void clear()
Description copied from interface: TypeMappingRegistry
Removes all registered TypeMappings and encodingStyleURIs from this TypeMappingRegistry.

Specified by:
clear in interface TypeMappingRegistry

get

public TypeMap get(Class javaType)
Get a type map for a Java class. Note that if multiple type mappings exist for the Java type, the first mapping found will be returned.

Parameters:
javaType - the Java type
Returns:
a TypeMap object, or null if none found

get

public TypeMap get(Class javaType,
                   QName xmlType)
Get a type map between Java class and XML type.

Parameters:
javaType - the Java type
xmlType - the QName of the Xml type.
Returns:
a TypeMap object, or null if none found

get

public TypeMap get(Class javaType,
                   String typeNS,
                   String typeName)
Get a type map between Java class and XML type.

Parameters:
javaType - the Java type
typeNS - the Namespace of the Xml type.
typeName - the Name of the Xml type.
Returns:
a TypeMap object, or null if none found

get

public TypeMap get(Class javaType,
                   String uri)
Get a type map for a Java class from a particular namespace.

Parameters:
javaType - the Java type
uri - the namespace URI
Returns:
a TypeMap object, or null if none found

get

public TypeMap get(QName qname)
Get a type map for a QName. first mapping found will be returned.

Parameters:
qname - the QName type
Returns:
a TypeMap object, or null if none found

get

public TypeMap get(QName qname)
Deprecated. use standard QName instead

Get a type map for a QName. first mapping found will be returned.

Parameters:
qname - the QName type
Returns:
a TypeMap object, or null if none found

put

public void put(TypeMap tm)
Put a type map into the registry. The destination TypeMapping will be determined from the namespace URI of the type map's getQName method.

Parameters:
tm - a TypeMap object

iterator

public Iterator iterator()
Iterator for all the type maps in the registry.


importTypeMappings

public void importTypeMappings(String resourceName)
                        throws TypeMappingException,
                               IOException
Import type mappings from a resource into this registry

Specified by:
importTypeMappings in interface TypeMappingRegistry
Parameters:
resourceName - the resource name with type mapping entries
Throws:
TypeMappingException - if import failed
IOException - if resource could not be read

importTypeMappings

public void importTypeMappings(String resourceName,
                               ClassLoader loader)
                        throws TypeMappingException,
                               IOException
Import type mappings from a resource into this registry

Specified by:
importTypeMappings in interface TypeMappingRegistry
Parameters:
resourceName - the resource name with type mapping entries
loader - class loader to load mapping classes
Throws:
TypeMappingException - if import failed
IOException - if resource could not be read

importTypeMappingsFromFile

public void importTypeMappingsFromFile(String fileName)
                                throws TypeMappingException,
                                       IOException
Import type mappings from a file into this registry

Specified by:
importTypeMappingsFromFile in interface TypeMappingRegistry
Parameters:
fileName - name of the file with type mapping entries
Throws:
TypeMappingException - if import failed
IOException - if file could not be read

importTypeMappingsFromFile

public void importTypeMappingsFromFile(String fileName,
                                       ClassLoader loader)
                                throws TypeMappingException,
                                       IOException
Import type mappings from a file into this registry

Specified by:
importTypeMappingsFromFile in interface TypeMappingRegistry
Parameters:
fileName - name of the file with type mapping entries
loader - class loader to load mapping classes
Throws:
TypeMappingException - if import failed
IOException - if file could not be read

importTypeMappings

public void importTypeMappings(InputStream is,
                               ClassLoader loader)
                        throws IOException,
                               TypeMappingException
Import type mappings from an input stream into this registry

Specified by:
importTypeMappings in interface TypeMappingRegistry
Parameters:
loader - class loader to load mapping classes
Throws:
TypeMappingException - if import failed
IOException - if stream could not be read

importTypeMappings

public void importTypeMappings(String propResource,
                               Servlet servlet)
                        throws TypeMappingException,
                               ServletException,
                               IOException
Import type mappings from property resource in servlet

Specified by:
importTypeMappings in interface TypeMappingRegistry
Parameters:
propResource - name of the resource with type mapping entries
servlet - the servlet object
Throws:
TypeMappingException - if import failed
ServletException - if servlet context could not be retrieved
IOException - if stream could not be read

importTypeMappings

public void importTypeMappings(String propResource,
                               Servlet servlet,
                               ClassLoader loader)
                        throws TypeMappingException,
                               ServletException,
                               IOException
Import type mappings from property resource in servlet

Specified by:
importTypeMappings in interface TypeMappingRegistry
Parameters:
propResource - name of the resource with type mapping entries
servlet - the servlet object
loader - class loader to load mapping classes
Throws:
TypeMappingException - if import failed
ServletException - if servlet context could not be retrieved
IOException - if stream could not be read

importTypeMappings

public void importTypeMappings(Properties mappings)
                        throws TypeMappingException
Import type mappings from a property object

Specified by:
importTypeMappings in interface TypeMappingRegistry
Parameters:
mappings - property set with mappings
Throws:
TypeMappingException - if import failed

importTypeMappings

public void importTypeMappings(Properties mappings,
                               ClassLoader loader)
                        throws TypeMappingException
Import the mappings from the given properties. Each property value is a 6-tuple that represents an individual TypeMapping.

<java Type> <Serializer> <Deserializer> <URI> <LN> <location>

For example,

mapping1=Address AddressMarshaler AddressMarshaler urn:DemoApp Address http://schemas.acme.org/address
The java classes are loaded from the given class loader.

Specified by:
importTypeMappings in interface TypeMappingRegistry
Parameters:
mappings - property set with mappings
loader - class loader to load mapping classes
Throws:
TypeMappingException - if import failed

toString

public String toString()
Get a pretty printed string with type mappings in this registry

Returns:
string form of registry

Novell exteNd Web Services SDK API

exteNd is a registered trademark of Novell, Inc.
Copyright 1998-2003 Novell, Inc. All Rights Reserved.