Apache CXF API

org.apache.cxf.aegis
Class AegisContext

java.lang.Object
  extended by org.apache.cxf.aegis.AegisContext

public class AegisContext
extends Object

The Aegis Databinding context object. This object coordinates the data binding process: reading and writing XML. By default, this object sets up a default set of type mappings. This consists of two DefaultTypeMapping objects. The first is empty and has the Default, Java5, and XML TypeCreator classes configured. The second contains the standard mappings of the stock types. If a type can't be mapped in either, then the creators create a mapping and store it in the first one. The application can control some parameters of the type creators by creating a TypeCreationOptions object and setting properties. The application can add custom mappings to the type mapping, or even use its own classes for the TypeMapping or TypeCreator objects. Aegis, unlike JAXB, has no concept of a 'root element'. So, an application that uses Aegis without a web service has to either depend on xsi:type (at least for root elements) or have its own mapping from elements to classes, and pass the resulting Class objects to the readers. At this level, the application must specify the initial set of classes to make make use of untyped collections or .aegis.xml files. If the application leaves this list empty, and reads XML messages, then no .aegis.xml files are used unless the application has specified a Class<T> for the root of a particular item read. Specifically, if the application just leaves it to Aegis to map an element tagged with an xsi:type to a class, Aegis can't know that some arbitrary class in some arbitrary package is mapped to a particular schema type by QName in a mapping XML file. At the level of the CXF data binding, the 'root elements' are defined by the WSDL message parts. Additional classes that participate are termed 'override' classes.


Field Summary
static String UTILITY_TYPES_SCHEMA_NS
          Namespace used for the miscellaneous Aegis type schema.
 
Constructor Summary
AegisContext()
          Construct a context.
 
Method Summary
 org.apache.ws.commons.schema.XmlSchema addTypesSchemaDocument(org.apache.ws.commons.schema.XmlSchemaCollection collection)
           
static void addUtilityTypesToSchema(org.apache.ws.commons.schema.XmlSchema root)
           
 org.apache.ws.commons.schema.XmlSchema addXmimeSchemaDocument(org.apache.ws.commons.schema.XmlSchemaCollection collection)
           
protected  AbstractTypeCreator createDefaultTypeCreator()
           
 AegisReader<Element> createDomElementReader()
           
 AegisWriter<Element> createDomElementWriter()
           
protected  AbstractTypeCreator createRootTypeCreator()
           
 TypeCreator createTypeCreator()
           
 AegisReader<javax.xml.stream.XMLStreamReader> createXMLStreamReader()
           
 AegisWriter<javax.xml.stream.XMLStreamWriter> createXMLStreamWriter()
           
 Map<Class<?>,String> getBeanImplementationMap()
          This property provides support for interfaces.
 TypeCreationOptions getConfiguration()
          Deprecated. 2.1
 String getMappingNamespaceURI()
          What URI identifies the type mapping for this context? When the XMLTypeCreator reads .aegis.xml file, it will only read mappings for this URI (or no URI).
 Set<Type> getRootClasses()
           
 Set<String> getRootClassNames()
          Retrieve the set of root class names.
 AegisType getRootType(Class clazz)
          If a class was provided as part of the 'root' list, retrieve it's AegisType by Class.
 AegisType getRootType(QName schemaTypeName)
          If a class was provided as part of the root list, retrieve it's AegisType by schema type QName.
 Set<AegisType> getRootTypes()
          Retrieve the Aegis type objects for the root classes.
 TypeCreationOptions getTypeCreationOptions()
          Return the type mapping configuration associated with this context.
 TypeMapping getTypeMapping()
          Return the type mapping object used by this context.
 void initialize()
          Initialize the context.
 boolean isEnableJDOMMappings()
           
 boolean isMtomEnabled()
          Is MTOM enabled in this context?
 boolean isMtomUseXmime()
          Should this service use schema for MTOM types xmime:base64Binary instead of xsd:base64Binary?
 boolean isReadXsiTypes()
           
 boolean isWriteXsiTypes()
           
static boolean schemaImportsUtilityTypes(org.apache.ws.commons.schema.XmlSchema schema)
           
 void setBeanImplementationMap(Map<Class<?>,String> beanImplementationMap)
           
 void setConfiguration(TypeCreationOptions newConfiguration)
          Deprecated. 2.1
 void setEnableJDOMMappings(boolean enableJDOMMappings)
          Whether to enable JDOM as a mapping for xsd:anyType if JDOM is in the classpath.
 void setMappingNamespaceURI(String mappingNamespaceURI)
           
 void setMtomEnabled(boolean mtomEnabled)
           
 void setMtomUseXmime(boolean mtomUseXmime)
           
 void setReadXsiTypes(boolean flag)
          Controls the use of xsi:type attributes when reading objects.
 void setRootClasses(Set<Type> rootClasses)
          The list of initial classes.
 void setRootClassNames(Set<String> classNames)
          Set the root class names.
 void setTypeCreationOptions(TypeCreationOptions newConfiguration)
          Set the configuration object.
 void setTypeMapping(TypeMapping typeMapping)
          Set the type mapping object used by this context.
 void setWriteXsiTypes(boolean flag)
          Controls whether Aegis writes xsi:type attributes on all elements.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UTILITY_TYPES_SCHEMA_NS

public static final String UTILITY_TYPES_SCHEMA_NS
Namespace used for the miscellaneous Aegis type schema.

See Also:
Constant Field Values
Constructor Detail

AegisContext

public AegisContext()
Construct a context.

Method Detail

createTypeCreator

public TypeCreator createTypeCreator()

createRootTypeCreator

