Creating pseudo components using tJavaFlex
The tJavaFlex
component is similar to the tJavaRow
component, in that it is included into a flow. The difference between the two components is that the tJavaFlex
component has pre and post processes that are performed before and after the individual rows are processed, so it is similar to a pre-built Talend component.
Getting ready
Open the job jo_cook_ch05_0030_tJavaFlex
.
How to do it…
Open the
tJavaFlex
component.In the Start Code section, enter the following:
String allNames = ""; Integer NB_LINE = 0;
In the Main Code section enter the following:
allNames = allNames + row1.name + "|"; NB_LINE += 1;
In the End Code section, enter the following:
globalMap.put("allNames", allNames); globalMap.put("tJavaFlex_1_NB_LINE", NB_LINE);
Open
tJava
and enter the following:System.out.println("All names concatenated: "+(String) globalMap.get("allNames")); System.out.println("Count of rows: "+(Integer) globalMap.get("tJavaFlex_1_NB_LINE"));
Run the job. You will see that...