How to create a custom java class

One Star

How to create a custom java class

I would like to read the product configurations once, at job start up and store them in a ?ProductConfiguration? custom objects. What would the recommended best practice to achieve this? Should I create a ?ProductConfiguration? class as a new routine and store that as a context variable?
One Star

Re: How to create a custom java class

Hi Sujee,
maybe you could use the context variable directly to store values (for a job's lifespan)..
Gabriel
Employee

Re: How to create a custom java class

Is this for a Job or a Route? If it is for a Job (designed in Integration perspective) then take a look at tContextLoad in the Compenent Reference Guide. It should do what you want.
One Star

Re: How to create a custom java class

Hi Gabriel/Edward,
Thanks for the replies. This is for a job and the product has different attributes that I like to load once at job start up and then refer later. The job is concerned about multiple products. So I was wondering whether I can create a custom java class (e.g. ProductConfiguration) and store a collection of this in the context.
I just got started with talend and routines seems to be the way in talend to create reusuable functions.
Is these also a way to define a custom class? then my problem will be solved.
One Star

Re: How to create a custom java class

Hi Sujee,
this is another use case Smiley Happy As far I understand, you want to cache product data to enrich/update/compare other passed data in your job? For that you could use a tMap component with lookups, while if there's a reasonable amount of product records, the records can be cached. In the tMap component you can specify if you want to load the lookup records once, for every row, if cache them, ..
See Talend tutorials
http://www.talendforge.org/tutorials/tutorial.php?idTuto=9
http://techblog.appirio.com/2009/12/performing-lookups-and-transformations.html
or you can search for other tutorials as well.
if we missed the point, then you rather explain you use case, it's better to follow the Talend tool's practice than fight against it.
Have fun
Gabriel
One Star

Re: How to create a custom java class

Thanks Gabriel.
I would like to load the product configuration once and later access that information in processing documents which belongs to a product.Number of records in the document table is very high and number of products are few.
So I did not want to access the product table for each record in the documents table. I will try to implement this using look ups. This solution can work specially if I can get the look up records loaded only once.