Step 7 : ARM 4.0 Java Hello World example

Description

After we have created the ARM representation of our running application we will now create an ARM transaction instance using the newArmTransaction() method of the ArmTransactionFactory interface for measuring our transaction using the start/stop mechanism passing the following parameters:

  1. app - reference to the ARM representation of our running application.
  2. tranDef - reference to the ARM transaction definition object which represents the type of transaction we are going to measure.

Code

01: import org.opengroup.arm40.transaction.*;
02: 
03: public class HelloWorld  {
04: 
05:     public static void main(String argv[]) throws Exception {
06: 
07:         ArmTransactionFactory tranFactory;
08:         if ((tranFactory = getTranFactory())==null) {
09:             System.exit(-1);
10:         }
11:         ArmApplicationDefinition appDef = 
12:             tranFactory.newArmApplicationDefinition("HelloTranApp", 
13:                                                     null, null);
14:         ArmTransactionDefinition tranDef =
15:             tranFactory.newArmTransactionDefinition(appDef, "HelloWorldJava",
16:                                                     null, null);
17:         ArmApplication app = 
18:             tranFactory.newArmApplication(appDef, "Examples", null, null);
19:         ArmTransaction tran = tranFactory.newArmTransaction(app, tranDef);
20:         System.out.println("Hello world!");
21:         System.exit(0);
22:     }
23: }