Although this recipe is centered on the use of tJava
, it also acts as a convenient means of illustrating how the context
and globalMap
variables can be directly referenced from within the majority of Talend components.
Open jo_cook_ch05_0010_tJavaContextGlobalMap
, then open the context panel, and you should see a variable named testValue
.
Open
tMap_1
and type in the following code:System.out.println("tJava_1"); context.testValue ="testValue is now initialized"; globalMap.put("gmTestValue", "gmTestValue is now initialized");
Open
tMap_2
and type in the following code:System.out.println("tJava_2"); System.out.println("context.testValue is: "+context.testValue); System.out.println("gmTestValue is: "+(String) globalMap.get("gmTestValue"));
Run the job. You will see that the variables initialized in the first
tJava
are printed correctly in the second.