Configuring a Job using a tJavaFlex component - 7.0

Java custom code

author
Talend Documentation Team
EnrichVersion
7.0
EnrichProdName
Talend Big Data
Talend Big Data Platform
Talend Data Fabric
Talend Data Integration
Talend Data Management Platform
Talend Data Services Platform
Talend ESB
Talend MDM Platform
Talend Open Studio for Big Data
Talend Open Studio for Data Integration
Talend Open Studio for ESB
Talend Open Studio for MDM
Talend Real-Time Big Data Platform
task
Data Governance > Third-party systems > Custom code components (Integration) > Java custom code components
Data Quality and Preparation > Third-party systems > Custom code components (Integration) > Java custom code components
Design and Development > Third-party systems > Custom code components (Integration) > Java custom code components
EnrichPlatform
Talend Studio

The tJavaFlex component is used to inject code at the start/end of a Job and to transform data transformations for each row.

A common Job using tJavaFlex is generally composed of:

  • a tFileInputDelimited component to read data from a text file,
  • a tJavaFlex to inject specific code at various moment of the Job processing (start, main or end parts),
  • a tLogRow component to print data in the console and processing information based on what the code injection says in the start and/or end part of tJavaFlex.

Procedure

  1. In the Palette, slide a tFileInputDelimited , a tJavaFlex and a tLogRow component onto the workspace.
  2. Connect tFileInputDelimited to tJavaRow and tJavaRow to tLogRow using a Row > Main link.
  3. Set the Basic settings of the tFileInputDelimited component.
  4. Double-click on tFileInputDelimited to display its Basic settings. The tFileInputDelimited reads the same text file and use the same schema as in the tJava and tJavaRow example .
  5. When prompted, click OK to accept the propagation or click afterward on the Sync columns button in the tJavaRow Basic settings view.
  6. Double-click on tJavaRow to display its Basic settings view. Add the following code in the Start code area:
    System.out.println("******The subjob begins to work!******");
    int nb_line=0
  7. Add the following code in the Main code area:
    row2.name=(row1.name).toUpperCase();
    nb_line++;
  8. Add the following code in the End code area:
    System.out.println("The total number of processed data is: "+nb_line);
    System.out.println("******The subjob finishes!******");
    Note: This code converts the column names to upper case.
  9. Execute the Job by pressing F6.

Results