com.edustructures.sifworks
Interface MessageInfo

All Known Implementing Classes:
SIFMessageInfo

public interface MessageInfo

Provides information about an XML message, such as envelope and header attributes, the source of the message, and optionally the raw XML document that comprises the message. A concrete implementation of this interface is available for each messaging protocol supported by the ADK. For instance, the SIFMessageInfo class provides access to specific information regarding Schools Interoperability Framework SIF_Message envelopes and SIF_Header headers.

Using MessageInfo in Message Handlers

A MessageInfo instance is passed as a parameter to message handlers such as Publisher.onRequest and Subscriber.onEvent. Cast the parameter to a concrete type to obtain protocol-specific information about the message. For example, the following shows how to obtain the value of the SIF_SourceId and SIF_MsgId elements from the SIF_Header, as well as the version of SIF declared by the SIF_Message envelope:

    public void onEvent( Event event, Zone zone, MessageInfo info )
    {
        // Cast to SIFMessageInfo to get SIF-specific header info
        SIFMessageInfo inf = (SIFMessageInfo)info;

        // Obtain SIF-specific header values
        String sourceId = inf.getSourceId();
        String msgId = inf.getMsgId();
        SIFVersion version = inf.getSIFVersion();

        // Display some information about this SIF_Event...
        System.out.println( "SIF_Event message with ID " + msgId +
            " received from agent " + sourceId +
            " in zone " + zone.getZoneId() + "."
            " This is a SIF " + version.toString() + " message." );

        ...

Raw XML Message Content

When the adk.keepMessageContent agent property is enabled, the getMessage() method will return the XML document that was received as a single String. When this option is disabled (the default), the ADK does not keep a copy of raw message content in memory and will return a null value.

Version:
1.0

Method Summary
 java.lang.String getAttribute(java.lang.String attr)
          Gets the value of an attribute.
 java.lang.String[] getAttributeNames()
          Gets the names of all attributes.
 java.lang.String getMessage()
          Gets the content of the raw XML message
 java.lang.String getPayloadTag()
          Gets the payload message element tag
 byte getPayloadType()
          Gets the payload message type
 Zone getZone()
          Gets the zone from which the message originated
 void setAttribute(java.lang.String attr, java.lang.String value)
          Sets the value of an attribute.
 

Method Detail

getPayloadType

byte getPayloadType()
Gets the payload message type

Returns:
A MSGTYP_ constant (e.g. SIFDTD.MSGTYPE_REQUEST)

getPayloadTag

java.lang.String getPayloadTag()
Gets the payload message element tag

Returns:
The element tag of the message (e.g. "SIF_Request")

getZone

Zone getZone()
Gets the zone from which the message originated


getAttribute

java.lang.String getAttribute(java.lang.String attr)
Gets the value of an attribute. Implementations of this interface may define attributes to hold values specific to the messaging protocol.

Parameters:
attr - The name of the attribute
Returns:
The value of the attribute, or null if not defined
See Also:
setAttribute(java.lang.String, java.lang.String), getAttributeNames()

setAttribute

void setAttribute(java.lang.String attr,
                  java.lang.String value)
Sets the value of an attribute. Implementations of this interface may define attributes to hold values specific to the messaging protocol.

Parameters:
attr - The attribute name
value - The attribute value
See Also:
getAttributeNames(), getAttribute(java.lang.String)

getAttributeNames

java.lang.String[] getAttributeNames()
Gets the names of all attributes. Implementations of this interface may define attributes to hold values specific to the messaging protocol.

Returns:
An array of the attribute names that can be individually queried by the getAttribute method
See Also:
getAttribute(java.lang.String), setAttribute(java.lang.String, java.lang.String)

getMessage

java.lang.String getMessage()
Gets the content of the raw XML message

Returns:
The raw XML message content as it was received by the ADK. If the adk.keepMessageContent agent property is disabled (the default), null is returned.


Copyright © 2001-2007 Edustructures LLC. All Rights Reserved. SIFWorks® and ADK® are registered trademarks of Edustructures LLC. SIF™ and Schools Interoperability Framework are trademarks of the Schools Interoperability Framework Association.