Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I have a scenario where i want to make use of udf's defined in an external class. How can i instantiate the parent class in my current job so that i can use the object instantiated across my job and sub jobs?
I have tried using tJava component for instantiation but the objects defined in my tjava are scoping only in very next tmap component and not beyond that.
How can i declare and instantiate objects at class level(can be re-used across subjobs) as defining objects in tjava has a limited scope.
Appreciate your suggestion, Thanks in advance.
An easy (but sometimes fiddly) way of doing this is to use the globalMap. Instantiate your object and add it to the globalMap. Then when you want to use it, retrieve it from the globalMap. For example....
Adding it to the globalMap
MyClass myClass = new MyClass(); //Do something with the object globalMap.put("myclass", myClass);
Then, when you want to use it....
MyClass myClass = ((MyClass)globalMap.get("myclass"));
....or you could just use it like so....
((MyClass)globalMap.get("myclass")).yourObjectMethod();
An easy (but sometimes fiddly) way of doing this is to use the globalMap. Instantiate your object and add it to the globalMap. Then when you want to use it, retrieve it from the globalMap. For example....
Adding it to the globalMap
MyClass myClass = new MyClass(); //Do something with the object globalMap.put("myclass", myClass);
Then, when you want to use it....
MyClass myClass = ((MyClass)globalMap.get("myclass"));
....or you could just use it like so....
((MyClass)globalMap.get("myclass")).yourObjectMethod();
Hi Rhall,
Thank you vmuch, That works.