Commit a7aff4f5 by O'Reilly Media, Inc.

Initial commit

parents
9781565926769
\ No newline at end of file
package myGenFac;
import com.ibm.cics.server.ts.iiop.*;
/**
* This type was created in VisualAge.
*/
public class DoIt {
/**
* Constructor
*/
/* WARNING: THIS METHOD WILL BE REGENERATED. */
public DoIt() {
super();
}
/**
* Starts the application.
* @param args an array of command-line arguments
*/
public static void main(java.lang.String[] args) {
String[] myArray=new String[6];
myArray[0]="-host";
myArray[1]="winmvs26.hursley.ibm.com";
myArray[2]="-port";
myArray[3]="32661";
myArray[4]="-d";
myArray[5]="c:\\IORFiles";
com.ibm.cics.server.ts.iiop.GenFacIOR.main(myArray);
}
}
\ No newline at end of file
module accountObject {
struct AccountData {
string respcode;
string reascode;
string cicsfunc;
string acctid;
string lastname;
string firstname;
string midinit;
string title;
string telnum;
string addr1;
string addr2;
string addr3;
string auth1;
string auth2;
string auth3;
string auth4;
string cards;
string issuemonth;
string issueday;
string issueyear;
string reason;
string code;
string approver;
string scode1;
string scode2;
string scode3;
string status;
string limit;
};
interface AccountInterface {
//getter methods
accountObject::AccountData getAccount(in string acctno);
};
};
package testIIOPClient;
import accountObject.*;
import java.io.*;
import org.omg.CORBA.*;
import org.omg.CosLifeCycle.*;
import org.omg.CosNaming.*;
/**
* This type was created in VisualAge.
*/
public class ClientStub {
/**
* ClientStub constructor comment.
*/
public ClientStub(String acctID) {
String factoryIOR;
AccountInterface ai = null;
try
{
// create and initialize the ORB
System.out.println("Client: creating and initializing the ORB");
ORB orb = ORB.init();
// create the generic factory
System.out.println("Client: creating the generic factory");
factoryIOR = getFactoryIOR();
org.omg.CORBA.Object genFacRef = orb.string_to_object(factoryIOR);
System.out.println("Client: narrowing the generic factory");
GenericFactory fact = GenericFactoryHelper.narrow(genFacRef);
// use generic factory to make accountObject object
System.out.println("Client: using generic factory to make testObject object");
NameComponent nc = new NameComponent("accountObject::AccountInterface", "object interface");
NameComponent key[] = {nc};
NVP mycriteria[] = {};
System.out.println("about to create object reference");
org.omg.CORBA.Object objRef = fact.create_object(key, mycriteria);
System.out.println("about to narrow");
ai = AccountInterfaceHelper.narrow(objRef);
getDetails(ai, acctID);
}
// Catch NoFactory
catch (org.omg.CosLifeCycle.NoFactory nf)
{
System.out.println("Client: NoFactory thrown by create_object for accountObject::AccountInterface");
System.out.println(" - check server program with alias accountObject.jll is available on the CICS server");
}
// Catch any unexpected exceptions
catch (Exception e)
{
System.out.println("Client: Unexpected exception : " + e);
e.printStackTrace(System.out);
}
}
/**
* This method was created in VisualAge.
* @param ai accountObject.AccountInterface
*/
public void getDetails(accountObject.AccountInterface ai, String acctID) {
// Invoke the getAccount method
System.out.println("Client: invoking getAccount method on accountObject object");
AccountData acctData = ai.getAccount(acctID);
if (acctData.respcode.equals("0000") && acctData.reascode.equals("0000")) {
System.out.println("Account ID: " + acctData.acctid);
System.out.println("First name: " + acctData.firstname);
System.out.println("Last name: " + acctData.lastname);
System.out.println("Mid init: " + acctData.midinit);
System.out.println("Title: " + acctData.title);
System.out.println("Tel Number: " + acctData.telnum);
System.out.println("Address 1: " + acctData.addr1);
System.out.println("Address 2: " + acctData.addr2);
System.out.println("Address 3: " + acctData.addr3);
System.out.println("Auth 1: " + acctData.auth1);
System.out.println("Auth 2: " + acctData.auth2);
System.out.println("Auth 3: " + acctData.auth3);
System.out.println("Auth 4: " + acctData.auth4);
System.out.println("Cards: " + acctData.cards);
System.out.println("Issue Date: " + acctData.issueday + "/" + acctData.issuemonth + "/" + acctData.issueyear);
System.out.println("Reason: " + acctData.reason);
System.out.println("Code: " + acctData.code);
System.out.println("Approver: " + acctData.approver);
System.out.println("Scode 1: " + acctData.scode1);
System.out.println("Scode 2: " + acctData.scode2);
System.out.println("Scode 3: " + acctData.scode3);
System.out.println("Status: " + acctData.status);
System.out.println("Limit: " + acctData.limit);
}
else // non-zero return code
{
System.out.println("An error occurred: ");
System.out.println("Response Code: " + acctData.respcode);
System.out.println("Reason Code: " + acctData.reascode);
System.out.println("Account ID: " + acctData.acctid);
System.out.println("CICS Function: " + acctData.cicsfunc);
}
}
/**
* This method was created in VisualAge.
* @return java.lang.String
* @exception java.io.IOException The exception description.
*/
public String getFactoryIOR() throws IOException {
String line;
final String filename = "C://IORFiles/genfac.ior";
FileInputStream in = null;
InputStreamReader isr = null;
BufferedReader br = null;
try
{
in = new FileInputStream(filename);
isr = new InputStreamReader(in);
br = new BufferedReader(isr);
}
catch(IOException e)
{
System.out.println("Client: Error opening file " + filename);
throw e;
}
try
{
line = br.readLine();
System.out.println("IOR:" + line); // for diagnostics
}
catch(IOException e)
{
System.out.println("Client: Error reading file " + filename);
throw e;
}
return line;