com.ibm.mq.headers

Interface MQHeaderFactory

All known implementing classes:
PCFHeaderFactory, PCFHeaderFactory

  1. 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

Nested Class Summary

Modifier and Type Interface and Description
  1. static interface
MQHeaderFactory.Registry
Interface representing a registry for MQHeaderFactories and their supported types and formats.

Method Summary

Modifier and Type Method and Description
  1. MQHeader
create(java.lang.String type)
Creates an MQHeader instance of the named type.
  1. MQHeader
decode(MQHeaderContext message)
Decodes (parses) an MQHeader instance from a message.
  1. java.util.Collection
getSupportedFormats()
Returns the set of format names associated with the header types supported by this MQHeaderFactory.
  1. java.util.Collection
getSupportedTypes()
Returns the set of header types supported by this MQHeaderFactory.

Method Detail

create

  1. MQHeader create(java.lang.String type)
  2. throws java.lang.InstantiationException
Creates 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

  1. MQHeader decode(MQHeaderContext message)
  2. throws java.lang.Exception
  3. MQDataException
  4. 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.
Throws:
java.lang.Exception - (to allow the com.ibm.pcf classes to throw MQException)
java.io.IOException

getSupportedFormats

  1. 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

  1. java.util.Collection getSupportedTypes( )
Returns the set of header types supported by this MQHeaderFactory. An MQHeaderFactory instance can create new instances of these types.