Configuring the tJavaFlex component - Cloud - 8.0

Java custom code

Version
Cloud
8.0
Language
English
Product
Talend Big Data
Talend Big Data Platform
Talend Cloud
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 Data Quality
Talend Open Studio for ESB
Talend Real-Time Big Data Platform
Module
Talend Studio
Content
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
Last publication date
2023-09-14

Procedure

  1. Double-click tJavaFlex to display its Basic settings view and define its properties.
  2. Click the [...] button next to Edit schema to open the corresponding dialog box where you can define the data structure to pass to the component that follows.
  3. Click the [+] button to add two columns: key and value and then set their types to Integer and String respectively.
  4. Click OK to validate your changes and close the dialog box.
  5. In the Basic settings view of tJavaFlex, select the Data Auto Propagate check box to automatically propagate data to the component that follows.
    In this example, we do not want to do any transformation on the retrieved data.
  6. In the Start code field, enter the code to be executed in the initialization phase.
    In this example, the code indicates the initialization of tJavaFlex by displaying the START message and sets up the loop and the variables to be used afterwards in the Java code:
    System.out.println("## START\n#");
    String [] valueArray = {"Miss", "Mrs", "Mr"};
    
    for (int i=0;i<valueArray.length;i++) {
  7. In the Main code field, enter the code you want to apply on each of the data rows.
    In this example, we want to display each key with its value:
    row1.key = i;
    row1.value = valueArray[i];
    Warning:

    In the Main code field, "row1" corresponds to the name of the link that comes out of tJavaFlex. If you rename this link, you have to modify the code of this field accordingly.

  8. In the End code field, enter the code that will be executed in the closing phase.
    In this example, the brace (curly bracket) closes the loop and the code indicates the end of the execution of tJavaFlex by displaying the END message:
    }
    System.out.println("#\n## END");
  9. If needed, double-click tLogRow and in its Basic settings view, click the [...] button next to Edit schema to make sure that the schema has been correctly propagated.