com.ibm.mq.headers

Interface MQHeaderFactory

  • All Known Implementing Classes:
    PCFHeaderFactory, PCFHeaderFactory


    public interface MQHeaderFactory
    An MQHeaderFactory is used to create new MQHeader instances dynamically. This is used when decoding (parsing) header content in messages, or for tasks such as creating new header instances in tooling applications. A tooling application may, for example, offer a catalog of header types that can be used to compose a message. Most applications will not need to use the MQHeaderFactory interface directly; the MQHeaderRegistry encapsulates a set of MQHeaderFactory instances that cover the standard MQ header types, and new header types can be registered directly without needing to define a new MQHeaderFactory type.

    An individual MQHeaderFactory may handle a single message format or more than one. MQHeaderFactories are registered with a Registry that allows them to be looked up by format or type. The default MQHeaderRegistry instance has pre-registered factories for the standard MQ header types and formats, including PCF.

    See Also:
    MQHeaderRegistry, MQHeaderIterator
    • Method Detail

      • create

        MQHeader create(java.lang.String type)
                 throws java.lang.InstantiationException
        Parameters:
        type -
        Returns:
        an MQHeader instance of the named type. The types known the header factory can be obtained from the getSupportedTypes method. These types correspond to the values returned by the type method on MQHeader instances.
        Throws:
        java.lang.InstantiationException
      • decode

        MQHeader decode(MQHeaderContext message)
                 throws java.lang.Exception,
                        MQDataException,
                        java.io.IOException
        Decodes (parses) an MQHeader instance from a message. The message context object carries the format, encoding and CCSID associated with the current position in the message or byte stream. The operation of an MQHeaderFactory to fulfil this method is essentially:
        1. Identify the header type that occurs next in the message. This may be known by the factory directly, and associated with the format; or the MQHeaderFactory may need to peek at the message content to detect the type.
        2. Having identified the correct type, instantiate an MQHeader instance of that type.
        3. Invoke the header object's read method on the message.
        4. Optionally, update the format, encoding and characterSet members of the message context object.
        5. Return the header instance.
        This method may return null if no more headers are present or this MQHeaderFactory cannot identify a header at the current position in the message.
        Parameters:
        message - the header context.
        Returns:
        the parsed MQHeader
        Throws:
        java.lang.Exception - (to allow the com.ibm.pcf classes to throw MQException)
        MQDataException
        java.io.IOException
      • getSupportedFormats

        java.util.Collection<?> getSupportedFormats()
        Returns:
        the set of format names associated with the header types supported by this MQHeaderFactory. An MQHeaderFactory instance is capable of decoding messages of these formats.
      • getSupportedTypes

        java.util.Collection<?> getSupportedTypes()
        Returns:
        the set of header types supported by this MQHeaderFactory. An MQHeaderFactory instance can create new instances of these types.
(c) Copyright IBM Corp. 2008, 2016. All Rights Reserved.