To start the servers create two new console windows and run the servers in each of the windows. To start the servers:
. Go to the transobjxa
directory and run:
. ant server
. Go to the transobjres
directory and run:
. ant server
When both of them print out the message "Waiting for invocations ...", you can run the client test.
antTo execute the test programs run:
ant run
package transclient; import java.io.*; import java.util.*; import org.omg.CORBA.ORB; import org.omg.CosTransactions.Current; import com.sssw.jts.api.TransactionService; import com.sssw.jbroker.api.transaction.TSIdentification; import common.Utils; import common.ResourceMapper; import transobjres.*; import transobjxa.*; public class Test { public static void main(String args[]) throws Exception { | // Create a ResourceHandleMapper | ResourceMapper resMapper = new ResourceMapper(); | | System.setProperty("transaction.service.id", "EXAMPLE-TRANSCLIENT"); | | // Initialize the ORB and get instance of TM | ORB orb = ORB.init(args, null); | TransactionService ts = (TransactionService) | orb.resolve_initial_references("TransactionService"); | | // | // Recover TM with COLD Start. | // | ts.recover(resMapper, true, null); | | | String testIOR; | | // Create reference to remote transactional object from transobjres | testIOR = Utils.readIOR("../transobjres/ior"); | TestRes test1 = | TestResHelper.narrow(orb.string_to_object(testIOR)); | | // Create reference to remote transactional object from transobjxa | testIOR = Utils.readIOR("../transobjxa/ior"); | TestXA test2 = | TestXAHelper.narrow(orb.string_to_object(testIOR)); | | Current txCurrent = ts.getTransactionCurrent(); | txCurrent.begin(); | | test1.insert(1, 11); | System.out.println("+ In Transaction test1.Find(1) => 11 => "+test1.findv2(1)); | | test2.insert(1, 22); | System.out.println("+ In Transaction test2.Find(1) => 22 => "+test2.findv2(1)); | | txCurrent.rollback(); | | System.out.println("+ After Rollback test1.Find(1) => -1 => "+test1.findv2(1)); | System.out.println("+ After Rollback test2.Find(1) => -1 => "+test2.findv2(1)); } }
Copyright © 2000-2003, Novell, Inc. All rights reserved. |