org.apache.woden.wsdl20.extensions

## Class ExtensionRegistry

- java.lang.Object
- - org.apache.woden.wsdl20.extensions.ExtensionRegistry

-     public class ExtensionRegistry
      extends Object

  This class is used to associate serializers, deserializers, and Java implementation types with extension elements. It also associates Java implementation types only with extension attributes, but not serializers and deserializers.

  This class has been copied from WSDL4J and modified for Woden. TODO update method javadocs.

  Author:
    Matthew J. Duftler (duftler@us.ibm.com), John Kaputin (jkaputin@apache.org)

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected Map<String,AssertionInfo>` | `assertionReg`
    `protected Map<Class,Map<URI,Class<ComponentExtensionContext>>>` | `compExtReg`
    `protected ExtensionDeserializer` | `defaultDeser`
    `protected ExtensionSerializer` | `defaultSer`
    `protected Map<Class,Map<QName,ExtensionDeserializer>>` | `deserializerReg`
    `protected Map<Class,Map<QName,Class>>` | `extAttributeReg`
    `protected Map<Class,Map<QName,Class>>` | `extElementReg`
    `static String` | `REGISTRAR_PROPERTY` The property containing the comma-separated listed of ExtensionRegistrars.
    `protected Map<Class,Map<QName,ExtensionSerializer>>` | `serializerReg`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ExtensionRegistry(ErrorReporter errorReporter)` Creates the extension registry, and sets the defaultSerializer and defaultDeserializer properties to instances of an UnknownExtensionSerializer, and an UnknownExtensionDeserializer, respectively.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `ComponentExtensionContext` | `createComponentExtension(Class parentClass, WSDLComponent parentComp, URI extNamespace)` Return a ComponentExtensionContext object from the Java class registered for the specified extension namespace against the specified WSDL component class.
    `XMLAttr` | `createExtAttribute(Class ownerClass, QName attrQName, XMLElement ownerElement, String attrValue)`
    `ExtensionElement` | `createExtElement(Class parentType, QName elementType)` Create an instance of the type which was declared to be used to represent extensibility elements with qnames matching elementQN, when intended to exist as children of the specified parentType.
    `Set<QName>` | `getAllowableExtensions(Class parentType)` TODO make the return val typesafe, and create similar method for ext attrs.
    `ExtensionDeserializer` | `getDefaultDeserializer()` Get the deserializer to be used when none is found for an encountered element.
    `ExtensionSerializer` | `getDefaultSerializer()` Get the serializer to be used when none is found for an extensibility element.
    `ErrorReporter` | `getErrorReporter()`
    `AssertionInfo` | `queryAssertion(String assertionId)`
    `AssertionInfo[]` | `queryAssertions()`
    `Class<ComponentExtensionContext>` | `queryComponentExtension(Class parentClass, URI extNamespace)` Return the Java class that represents the extensions from the specified namespace that extend the specified WSDL component class.
    `URI[]` | `queryComponentExtensionNamespaces(Class parentClass)` Return the extension namespaces registered for the specified WSDL Component class.
    `ExtensionDeserializer` | `queryDeserializer(Class parentType, QName elementType)` Look up the deserializer for the extensibility element with the qname elementQN, which was encountered as an immediate child of the element represented by the specified parentType.
    `Class<XMLAttr>` | `queryExtAttributeType(Class parentClass, QName attrQN)` Look up the type of the extensibility attribute with the specified qname, which was defined on an element represented by the specified parent class.
    `Class` | `queryExtElementType(Class parentClass, QName elemQN)` Look up the type of the extensibility element with the specified qname, which was defined as a child of the element represented by the specified parent class.
    `String[]` | `queryResourceBundleNames()`
    `ExtensionSerializer` | `querySerializer(Class parentType, QName elementType)` Look up the serializer to use for the extensibility element with the qname elementQN, which was encountered as a child of the specified parentType.
    `void` | `registerAssertion(Assertion assertion, Class targetClass)` Register an Assertion along with the target Class that the assertion applies to.
    `void` | `registerComponentExtension(Class parentClass, URI extNamespace, Class compExtCtxClass)` Register the Java class which will represent extensions from a specified namespace that will extend the specified WSDL component class.
    `void` | `registerDeserializer(Class parentType, QName elementType, ExtensionDeserializer ed)` Declare that the specified deserializer should be used to deserialize all extensibility elements with a qname matching elementQN, when encountered as immediate children of the element represented by the specified parentType.
    `void` | `registerExtAttributeType(Class ownerClass, QName attrQName, Class attrClass)` Declare that the type of the specified extension attribute, when it occurs as an attribute of the specified parent type, should be assumed to be attrType.
    `void` | `registerExtElementType(Class parentType, QName elementType, Class extensionType)` Declare that the specified extensionType is the concrete class which should be used to represent extensibility elements with qnames matching elementQN, that are intended to exist as children of the specified parentType.
    `void` | `registerResourceBundle(String resourceBundleName)`
    `void` | `registerSerializer(Class parentType, QName elementType, ExtensionSerializer es)` Declare that the specified serializer should be used to serialize all extensibility elements with a qname matching elementQN, when encountered as children of the specified parentType.
    `void` | `setDefaultDeserializer(ExtensionDeserializer defaultDeser)` Set the deserializer to be used when none is found for an encountered element.
    `void` | `setDefaultSerializer(ExtensionSerializer defaultSer)` Set the serializer to be used when none is found for an extensibility element.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### REGISTRAR_PROPERTY

          public static final String REGISTRAR_PROPERTY

      The property containing the comma-separated listed of ExtensionRegistrars. The property name is `org.apache.woden.extensionregistrars`.
      See Also:
        Constant Field Values

    - #### serializerReg

          protected Map<Class,Map<QName,ExtensionSerializer>> serializerReg

    - #### deserializerReg

          protected Map<Class,Map<QName,ExtensionDeserializer>> deserializerReg

    - #### extElementReg

          protected Map<Class,Map<QName,Class>> extElementReg

    - #### defaultSer

          protected ExtensionSerializer defaultSer

    - #### defaultDeser

          protected ExtensionDeserializer defaultDeser

    - #### extAttributeReg

          protected Map<Class,Map<QName,Class>> extAttributeReg

    - #### compExtReg

          protected Map<Class,Map<URI,Class<ComponentExtensionContext>>> compExtReg

    - #### assertionReg

          protected Map<String,AssertionInfo> assertionReg

  - ### Constructor Detail

    - #### ExtensionRegistry

          public ExtensionRegistry(ErrorReporter errorReporter)

      Creates the extension registry, and sets the defaultSerializer and defaultDeserializer properties to instances of an UnknownExtensionSerializer, and an UnknownExtensionDeserializer, respectively.

  - ### Method Detail

    - #### getErrorReporter

          public ErrorReporter getErrorReporter()

    - #### setDefaultSerializer

          public void setDefaultSerializer(ExtensionSerializer defaultSer)

      Set the serializer to be used when none is found for an extensibility element. Set this to null to have an exception thrown when unexpected extensibility elements are encountered. Default value is an instance of UnknownExtensionSerializer.
      See Also:
        `UnknownExtensionSerializer`

    - #### getDefaultSerializer

          public ExtensionSerializer getDefaultSerializer()

      Get the serializer to be used when none is found for an extensibility element. Default value is an instance of UnknownExtensionSerializer.
      See Also:
        `UnknownExtensionSerializer`

    - #### setDefaultDeserializer

          public void setDefaultDeserializer(ExtensionDeserializer defaultDeser)

      Set the deserializer to be used when none is found for an encountered element. Set this to null to have an exception thrown when unexpected extensibility elements are encountered. Default value is an instance of UnknownExtensionDeserializer.
      See Also:
        `UnknownExtensionDeserializer`

    - #### getDefaultDeserializer

          public ExtensionDeserializer getDefaultDeserializer()

      Get the deserializer to be used when none is found for an encountered element. Default value is an instance of UnknownExtensionDeserializer.
      See Also:
        `UnknownExtensionDeserializer`

    - #### registerSerializer

          public void registerSerializer(Class parentType,
                                QName elementType,
                                ExtensionSerializer es)

      Declare that the specified serializer should be used to serialize all extensibility elements with a qname matching elementQN, when encountered as children of the specified parentType.
      Parameters:
        `parentType` - a class object indicating where in the WSDL definition this extension was encountered. For example, org.apache.woden.Binding.class would be used to indicate this extensibility element was found in the list of extensibility elements belonging to a org.apache.woden.Binding.
        `elementType` - the qname of the extensibility element
        `es` - the extension serializer to use
      See Also:
        `querySerializer(Class, QName)`

    - #### registerDeserializer

          public void registerDeserializer(Class parentType,
                                  QName elementType,
                                  ExtensionDeserializer ed)

      Declare that the specified deserializer should be used to deserialize all extensibility elements with a qname matching elementQN, when encountered as immediate children of the element represented by the specified parentType.
      Parameters:
        `parentType` - a class object indicating where in the WSDL document this extensibility element was encountered. For example, org.apache.woden.Binding.class would be used to indicate this element was encountered as an immediate child of a <wsdl:binding> element.
        `elementType` - the qname of the extensibility element
        `ed` - the extension deserializer to use
      See Also:
        `queryDeserializer(Class, QName)`

    - #### querySerializer

          public ExtensionSerializer querySerializer(Class parentType,
                                            QName elementType)
                                              throws WSDLException

      Look up the serializer to use for the extensibility element with the qname elementQN, which was encountered as a child of the specified parentType.
      Parameters:
        `parentType` - a class object indicating where in the WSDL definition this extension was encountered. For example, org.apache.woden.Binding.class would be used to indicate this extensibility element was found in the list of extensibility elements belonging to a org.apache.woden.Binding.
        `elementType` - the qname of the extensibility element
      Returns:
        the extension serializer, if one was found. If none was found, the behavior depends on the value of the defaultSerializer property. If the defaultSerializer property is set to a non-null value, that value is returned; otherwise, a WSDLException is thrown.
      Throws:
        `WSDLException`
      See Also:
        `registerSerializer(Class, QName, ExtensionSerializer)`, `setDefaultSerializer(ExtensionSerializer)`

    - #### queryDeserializer

          public ExtensionDeserializer queryDeserializer(Class parentType,
                                                QName elementType)
                                                  throws WSDLException

      Look up the deserializer for the extensibility element with the qname elementQN, which was encountered as an immediate child of the element represented by the specified parentType.
      Parameters:
        `parentType` - a class object indicating where in the WSDL document this extensibility element was encountered. For example, org.apache.woden.Binding.class would be used to indicate this element was encountered as an immediate child of a <wsdl:binding> element.
        `elementType` - the qname of the extensibility element
      Returns:
        the extension deserializer, if one was found. If none was found, the behavior depends on the value of the defaultDeserializer property. If the defaultDeserializer property is set to a non-null value, that value is returned; otherwise, a WSDLException is thrown.
      Throws:
        `WSDLException`
      See Also:
        `registerDeserializer(Class, QName, ExtensionDeserializer)`, `setDefaultDeserializer(ExtensionDeserializer)`

    - #### queryExtElementType

          public Class queryExtElementType(Class parentClass,
                                  QName elemQN)

      Look up the type of the extensibility element with the specified qname, which was defined as a child of the element represented by the specified parent class.
      Parameters:
        `parentClass` - a class object indicating where in the WSDL document this extensibility attribute was encountered. For example, org.apache.woden.Binding.class would be used to indicate this attribute was defined on a <wsdl:binding> element.
        `elemQN` - the qname of the extensibility attribute
      Returns:
        one of the constants defined on the AttributeExtensible class
      See Also:
        `registerExtAttributeType(Class, QName, Class)`, `AttributeExtensible`

    - #### getAllowableExtensions

          public Set<QName> getAllowableExtensions(Class parentType)

      TODO make the return val typesafe, and create similar method for ext attrs. Returns a set of QNames representing the extensibility elements that are allowed as children of the specified parent type. Basically, this method returns the keys associated with the set of extension deserializers registered for this parent type. Returns null if no extension deserializers are registered for this parent type.

    - #### registerExtElementType

          public void registerExtElementType(Class parentType,
                                    QName elementType,
                                    Class extensionType)

      Declare that the specified extensionType is the concrete class which should be used to represent extensibility elements with qnames matching elementQN, that are intended to exist as children of the specified parentType.
      Parameters:
        `parentType` - a class object indicating where in the WSDL definition this extension would exist. For example, org.apache.woden.Binding.class would be used to indicate this extensibility element would be added to the list of extensibility elements belonging to a org.apache.woden.Binding, after being instantiated.
        `elementType` - the qname of the extensibility element
        `extensionType` - the concrete class which should be instantiated
      See Also:
        `createExtElement(Class, QName)`

    - #### createExtElement

          public ExtensionElement createExtElement(Class parentType,
                                          QName elementType)
                                            throws WSDLException

      Create an instance of the type which was declared to be used to represent extensibility elements with qnames matching elementQN, when intended to exist as children of the specified parentType. This method allows a user to instantiate an extensibility element without having to know the implementing type.
      Parameters:
        `parentType` - a class object indicating where in the WSDL definition this extension will exist. For example, org.apache.woden.Binding.class would be used to indicate this extensibility element is going to be added to the list of extensibility elements belonging to a org.apache.woden.Binding, after being instantiated.
        `elementType` - the qname of the extensibility element
      Returns:
        a new instance of the type used to represent the specified extension
      Throws:
        `WSDLException`
      See Also:
        `registerExtElementType(Class, QName, Class)`

    - #### registerExtAttributeType

          public void registerExtAttributeType(Class ownerClass,
                                      QName attrQName,
                                      Class attrClass)

      Declare that the type of the specified extension attribute, when it occurs as an attribute of the specified parent type, should be assumed to be attrType.
      Parameters:
        `ownerClass` - a class object indicating where in the WSDL document this extensibility attribute was encountered. For example, org.apache.woden.Binding.class would be used to indicate this attribute was defined on a <wsdl:binding> element.
        `attrQName` - the qname of the extensibility attribute
        `attrClass` - one of the constants defined on the AttributeExtensible class
      See Also:
        `queryExtAttributeType(Class, QName)`, `AttributeExtensible`

    - #### queryExtAttributeType

          public Class<XMLAttr> queryExtAttributeType(Class parentClass,
                                             QName attrQN)

      Look up the type of the extensibility attribute with the specified qname, which was defined on an element represented by the specified parent class.
      Parameters:
        `parentClass` - a class object indicating where in the WSDL document this extensibility attribute was encountered. For example, org.apache.woden.Binding.class would be used to indicate this attribute was defined on a <wsdl:binding> element.
        `attrQN` - the qname of the extensibility attribute
      Returns:
        one of the constants defined on the AttributeExtensible class
      See Also:
        `registerExtAttributeType(Class, QName, Class)`, `AttributeExtensible`

    - #### createExtAttribute

          public XMLAttr createExtAttribute(Class ownerClass,
                                   QName attrQName,
                                   XMLElement ownerElement,
                                   String attrValue)
                                     throws WSDLException

      Throws:
        `WSDLException`

    - #### registerComponentExtension

          public void registerComponentExtension(Class parentClass,
                                        URI extNamespace,
                                        Class compExtCtxClass)

      Register the Java class which will represent extensions from a specified namespace that will extend the specified WSDL component class. The Java class must implement `ComponentExtensionContext`.
      Parameters:
        `parentClass` - the WSDL component class
        `extNamespace` - the extension namespace
        `compExtCtxClass` - the Java class representing these extensions

    - #### queryComponentExtension

          public Class<ComponentExtensionContext> queryComponentExtension(Class parentClass,
                                                                 URI extNamespace)

      Return the Java class that represents the extensions from the specified namespace that extend the specified WSDL component class. This class will be an implementation of `ComponentExtensionContext`.
      Parameters:
        `parentClass` - the WSDL component
        `extNamespace` - the extension namespace
      Returns:
        the Class of the component extensions

    - #### queryComponentExtensionNamespaces

          public URI[] queryComponentExtensionNamespaces(Class parentClass)

      Return the extension namespaces registered for the specified WSDL Component class.
      Parameters:
        `parentClass` - the class of WSDL component extended by these namespaces
      Returns:
        an array of namespace URIs

    - #### createComponentExtension

          public ComponentExtensionContext createComponentExtension(Class parentClass,
                                                           WSDLComponent parentComp,
                                                           URI extNamespace)
                                                             throws WSDLException

      Return a ComponentExtensionContext object from the Java class registered for the specified extension namespace against the specified WSDL component class.
      Parameters:
        `parentClass` - the WSDL component class.
        `extNamespace` - the extension namespace.
      Returns:
        a `ComponentExtensionContext` object
      Throws:
        `WSDLException` - if no Java class is registered for this namespace and WSDL component.

    - #### registerResourceBundle

          public void registerResourceBundle(String resourceBundleName)

    - #### queryResourceBundleNames

          public String[] queryResourceBundleNames()

    - #### registerAssertion

          public void registerAssertion(Assertion assertion,
                               Class targetClass)

      Register an Assertion along with the target Class that the assertion applies to. TODO assertion dependencies.
      Parameters:
        `assertion` - an Assertion object representing the assertion to be registered.
        `targetClass` - the Class representing the component in the WSDL that the assertion applies to.

    - #### queryAssertion

          public AssertionInfo queryAssertion(String assertionId)

    - #### queryAssertions

          public AssertionInfo[] queryAssertions()

Copyright ? Apache Software Foundation. All Rights Reserved.