/***************************************************************************/ /* */ /* (c) Copyright IBM Corp. 2002 All rights reserved. */ /* */ /* This sample program is owned by International Business Machines */ /* Corporation or one of its subsidiaries ("IBM") and is copyrighted */ /* and licensed, not sold. */ /* */ /* You may copy, modify, and distribute this sample program in any */ /* form without payment to IBM, for any purpose including developing, */ /* using, marketing or distributing programs that include or are */ /* derivative works of the sample program. */ /* */ /* The sample program is provided to you on an "AS IS" basis, without */ /* warranty of any kind. IBM HEREBY EXPRESSLY DISCLAIMS ALL WARRANTIES, */ /* EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED */ /* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ /* Some jurisdictions do not allow for the exclusion or limitation of */ /* implied warranties, so the above limitations or exclusions may not */ /* apply to you. IBM shall not be liable for any damages you suffer as */ /* a result of using, modifying or distributing the sample program or */ /* its derivatives. */ /* */ /***************************************************************************/ /* */ /* Program name: JmsIMSBridge */ /* */ /* Description: Sample jms program to illustrate how to format a message */ /* for the IMS Bridge. */ /* */ /* Function: This program uses JMS APIs to create and format a message */ /* that can be sent to the IMS Bridge. */ /* */ /* Prereqs: MQSeries V5.2 with SupportPac MA88 or WebSphere MQ V5.3 */ /* */ /* Setup: Create a local queue manager and queue with channels */ /* communicating with MVS IMS system. Refer to SupportPac */ /* MA1C readme file for detail on setup. */ /* */ /* This program is run as follows: */ /* */ /* java JmsIMSBridge -icf com.sun.jndi.fscontext.RefFSContextFactory */ /* -url file:e://support//jms//sample */ /* -qcf qcfIMS */ /* -q qIMS */ /* */ /* where icf is the JNDI service provider */ /* url is the URL of the session's initial context */ /* qcf is the queue connection factory */ /* q is the queue to put the output message on */ /* */ /* The queue connection factory and queue parameters to this program need */ /* to be setup so that they can be found. This is done via the JMS Admin- */ /* istration tool that is supplied with MQSeries Java (SupportPac MA88) */ /* and is described in the Using Java manual. This program was tested */ /* using a file system context set up in a jmsadmin.config as follows: */ /* */ /* INITIAL_CONTEXT_FACTORY=com.sun.jndi.fscontext.RefFSContextFactory */ /* PROVIDER_URL=file:e://support//jms//sample */ /* SECURITY_AUTHENTICATION=none */ /* */ /* The actual JMSAdmin utility was run with the following definitions: */ /* */ /* def qcf(qcfIMS) qmanager(ims.qmgr) */ /* def q(qIMS) queue(SYSTEM.DEFAULT.LOCAL.QUEUE) targclient(MQ) */ /* */ /* Build: Compile with javac JmsIMSBridge.java */ /* */ /***************************************************************************/ import java.io.*; import javax.jms.*; import javax.naming.*; import javax.naming.directory.*; import java.util.Hashtable; import java.util.Properties; public class JmsIMSBridge { private static String icf = null; private static String url = null; private static String lookupQCF = null; private static String lookupQueue = null; public JmsIMSBridge() { /***********************************************/ /* We'll get anything with the -D syntax first */ /***********************************************/ url = System.getProperty("url"); icf = System.getProperty("icf"); lookupQueue = System.getProperty("q"); lookupQCF = System.getProperty("qcf"); /****************************************************/ /* Now go and get the JmsIMSBridge.properties file. */ /****************************************************/ try { Properties props = new Properties(System.getProperties()); props.load(new BufferedInputStream(new FileInputStream("JmsIMSBridge.properties"))); System.setProperties(props); } catch (IOException e) { /*******************************************************************/ /* We'll ignore this exception and attempt to get the program */ /* inputs from the command line. */ /* System.out.println("JmsIMSBridge.properties" + e.getMessage()); */ /*******************************************************************/ } /******************************************************/ /* If any of the necessary properties are null, we'll */ /* take the value from the file since they weren't */ /* specified with -D. */ /******************************************************/ if (url == null) {url = System.getProperty("url");} if (icf == null) {icf = System.getProperty("icf");} if (lookupQueue == null) {lookupQueue = System.getProperty("q");} if (lookupQCF == null) {lookupQCF = System.getProperty("qcf");} } public JmsIMSBridge(String[] args) { this(); /**********************************/ /* Get the command-line arguments */ /**********************************/ for( int i=0; i