home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: Java / Java.zip / mqaoad21.zip / MQAOAdapterVerify.java < prev    next >
Text File  |  2002-12-19  |  4KB  |  126 lines

  1. package com.ibm.extricity.adapters.mqseries.mqak;
  2.  
  3. /**
  4.  * Insert the type's description here.
  5.  * Creation date: (3/6/01 11:23:19 AM)
  6.  * @author: Administrator
  7.  */
  8. import com.ibm.epic.adapters.eak.mcs.*;
  9. import com.ibm.epic.adapters.eak.nativeadapter.*;
  10. import com.ibm.epic.adapters.eak.common.AdapterException;
  11. import java.io.*;
  12. import java.util.*;
  13.  
  14. public class MQAOAdapterVerify
  15. {
  16. /**
  17.  * MQAPAdapterVerify constructor comment.
  18.  */
  19. public MQAOAdapterVerify()
  20. {
  21.     super();
  22. }
  23.  
  24.  
  25. /**
  26.  * Insert the method's description here.
  27.  * Creation date: (10/23/00 3:07:55 PM)
  28.  * @param args java.lang.String[]
  29.  */
  30. public static void main(String[] args)
  31. {
  32.     InputStream propin = null;
  33.     InputStreamReader msgin = null;
  34.     Properties prop = null;
  35.     String filename = args[0];
  36.  
  37.     if(filename == null)
  38.     {
  39.         filename = "MQAOAdapterVerify.properties";
  40.     }
  41.     try
  42.     {
  43.         try
  44.         {
  45.             propin = new FileInputStream(filename);
  46.         }
  47.         catch(FileNotFoundException e1)
  48.         {
  49.             try
  50.             {
  51.                 propin = new FileInputStream("MQAOAdapterVerify.properties");
  52.             }
  53.             catch(FileNotFoundException e2)
  54.             {
  55.                 System.out.println("!!!Properties file not found-- Using builtin defaults!!!");
  56.                 e1.printStackTrace();
  57.             }
  58.         }
  59.         if(propin != null)
  60.         {
  61.             prop = new Properties();
  62.             prop.load(propin);
  63.             try
  64.             {
  65.                 EpicNativeAdapter theENA = new EpicNativeAdapter(prop.getProperty("ApplicationID","MQSIPAM"), "IBM Extricity MQAK Adapter");
  66.                 EpicMessageExt theEM;
  67.                 // Create the message
  68.                 theEM = new EpicMessageExt(prop.getProperty("ApplicationID","MQSIPAM"), prop.getProperty("MessageType","GatewayMessage"));
  69.                 theEM.setLMSCorrelationID(theEM.LMS_CORELATION_ID_NONE);
  70.                 // Fill the message header
  71.                 theEM.setAckRequested(prop.getProperty("AckRequested","False"));
  72.                 theEM.setDestinationComponent(prop.getProperty("DestinationComponent","GATEWAY"));
  73.                 theEM.setSrcTradingPartnerID(prop.getProperty("SrcTradingPartnerID","0123456789"));
  74.                 theEM.setDstTradingPartnerID(prop.getProperty("DstTradingPartnerID","9876543210"));
  75.                 theEM.setBOCorrelationID(prop.getProperty("BOCorrelationID","TEST COR ID"));
  76.                 theEM.setExtricityProcessID(prop.getProperty("ExtricityProcessID","NONE"),false);
  77.                 theEM.setProtocolAndVersion(prop.getProperty("ProtocolAndVersion","XCBL"));
  78.                 theEM.setProcessTransactionID(prop.getProperty("ProcessTransactionID","PO"));
  79.                 theEM.setUniqueMsgID(prop.getProperty("UniqueMsgID","1234"));
  80.                 // Fill the message data
  81.                 filename = prop.getProperty("BodyDataFile",null);
  82.                 if(filename == null)
  83.                 {
  84.                     theEM.setBodyData(prop.getProperty("BodyData","<OAG_PO_SIM><PONumber>PO123456789</PONumber><SupplierId>987654321</SupplierId></OAG_PO_SIM>"));
  85.                 }
  86.                 else
  87.                 {
  88.                     try
  89.                     {
  90.                         msgin = new InputStreamReader(new FileInputStream(filename));
  91.                     }
  92.                     catch(FileNotFoundException e1)
  93.                     {
  94.                         System.out.println("Body file not found e="+e1.toString());
  95.                         return;
  96.                     }
  97.                     char[] buf = new char[8192];
  98.                     int num;
  99.                     StringBuffer str = new StringBuffer(8192);
  100.                     while((num = msgin.read(buf)) >= 0)
  101.                     {
  102.                         str.append(buf,0,num);
  103.                     }
  104.                     theEM.setBodyData(str.toString());
  105.                 }
  106.                 //if(_DEBUG)
  107.                 {
  108.                     System.out.println("main theEM: " + theEM.toString());
  109.                 }
  110.                 // Send the message
  111.                 theENA.begin();
  112.                 theENA.sendMsg(theEM);
  113.                 theENA.commit();
  114.             }
  115.             catch (AdapterException e)
  116.             {
  117.                 System.out.println("main exception: " + e.toString());
  118.             }
  119.         }
  120.     }
  121.     catch(Exception e)
  122.     {
  123.         e.printStackTrace();
  124.     }
  125. }
  126. }