protected AbstractTypeCreator createRootTypeCreator()

createDefaultTypeCreator

protected AbstractTypeCreator createDefaultTypeCreator()

initialize

public void initialize()
Initialize the context. The encodingStyleURI allows .aegis.xml files to have multiple mappings for, say, SOAP 1.1 versus SOAP 1.2. Passing null uses a default URI.

Parameters:
mappingNamespaceURI - URI to select mappings based on the encoding.

createDomElementReader

public AegisReader<Element> createDomElementReader()

createXMLStreamReader

public AegisReader<javax.xml.stream.XMLStreamReader> createXMLStreamReader()

createDomElementWriter

public AegisWriter<Element> createDomElementWriter()

createXMLStreamWriter

public AegisWriter<javax.xml.stream.XMLStreamWriter> createXMLStreamWriter()

getRootType

public AegisType getRootType(Class clazz)
If a class was provided as part of the 'root' list, retrieve it's AegisType by Class.

Parameters:
clazz -
Returns:

getRootType

public AegisType getRootType(QName schemaTypeName)
If a class was provided as part of the root list, retrieve it's AegisType by schema type QName.

Parameters:
schemaTypeName -
Returns:

schemaImportsUtilityTypes

public static boolean schemaImportsUtilityTypes(org.apache.ws.commons.schema.XmlSchema schema)

addTypesSchemaDocument

public org.apache.ws.commons.schema.XmlSchema addTypesSchemaDocument(org.apache.ws.commons.schema.XmlSchemaCollection collection)

addXmimeSchemaDocument

public org.apache.ws.commons.schema.XmlSchema addXmimeSchemaDocument(org.apache.ws.commons.schema.XmlSchemaCollection collection)

addUtilityTypesToSchema

public static void addUtilityTypesToSchema(org.apache.ws.commons.schema.XmlSchema root)

getRootClassNames

public Set<String> getRootClassNames()
Retrieve the set of root class names. Note that if the application specifies the root classes by Class instead of by name, this will return null.

Returns:

setRootClassNames

public void setRootClassNames(Set<String> classNames)
Set the root class names. This function is a convenience for Spring configuration. It sets the same underlying collection as setRootClasses(Set).

Parameters:
classNames -

getConfiguration

public TypeCreationOptions getConfiguration()
Deprecated. 2.1

Return the type mapping configuration associated with this context.

Returns:
Returns the configuration.

getTypeCreationOptions

public TypeCreationOptions getTypeCreationOptions()
Return the type mapping configuration associated with this context.

Returns:
Returns the configuration.

setConfiguration

public void setConfiguration(TypeCreationOptions newConfiguration)
Deprecated. 2.1

Set the configuration object. The configuration specifies default type mapping behaviors.

Parameters:
configuration - The configuration to set.

setTypeCreationOptions

public void setTypeCreationOptions(TypeCreationOptions newConfiguration)
Set the configuration object. The configuration specifies default type mapping behaviors.

Parameters:
configuration - The configuration to set.

isWriteXsiTypes

public boolean isWriteXsiTypes()

isReadXsiTypes

public boolean isReadXsiTypes()

setWriteXsiTypes

public void setWriteXsiTypes(boolean flag)
Controls whether Aegis writes xsi:type attributes on all elements. False by default.

Parameters:
flag -

setReadXsiTypes

public void setReadXsiTypes(boolean flag)
Controls the use of xsi:type attributes when reading objects. By default, xsi:type reading is enabled. When disabled, Aegis will only map for objects that the application manually maps in the type mapping.

Parameters:
flag -

getTypeMapping

public TypeMapping getTypeMapping()
Return the type mapping object used by this context.

Returns:

setTypeMapping

public void setTypeMapping(TypeMapping typeMapping)
Set the type mapping object used by this context.

Parameters:
typeMapping -

getRootTypes

public Set<AegisType> getRootTypes()
Retrieve the Aegis type objects for the root classes.

Returns:
the set of type objects.

getBeanImplementationMap

public Map<Class<?>,String> getBeanImplementationMap()
This property provides support for interfaces. If there is a mapping from an interface's Class to a string containing a class name, Aegis will create proxy objects of that class name.

Returns:
See Also:
BeanType

setBeanImplementationMap

public void setBeanImplementationMap(Map<Class<?>,String> beanImplementationMap)

getRootClasses

public Set<Type> getRootClasses()

setRootClasses

public void setRootClasses(Set<Type> rootClasses)
The list of initial classes.

Parameters:
rootClasses -

isMtomEnabled

public boolean isMtomEnabled()
Is MTOM enabled in this context?

Returns:

setMtomEnabled

public void setMtomEnabled(boolean mtomEnabled)

isMtomUseXmime

public boolean isMtomUseXmime()
Should this service use schema for MTOM types xmime:base64Binary instead of xsd:base64Binary?

Returns:

setMtomUseXmime

public void setMtomUseXmime(boolean mtomUseXmime)

getMappingNamespaceURI

public String getMappingNamespaceURI()
What URI identifies the type mapping for this context? When the XMLTypeCreator reads .aegis.xml file, it will only read mappings for this URI (or no URI). When the abstract type creator is otherwise at a loss for a namespace URI, it will use this URI.

Returns:

setMappingNamespaceURI

public void setMappingNamespaceURI(String mappingNamespaceURI)

isEnableJDOMMappings

public boolean isEnableJDOMMappings()

setEnableJDOMMappings

public void setEnableJDOMMappings(boolean enableJDOMMappings)
Whether to enable JDOM as a mapping for xsd:anyType if JDOM is in the classpath.

Parameters:
enableJDOMMappings -

Apache CXF API

Apache CXF