Skip to main content Skip to complementary content

Managing user routines

Talend Studio allows you to create user routines and modify them to fill your specific needs.

Creating custom routine JARs

Talend Studio allows you to create custom routine JARs and set up custom routine JAR dependencies on Jobs and Joblets.

The custom routine JAR allows you to package multiple user routines with their dependencies into a single archive. By setting up custom routine JAR dependencies on Jobs and Joblets, the code dependencies for Jobs and Joblets become more explicit and this can help reduce dependency conflicts.

About this task

To create a custom routine JAR:

Procedure

  1. In the Repository tree view, right-click Code > Custom Routine Jars and select Create Routine Jar from the contextual menu.
    The New Routine Jar dialog box is displayed.
  2. Fill in the generic properties such as Name, Purpose (optional), and Description (optional).
    The information you fill in the Description field will appear as a tooltip when your mouse pointer is moved over the custom routine JAR in the Repository tree view.
  3. Click Finish to save the new custom routine JAR.
    The newly added custom routine JAR is displayed under the Custom Routine Jars node.

    Now you can create inner routines and add them into the new custom routine JAR by right-clicking it and selecting Create routine from the contextual menu. For more information, see Creating user routines.

    You can add any existing global user routine into a custom routine JAR by right-clicking the global user routine and selecting Copy Routine to... from the contextual menu.

    Information noteNote: A global user routine will be kept as a global one after being copied into a custom routine JAR.
    Information noteTip: To rename a custom routine JAR or an inner routine, right-click it and select Edit properties from the contextual menu. Edit its name in the dialog box displayed.

Creating user routines

You can create your own routines according to your particular factorization needs.

Procedure

  1. If you need to create a global user routine, right-click Code > Global Routines and select Create routine from the contextual menu.
    You can create folders under the Global Routines node by right-clicking the node and selecting Create folder. The folders can help you organize global user routines.
  2. If you need to create an inner routine within a custom routine jar, right-click the custom routine jar under Code > Custom Routine Jars and select Create routine from the contextual menu.
  3. In the New routine dialog box displayed, fill in the generic properties for the new routine, such as Name, Purpose (optional), and Description (optional).
    The information you fill in the Description field will appear as a tooltip when your mouse pointer is moved over the routine in the Repository tree view.
  4. Click Finish.
    The newly created routine is saved in the Repository tree view. The routine editor opens to reveal a model routine which contains a function sample, by default, comprising descriptive text in blue, followed by the corresponding code.
    Information noteNote: We advise you to add detailed description for each function in the routine. The description should generally include the input and output parameters you would expect to use, as well as the results returned along with an example. This information tends to be useful for collaborative work and the maintenance of the routines.
  5. Modify or replace the function sample with your own code and press Ctrl+S to save the changes. Otherwise, the routine is saved automatically when you close the routine editor.
    Information noteNote: You can copy all or part of the code for a system routine and use it in a user routine by using the Ctrl+C and Ctrl+V commands, then adapt the code according to your needs.

Editing user routines

You can modify user routines whenever you like.

About this task

To edit a user routine:

Procedure

  1. Right-click the user routine in the Repository tree view and select Edit routine.
  2. The routine editor opens in the workspace, where you can modify the routine.
  3. Once you have adapted the routine to suit your needs, press Ctrl+S to save it.

Editing user routine libraries

You can edit the library of a user routine by importing external libraries (usually .jar files) for it.

You can import external libraries for an inner routine by editing the library of the custom routine jar in which the inner routine is packaged.

These external library files will be listed, like modules, in the Modules view in Talend Studio. For more information on the Modules view, see Installing external modules to Talend Studio.

The imported library will be also listed in the library file of Talend Studio.

About this task

To edit the library for a user routine or a custom routine jar, complete the following:

Procedure

  1. If the library to be imported is not available on your machine, either download and install it using the Modules view or download and store it in a local directory.
  2. In the Repository tree view, right-click the user routine or the custom routine jar and then select Edit Routine Libraries or Edit Routine Jar libraries.
    The Import External Library dialog box displays.
    Import External Library dialog box.
  3. Click New... to open the Module dialog box where you can import the external library.
    Module dialog box.
  4. Specify the library via one of the following ways:
    • Select the Platform option and then select the library from the list.
    • Select the Install a new module option and then click [...] to browse to the library in a local directory.

      You can import direct dependencies of a POM file by selecting the Install a new module option and then clicking [...] to browse to a POM file.

      If the MVN URI of the selected library exists in the file <TalendStudio>\configuration\MavenUriIndex.xml, it is automatically filled in the Default MVN URI field.

      If the MVN URI of the selected library is within the jar file, it is automatically detected and filled in the Custom MVN URI field if it is different from the default MVN URI. Select the Custom MVN URI check box if you want to change the custom Maven URI or use the custom Maven URI to install the library. If neither the default MVN URI nor the custom MVN URI exists, the Default MVN URI field is filled with mvn:org.talend.libraries/<jarname>/6.0.0-SNAPSHOT/jar.

    • Select the Artifact repository (local m2/nexus) option, enter the search keyword in the Module Name field, click Search Local to search in the local repository <TalendStudio>\configuration\.m2 or click Search Remote to search in the remote artifact repository, then select the library from the list below. The search keyword can be the partial or full name of the library.

      The Search Remote button is available only when the user libraries is set up in Talend Administration Center or Talend Management Console.

  5. If you want to import direct dependencies of the selected library, select the Add direct dependencies check box.
    The Add direct dependencies check box is selected and appears dimmed when you select the Install a new module option and browse to a POM file.

    The provided, test, and system scope dependencies cannot be imported. For more information about the dependency scope, see POM Reference.

    Information noteNote: The direct dependencies are imported based on the dependencies in the POM file within the selected library or the dependencies in the selected POM file. The direct dependencies can only be discovered if a POM file is present in the selected library and the POM file contains the groupId, artifactId, and version information for the dependencies.
  6. If you want to import transitive dependencies of the selected library, select the Add transitive dependencies check box, which is available when the Add direct dependencies check box is selected.
    Downloading the dependencies files may take a long time.
  7. Click OK to confirm your changes.
    The selected library file is listed in the Library File list in the Import External Library dialog box.

    If the Add direct dependencies check box is selected, the direct dependencies of the selected library or POM file are also listed in the Library File list.

    You can remove any of the already imported files by selecting the file in the Library File list and clicking Remove.

  8. To include the external libraries when building your Job as a standalone Job to be executed out of Talend Studio, select the corresponding Required check box. Otherwise, you will get the "class not found" error when the Job is executed.
    By default, the Required check box is selected for each imported library.
    If you have imported Camel or CXF libraries and you need to build your Job as an OSGI bundle to be deployed on Talend Runtime, it is recommended that you clear the Required check box to avoid issues caused by duplicate class paths, as those libraries are already provided with Talend Runtime bundles.
  9. Click Finish to close the dialog box.

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – please let us know!