The problem is that I have an old web service library that has a hashtable of global options which it combines with hashtable of request options. I cann’t influence request code, but I can set the global hashtable. And I was just curious if there is a simple way to implement an extention to Hashtable class that will perform a callback for some of the key to read some thread-local variable instead of its original value?
EDIT: I forgot to mention that I’m bound to JDK 1.4.2.
You can create a new class that derives from
Hashtableand override theget()method.Building on the code of twolfe18:
To set the value, use
map.special.set(value). The value will be different per thread.