Six Stars

Creating a globally accessible HashMap

Hi, first off I know about globalMap and context Smiley Wink
For various reasons I would like the option of loading up some re-usable lookup tables at the start of my job and then referencing them in code (tJavaRow etc) across subjobs. Is there a way to create variables in the scope of the TalendJob class just like globalMap? I know I could store everything in globalMap with some sensible key definition but it doesn't feel appropriate to do so and obviously I don't really want to build my own HashMap and then store /that/ in the globalMap either ...
TIA, Mark
4 REPLIES
Fifteen Stars

Re: Creating a globally accessible HashMap

Six Stars

Re: Creating a globally accessible HashMap

Use a routine with a ConcurrentHashMap (https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ConcurrentHashMap.html)

OK but if I do that say, at the first block of a tJavaFlex, it will be within the scope of the enclosing subjob and I want to be able to reference it directly from components in subsequent subjobs so I'm not quite sure how that needs to be declared to have the visibility I need?
Ta, Mark
Six Stars

Re: Creating a globally accessible HashMap

OK - I have this working - create the HashMap and then store its reference in the globalMap - works well and should simplify some stuff that would otherwise require tMaps and redundant queries.
Fifteen Stars

Re: Creating a globally accessible HashMap

You answered your own question before I saw it. That is how I deal with some of my lookups to make them a little more straight forward :-)
Rilhia Solutions