One Star

accessing globalMap inside a custom routine

A colleague of mine said that this was possible, by passing in the (entire) globalMap to the routine.
Does anyone know the best syntax to pass in, and receiving routine example to show how to get and put, once in the routine?
Thanks.
1 REPLY
Community Manager

Re: accessing globalMap inside a custom routine

Hi
Yes, it is possible to pass the global variable globalMap to custom routine. For example:
Here is my custom routine,
public class myroutine {

public static void passGlobalVariableToRoutine(java.util.Map<String, Object> globalMap) {
globalMap.put("key", "shong");

}
}

code on tJava:
myroutine.passGlobalVariableToRoutine(globalMap);
String s=(String)globalMap.get("key");
System.out.println(s);

output on console:
Starting job test at 09:30 15/09/2011.
connecting to socket on port 3935
connected
shong
disconnected
Job test ended at 09:30 15/09/2011.

Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business