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:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceInterface representing a registry for MQHeaderFactories and their supported types and formats. -
Method Summary
Modifier and TypeMethodDescriptiondecode(MQHeaderContext message) Decodes (parses) an MQHeader instance from a message.Collection<?> Collection<?>
-
Method Details
-
create
- Parameters:
type- of the header to create.- 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:
InstantiationException- if the header object cannot be created
-
decode
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:- 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.
- Having identified the correct type, instantiate an MQHeader instance of that type.
- Invoke the header object's read method on the message.
- Optionally, update the format, encoding and characterSet members of the message context object.
- Return the header instance.
- Parameters:
message- the header context.- Returns:
- the parsed MQHeader
- Throws:
Exception- (to allow the com.ibm.pcf classes to throw MQException)MQDataException- if a PCF error occurs while decoding the messageIOException- if an error occurs while decoding the message
-
getSupportedFormats
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
Collection<?> getSupportedTypes()- Returns:
- the set of header types supported by this MQHeaderFactory. An MQHeaderFactory instance can create new instances of these types.
-