Package org.apache.synapse.transport.fix

## Class FIXUtils

- java.lang.Object
- - org.apache.synapse.transport.fix.FIXUtils

-     public class FIXUtils
      extends Object

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `FIXUtils()` |

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static boolean` | `compareURLs​(String url1, String url2)` | Compares two given FIX URL strings.
    `quickfix.Message` | `createFIXMessage​(org.apache.axis2.context.MessageContext msgCtx)` | Extract the FIX message embedded in an Axis2 MessageContext
    `static String[]` | `generateEPRs​(quickfix.SocketAcceptor acceptor, String serviceName, String ip)` | Generate EPRs for the specified FIX service.
    `static String[]` | `getEPRs​(quickfix.SessionSettings settings)` |
    `static String` | `getFixApplication​(org.apache.axis2.context.MessageContext msgCtx)` | Extracts the application type for the message from the message context
    `static FIXUtils` | `getInstance()` |
    `static Map<String,​String>` | `getMessageForwardingParameters​(quickfix.Message message)` | Extracts the fields related to message forwarding (third party routing) from the FIX header.
    `static org.apache.axiom.om.OMNamespace` | `getNamespaceOfFIXPayload​(org.apache.axiom.soap.SOAPBody fixBody)` | Read the FIX message payload and identify the namespace if exists
    `static int` | `getSequenceNumber​(org.apache.axis2.context.MessageContext msgCtx)` | Reads the SOAP body of a message and attempts to retreive the application level sequence number
    `static String` | `getServiceName​(org.apache.axis2.context.MessageContext msgCtx)` | Extracts the name of the service which processed the message from the MessageContext
    `static String[]` | `getSocketAddressElements​(String fixEPR)` | Reads a FIX EPR and returns the host and port on a String array
    `static String` | `getSourceSession​(org.apache.axis2.context.MessageContext msgCtx)` | Reads the SOAP body of a message and attempts to retreive the session identifier string
    `static Map<String,​String>` | `getTransportHeaders​(String serviceName, String fixApplication)` | Creates a Map of transport headers for a message
    `void` | `setSOAPEnvelope​(quickfix.Message message, int counter, String sessionID, org.apache.axis2.context.MessageContext msgCtx)` | FIX messages are non-XML.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### FIXUtils

          public FIXUtils()

  - ### Method Detail

    - #### getInstance

          public static FIXUtils getInstance()

    - #### setSOAPEnvelope

          public void setSOAPEnvelope​(quickfix.Message message,
                                      int counter,
                                      String sessionID,
                                      org.apache.axis2.context.MessageContext msgCtx)
                               throws org.apache.axis2.AxisFault

      FIX messages are non-XML. So convert them into XML using the AXIOM API. Put the FIX message into an Axis2 MessageContext.The basic format of the generated SOAP envelope;

      ....
      ....
      ....
      Parameters:
        `message` - the FIX message
        `counter` - application level sequence number of the message
        `sessionID` - the incoming session
        `msgCtx` - the Axis2 MessageContext to hold the FIX message
      Throws:
        `org.apache.axis2.AxisFault` - the exception thrown when invalid soap envelopes are set to the msgCtx

    - #### createFIXMessage

          public quickfix.Message createFIXMessage​(org.apache.axis2.context.MessageContext msgCtx)
                                            throws IOException

      Extract the FIX message embedded in an Axis2 MessageContext
      Parameters:
        `msgCtx` - the Axis2 MessageContext
      Returns:
        a FIX message
      Throws:
        `IOException` - the exception thrown when handling erroneous binary content

    - #### generateEPRs

          public static String[] generateEPRs​(quickfix.SocketAcceptor acceptor,
                                              String serviceName,
                                              String ip)

      Generate EPRs for the specified FIX service. A FIX end point can be uniquely identified by a pair. Add some additional FIX session details so the EPRs are more self descriptive. A FIX EPR generated here looks like; fix://10.100.1.80:9898?BeginString=FIX.4.4&SenderCompID=BANZAI&TargetCompID=EXEC& SessionQualifier=mySession&Serviec=StockQuoteProxy
      Parameters:
        `acceptor` - the SocketAcceptor associated with the service
        `serviceName` - the name of the service
        `ip` - the IP address of the host
      Returns:
        an array of EPRs for the specified service in String format

    - #### getEPRs

          public static String[] getEPRs​(quickfix.SessionSettings settings)
                                  throws quickfix.FieldConvertError,
                                         quickfix.ConfigError

      Throws:
        `quickfix.FieldConvertError`
        `quickfix.ConfigError`

    - #### compareURLs

          public static boolean compareURLs​(String url1,
                                            String url2)

      Compares two given FIX URL strings. The second URL is considered equal to the first URL if all the properties in the first URL also exist in the second URL and if they have equals values.
      Parameters:
        `url1` - a FIX URL String
        `url2` - a FIX URL String
      Returns:
        a boolean value

    - #### getMessageForwardingParameters

          public static Map<String,​String> getMessageForwardingParameters​(quickfix.Message message)

      Extracts the fields related to message forwarding (third party routing) from the FIX header.
      Parameters:
        `message` - the FIX message
      Returns:
        a Map of forwarding parameters

    - #### getServiceName

          public static String getServiceName​(org.apache.axis2.context.MessageContext msgCtx)
                                       throws org.apache.axis2.AxisFault

      Extracts the name of the service which processed the message from the MessageContext
      Parameters:
        `msgCtx` - Axis2 MessageContext of a message
      Returns:
        name of the AxisService
      Throws:
        `org.apache.axis2.AxisFault` - on error

    - #### getFixApplication

          public static String getFixApplication​(org.apache.axis2.context.MessageContext msgCtx)

      Extracts the application type for the message from the message context
      Parameters:
        `msgCtx` - Axis2 Message Context
      Returns:
        application type of the message

    - #### getTransportHeaders

          public static Map<String,​String> getTransportHeaders​(String serviceName,
                                                                     String fixApplication)

      Creates a Map of transport headers for a message
      Parameters:
        `serviceName` - name of the service to which the message belongs to
        `fixApplication` - FIX application type
      Returns:
        a Map of transport headers

    - #### getSocketAddressElements

          public static String[] getSocketAddressElements​(String fixEPR)
                                                   throws org.apache.axis2.AxisFault

      Reads a FIX EPR and returns the host and port on a String array
      Parameters:
        `fixEPR` - a FIX EPR
      Returns:
        an array of Strings containing addressing elements
      Throws:
        `org.apache.axis2.AxisFault` - on error

    - #### getSequenceNumber

          public static int getSequenceNumber​(org.apache.axis2.context.MessageContext msgCtx)

      Reads the SOAP body of a message and attempts to retreive the application level sequence number
      Parameters:
        `msgCtx` - Axis2 MessageContext
      Returns:
        application level sequence number or -1

    - #### getSourceSession

          public static String getSourceSession​(org.apache.axis2.context.MessageContext msgCtx)

      Reads the SOAP body of a message and attempts to retreive the session identifier string
      Parameters:
        `msgCtx` - Axis2 MessageContext
      Returns:
        a String uniquely identifying a session or null

    - #### getNamespaceOfFIXPayload

          public static org.apache.axiom.om.OMNamespace getNamespaceOfFIXPayload​(org.apache.axiom.soap.SOAPBody fixBody)

      Read the FIX message payload and identify the namespace if exists
      Parameters:
        `fixBody` - FIX message payload
      Returns:
        namespace as a OMNamespace