Developer forum

Forum » Development » When are table scripts instantiated

When are table scripts instantiated

Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Hi there,

When are table scripts instantiated? Once per application life time or once per job run? I have a TableScript that needs to compare incoming users to existing users. I want to load the existing users just once, and not N+1 for every row imported in ProcessInputRow. However, I am not sure what the best approach to store my user data is. If I store it in a static, it won't be recreated until the app recycles. Can I store it in an instance variable and assign it in the constructor and expect my class to be instantiated on each run?

Thanks,

Imar


Replies

 
Jonas Krarup Dam
Reply

Hi Imar,

That is a great question.

It's is instantiated once, and kept in context.current.

Unless I've misread the code, this means that the tablescript object is instanciated once at the beginning of the integration activity, and disposed of when the activity finishes, and the current request to the server ends.

Regards, Jonas

 

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Gotcha. So if I understand correctly, I could use a normal (not a static) constructor, create my data there and store it in an instance field so it's accessible for all the rows, right?

Imar

 
Jonas Krarup Dam
Reply

I haven't tested it, but yes, that sounds right.

Alternatively, just put it in a lazy-load property :-)

/Jonas

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

>> Alternatively, just put it in a lazy-load property :-)

Yep, that makes sense too. And just like the constructor, requires the TableScript to be instantiated per run or might have wrong data. Wil check it out and see if that's how it behaves.

Imar

 

You must be logged in to post in the forum