Home » synapse-1.2-src » org.apache.synapse.transport.fix » [javadoc | source]

    1   /*
    2    *  Licensed to the Apache Software Foundation (ASF) under one
    3    *  or more contributor license agreements.  See the NOTICE file
    4    *  distributed with this work for additional information
    5    *  regarding copyright ownership.  The ASF licenses this file
    6    *  to you under the Apache License, Version 2.0 (the
    7    *  "License"); you may not use this file except in compliance
    8    *  with the License.  You may obtain a copy of the License at
    9    *
   10    *   http://www.apache.org/licenses/LICENSE-2.0
   11    *
   12    *  Unless required by applicable law or agreed to in writing,
   13    *  software distributed under the License is distributed on an
   14    *   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   15    *  KIND, either express or implied.  See the License for the
   16    *  specific language governing permissions and limitations
   17    *  under the License.
   18    */
   19   
   20   package org.apache.synapse.transport.fix;
   21   
   22   import org.apache.axis2.transport.OutTransportInfo;
   23   import org.apache.commons.logging.Log;
   24   import org.apache.commons.logging.LogFactory;
   25   import quickfix.SessionID;
   26   
   27   import java.util.Hashtable;
   28   
   29   /**
   30    * FIXOutTransportInfo is a holder for FIX SessionID to send an outgoing message
   31    * to a FIX engine.
   32    */
   33   public class FIXOutTransportInfo implements OutTransportInfo {
   34   
   35       private SessionID sessionID;
   36       private Log log;
   37   
   38       public FIXOutTransportInfo(SessionID sessionID) {
   39           this.sessionID = sessionID;
   40           this.log = LogFactory.getLog(this.getClass());
   41       }
   42   
   43       /**
   44        * Constructs a FIXOutTransportInfo out of a FIX EPR. Reads the parameters in the given
   45        * EPR and creates a SessionID out of them
   46        *
   47        * @param targetEPR a valid FIX EPR
   48        */
   49       public FIXOutTransportInfo(String targetEPR) {
   50           if (!targetEPR.startsWith(FIXConstants.FIX_PREFIX)) {
   51               handleException("Invalid FIX EPR " + targetEPR + ". The EPR prefix must be " +
   52                       FIXConstants.FIX_PREFIX);
   53           }
   54           else {
   55               Hashtable<String,String> properties = FIXUtils.getProperties(targetEPR);
   56               this.sessionID = new SessionID(
   57                       properties.get(FIXConstants.BEGIN_STRING),
   58                       properties.get(FIXConstants.SENDER_COMP_ID),
   59                       properties.get(FIXConstants.SENDER_SUB_ID),
   60                       properties.get(FIXConstants.SENDER_LOCATION_ID),
   61                       properties.get(FIXConstants.TARGET_COMP_ID),
   62                       properties.get(FIXConstants.TARGET_SUB_ID),
   63                       properties.get(FIXConstants.TARGET_LOCATION_ID),
   64                       properties.get(FIXConstants.SESSION_QUALIFIER));
   65               this.log = LogFactory.getLog(this.getClass());
   66           }
   67       }
   68   
   69       public SessionID getSessionID() {
   70           return sessionID;
   71       }
   72   
   73       public void setContentType(String s) {
   74   
   75       }
   76   
   77       private void handleException(String s) {
   78           log.error(s);
   79           throw new AxisFIXException(s);
   80       }
   81   }

Home » synapse-1.2-src » org.apache.synapse.transport.fix » [javadoc | source]