ajayk0719 / jai-tools

Automatically exported from code.google.com/p/jai-tools
0 stars 0 forks source link

Lookup: avoid loading/reading resource everytime #36

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
When computing several statistics, the StreamingSampleStats invokes several
times the ProcessorFactory.getForStatistic method which invokes
Lookup.getProviders("jaitools.numeric.processor").

Each time the getProviders method is invoked, it looks for the resource,
creates a stream and a reader and read the stream. Although these stops
don't represent a heavy operation, I think the Lookup class can somehow
cache (softly?) the providers the first time and return them for future calls.

Original issue reported on code.google.com by dany.Geo...@gmail.com on 14 Apr 2010 at 7:34

GoogleCodeExporter commented 9 years ago
Thanks Daniele - good idea.

Added caching using a HashMap with WeakReference values. Added unit tests.

Committed to 1.0.x branch (r1172) and trunk (r1171)

Original comment by michael.bedward@gmail.com on 16 Apr 2010 at 6:17