Example: lr.end_transaction

Example 1 - Simple Transaction

The sample below illustrates timing the duration of a method call getStockList from an ORB interface. The sample code does not check for exceptions.

lr.start_transaction("GetStocks");
orStockServer1.getStockList();
lr.end_transaction("GetStocks", lr.PASS);



Example 2 - Conditional transaction sample

The sample below illustrates timing the duration of the same sample code, however it adds checks for exceptions and ensures that the getStockList() method returns an non-zero length array.

lr.start_transaction("GetStocks");
try { String stocks[];
stocks = orStockServer1.getStockList();
if (stocks.length == 0)         throw new Exception("No stocks returned/available");
lr.end_transaction("GetStocks", lr.PASS);
} catch (Exception e1) {      lr.end_transaction("GetStocks", lr.FAIL);      lr.message(" An exception occurred : " + e1.toString() );     }