i'm migrating some components from java jet to the new component kit;
How to use contexte variables in compnents developped with new component kit.
With new Talend Component Kit you don't need to implement anything special in your Component code to support context variables. Context variables are supported by Studio out of the box.
It works in following way:
1. Component option value goes to generated code without changes.
If user set a value with context variable he may see following Java code fragment in generated code
(click on "Code" tab to see generated code)2. In generated you may see that Map<String, Object> is created for Component options. Context variables are evaluated during this configuration Map setup. Map will hold evaluated context variable value (e.g. "myValue" string)
3. Then this Map is used to initialize Component. In Component code you will get evaluated context variable value (you will get "myValue" instead of context.input in Component code).
However, note that Components developed with new Component Kit support only static values (i.e. values which are not changed during Job runtime), because Component options are evaluated only once at the beginning.
If you have more questions don't hesitate to ask.
If you found some bug related to context variable value support, please create a ticket in our Jira for TUP (Studio) project.
It is not possible to access global/context variables directly in Component code.
You may set global/context variable as value of Component UI property.
Then global/context variable value will be evaluated during Job code execution and set as value of Component Configuration class (a POJO class which defines Component properties)
In your Component code you may get variables values as values in your Configuration class.
I have tried this solution and while it works for context variables, it is treating the global variables as text (i.e. I get "jobName" output instead of the actual name of the job)
I have included below a screen shot of the configuration in my studio and code for the configuration object and object for the list below.
Configuration (Studio 7.1.1)
Talend named a Leader.
Kickstart your first data integration and ETL projects.
Look at6 ways to start utilizing Machine Learning with Amazon We Services and Talend
Test drive Talend's enterprise products.