com.ibm.ia.connectivity.context

Class MessageContextProvider

  • java.lang.Object
    • com.ibm.ia.connectivity.context.MessageContextProvider


  • public class MessageContextProvider
    extends java.lang.Object

    Provides access to the current inbound message context to classifier and transformation operations. The static methods of this class mirror the methods of the MessageContext interface.

    Note: These methods are not intended for use by client applications or agent implementations. Calling these methods outside the context of a classifier or transformation operation results in a RuntimeException.

    Using the message context in a message classifier

    A predefined namespace prefix, context, is used to address the functions defined by the MessageContext interface in the classifier expression.

    For example, the message classifier in the following inbound binding definition uses the context namespace to match messages that arrive with the JMSType value, PurchaseEvent:

     define inbound binding 'binding1' 
         using 
             message format application/xml , 
             protocol JMS , 
         classifying messages : 
             if matches "context:getJMSType() == 'PurchaseEvent'" 
                 transform using "transformPurchaseEvent.xsl" 
             else discard message ,
         accepting events : 
             - purchase event .
     

    Note: The context prefix is predefined but can be overridden by a classifier namespace prefix definition. The namespace used to access the message context functions from a classifier expression is: com.ibm.ia.connectivity.context.MessageContextProvider

    Using the message context in an XSLT transformation

    To use the message context when transforming the inbound message into an event, the XSLT must define a namespace for the com.ibm.ia.connectivity.context.MessageContextProvider class. The specified namespace prefix is used to address the functions defined by the MessageContext interface.

    For example, to generate a <timestamp> element that contains the ISO 8601 value of the message timestamp:

    1. Define a namespace prefix, context, in the <xsl:stylesheet> element:
       <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
            xmlns:context="com.ibm.ia.connectivity.context.MessageContextProvider"
            exclude-result-prefixes="context"
            ... >
       
    2. Use the function context:getMessageTimestampISO8601(zoneId) when generating the <timestamp> element in the template:
       <timestamp><xsl:value-of select="context:getMessageTimestampISO8601('UTC')"></timestamp>
       

    Note: The message context functions are not available when transforming an outbound message.

    • Field Detail

      • PREFIX

        public static final java.lang.String PREFIX

        The default prefix used for the message context provider namespace.

        See Also:
        Constant Field Values
      • NAMESPACE

        public static final java.lang.String NAMESPACE

        The namespace for message context provider functions.

        See Also:
        Constant Field Values
    • Method Detail

      • getProtocol

        public static java.lang.String getProtocol()
        Use this method to access MessageContext.getProtocol() in message classification or transformation.
      • getSolutionName

        public static java.lang.String getSolutionName()
        Use this method to access MessageContext.getSolutionName() in message classification or transformation.
      • getSolutionVersion

        public static java.lang.String getSolutionVersion()
        Use this method to access MessageContext.getSolutionVersion() in message classification or transformation.
      • getBindingName

        public static java.lang.String getBindingName()
        Use this method to access MessageContext.getBindingName() in message classification or transformation.
      • getEndpointName

        public static java.lang.String getEndpointName()
        Use this method to access MessageContext.getEndpointName() in message classification or transformation.
      • getJMSType

        public static java.lang.String getJMSType()
        Use this method to access MessageContext.getJMSType() in message classification or transformation.
      • getJMSMessageID

        public static java.lang.String getJMSMessageID()
        Use this method to access MessageContext.getJMSMessageID() in message classification or transformation.
      • getJMSCorrelationID

        public static java.lang.String getJMSCorrelationID()
        Use this method to access MessageContext.getJMSCorrelationID() in message classification or transformation.
      • getHeaderNames

        public static java.util.ArrayList<java.lang.String> getHeaderNames()
        Use this method to access MessageContext.getHeaderNames() in message classification or transformation.
      • getHeaderName

        public static java.lang.String getHeaderName()
        The no-argument form of this method is not intended for use but is implemented for completeness. Equivalent to getHeaderName(0).
        See Also:
        getHeaderName(int)
      • getHeader

        public static java.lang.String getHeader(java.lang.String name)
        Use this method to access MessageContext.getHeader(String name) in message classification or transformation.
      • getHeader

        public static java.lang.String getHeader()
        The no-argument form of this method is not intended for use but is implemented for completeness. Equivalent to getHeader("").
        See Also:
        getHeader(String)
      • getHeaders

        public static java.util.ArrayList<java.lang.String> getHeaders(java.lang.String name)
        Use this method to access MessageContext.getHeaders(String name) in message classification or transformation.
      • getHeaders

        public static java.util.ArrayList<java.lang.String> getHeaders()
        The no-argument form of this method is not intended for use but is implemented for completeness. Equivalent to getHeaders("").
        See Also:
        getHeaders(String)
      • getRequestURL

        public static java.lang.String getRequestURL()
        Use this method to access MessageContext.getRequestURL() in message classification or transformation.
      • getContextPath

        public static java.lang.String getContextPath()
        Use this method to access MessageContext.getContextPath() in message classification or transformation.
      • getPathInfo

        public static java.lang.String getPathInfo()
        Use this method to access MessageContext.getPathInfo() in message classification or transformation.
      • getServletPath

        public static java.lang.String getServletPath()
        Use this method to access MessageContext.getServletPath() in message classification or transformation.
      • getQueryString

        public static java.lang.String getQueryString()
        Use this method to access MessageContext.getQueryString() in message classification or transformation.

© Copyright IBM 2016